Ë
    �\;jJ  ã                   óê   — d dl mZ d dlmZmZmZ d dlZ G d„ d«      Zdedefd„Z		 	 	 	 ddeeef   d	e
d
e
dededeej                  e
f   fd„Z	 	 	 ddedej                  de
dedee   dee
   fd„Zy)é    )ÚPath)ÚOptionalÚTupleÚUnionNc            
       ó,   — e Zd ZdZdededededef
d„Zy)	Ú	AudioInfoz0Audio info, return type of backend info functionÚsample_rateÚnum_samplesÚnum_channelsÚbits_per_sampleÚencodingc                 óJ   — || _         || _        || _        || _        || _        y )N)r	   r
   r   r   r   )Úselfr	   r
   r   r   r   s         úfG:\00. PROJECTS\API\Inventory\templateJSON\kerjaOCR\Lib\site-packages\paddle/audio/backends/backend.pyÚ__init__zAudioInfo.__init__   s+   € ð 'ˆÔØ&ˆÔØ(ˆÔØ.ˆÔØ ˆ�ó    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚintÚstrr   © r   r   r   r      s:   „ Ù:ð!àð!ð ð!ð ð	!ð
 ð!ð ô!r   r   ÚfilepathÚreturnc                 ó   — t        d«      ‚)a  Get signal information of input audio file.

    Args:
       filepath: audio path or file object.

    Returns:
        AudioInfo: info of the given audio.

    Example:
        .. code-block:: python

            >>> import os
            >>> import paddle

            >>> sample_rate = 16000
            >>> wav_duration = 0.5
            >>> num_channels = 1
            >>> num_frames = sample_rate * wav_duration
            >>> wav_data = paddle.linspace(-1.0, 1.0, num_frames) * 0.1
            >>> waveform = wav_data.tile([num_channels, 1])
            >>> base_dir = os.getcwd()
            >>> filepath = os.path.join(base_dir, "test.wav")

            >>> paddle.audio.save(filepath, waveform, sample_rate)
            >>> wav_info = paddle.audio.info(filepath)
    úplease set audio backend©ÚNotImplementedError)r   s    r   Úinfor    '   s   € ô8 Ð8Ó
9Ð9r   Úframe_offsetÚ
num_framesÚ	normalizeÚchannels_firstc                 ó   — t        d«      ‚)a¢  Load audio data from file.Load the audio content start form frame_offset, and get num_frames.

    Args:
        frame_offset: from 0 to total frames,
        num_frames: from -1 (means total frames) or number frames which want to read,
        normalize:
            if True: return audio which norm to (-1, 1), dtype=float32
            if False: return audio with raw data, dtype=int16

        channels_first:
            if True: return audio with shape (channels, time)

    Return:
        Tuple[paddle.Tensor, int]: (audio_content, sample rate)

    Examples:
        .. code-block:: python

            >>> import os
            >>> import paddle

            >>> sample_rate = 16000
            >>> wav_duration = 0.5
            >>> num_channels = 1
            >>> num_frames = sample_rate * wav_duration
            >>> wav_data = paddle.linspace(-1.0, 1.0, num_frames) * 0.1
            >>> waveform = wav_data.tile([num_channels, 1])
            >>> base_dir = os.getcwd()
            >>> filepath = os.path.join(base_dir, "test.wav")

            >>> paddle.audio.save(filepath, waveform, sample_rate)
            >>> wav_data_read, sr = paddle.audio.load(filepath)
    r   r   )r   r!   r"   r#   r$   s        r   Úloadr&   F   s   € ôR Ð8Ó
9Ð9r   Úsrcr	   r   r   c                 ó   — t        d«      ‚)aä  
    Save audio tensor to file.

    Args:
        filepath: saved path
        src: the audio tensor
        sample_rate: the number of samples of audio per second.
        channels_first: src channel information
            if True, means input tensor is (channels, time)
            if False, means input tensor is (time, channels)
        encoding:encoding format, wave_backend only support PCM16 now.
        bits_per_sample: bits per sample, wave_backend only support 16 bits now.

    Returns:
        None

    Examples:
        .. code-block:: python

            >>> import paddle

            >>> sample_rate = 16000
            >>> wav_duration = 0.5
            >>> num_channels = 1
            >>> num_frames = sample_rate * wav_duration
            >>> wav_data = paddle.linspace(-1.0, 1.0, num_frames) * 0.1
            >>> waveform = wav_data.tile([num_channels, 1])
            >>> filepath = "./test.wav"

            >>> paddle.audio.save(filepath, waveform, sample_rate)
    r   r   )r   r'   r	   r$   r   r   s         r   Úsaver)   r   s   € ôP Ð8Ó
9Ð9r   )r   éÿÿÿÿTT)TNé   )Úpathlibr   Útypingr   r   r   Úpaddler   r   r    r   ÚboolÚTensorr&   r)   r   r   r   Ú<module>r1      sè   ðõ ß )Ñ )ã ÷!ñ !ð$:�3ð :˜9ó :ðB ØØØñ):Ø�C˜�IÑð):àð):ð ð):ð ð	):ð
 ð):ð ˆ6�=‰=˜#ÐÑó):ð`  Ø"Ø%'ñ(:Øð(:à	�‰ð(:ð ð(:ð ð	(:ð
 �s‰mð(:ð ˜c‘]ô(:r   