o
     Õj°  ã                   @   s¾   d dl mZ d dlmZmZmZ d dlZG dd„ dƒZdedefdd	„Z		 	
		ddeeef de
de
dededeeje
f fdd„Z			ddedejde
dedee dee
 fdd„ZdS )é    )ÚPath)ÚOptionalÚTupleÚUnionNc                
   @   s.   e Zd ZdZdededededef
dd„Zd	S )
Ú	AudioInfoz0Audio info, return type of backend info functionÚsample_rateÚnum_samplesÚnum_channelsÚbits_per_sampleÚencodingc                 C   s"   || _ || _|| _|| _|| _d S )N)r   r   r	   r
   r   )Úselfr   r   r	   r
   r   © r   ú^/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/paddle/audio/backends/backend.pyÚ__init__   s
   
zAudioInfo.__init__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚintÚstrr   r   r   r   r   r      s    þýüûúr   ÚfilepathÚreturnc                 C   ó   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   r   r   r   Úinfo'   s   r   éÿÿÿÿTÚframe_offsetÚ
num_framesÚ	normalizeÚchannels_firstc                 C   r   )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!   r   r   r   ÚloadF   s   )r"   é   Úsrcr   r   r
   c                 C   r   )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
   r   r   r   Úsaver   s   (r%   )r   r   TT)TNr#   )Úpathlibr   Útypingr   r   r   Zpaddler   r   r   r   ÚboolZTensorr"   r%   r   r   r   r   Ú<module>   sL   !û
ÿþýüû
ú0úÿþýüûú