Ë
    P/æjXS ã                   óV  — d dl Z d dlZd dlmZmZmZmZmZ d dlZd dlm	Z	 d dl
mZ d dlmZ d dlmZ d dlmZmZmZmZmZ g Z G d„ d	ej0                  j2                  «      Z G d
„ dej0                  j2                  «      Z G d„ dej0                  j2                  «      Z G d„ dej0                  j2                  «      Z G d„ dej0                  j2                  «      Z G d„ dej0                  j2                  «      Z G d„ dej0                  j2                  «      Z  G d„ dej0                  j2                  «      Z! G d„ dej0                  j2                  «      Z" G d„ dej0                  j2                  «      Z# G d„ dej0                  j2                  «      Z$ G d„ dej0                  j2                  «      Z% G d „ d!ej0                  j2                  «      Z& G d"„ d#ej0                  j2                  «      Z' G d$„ d%ej0                  j2                  «      Z( G d&„ d'ej0                  j2                  «      Z) G d(„ d)e)«      Z* G d*„ d+e)«      Z+ G d,„ d-ej0                  j2                  «      Z, G d.„ d/ej0                  j2                  «      Z- G d0„ d1ej0                  j2                  «      Z. G d2„ d3ej0                  j2                  «      Z/ G d4„ d5ej0                  j2                  «      Z0 G d6„ d7ej0                  j2                  «      Z1 G d8„ d9eej0                  j2                  «      Z2 G d:„ d;ej0                  j2                  «      Z3 G d<„ d=ej0                  j2                  «      Z4 G d>„ d?ej0                  j2                  «      Z5d@e6dAe7dBee6e6f   fdC„Z8 G dD„ dEej0                  j2                  «      Z9 G dF„ dGej0                  j2                  «      Z: G dH„ dIej0                  j2                  «      Z; G dJ„ dKej0                  j2                  «      Z< G dL„ dMej0                  j2                  «      Z=y)Né    N)ÚCallableÚOptionalÚSequenceÚTupleÚUnion)ÚTensor)ÚLazyModuleMixin)ÚUninitializedParameter)Ú
functional)Ú_apply_sinc_resample_kernelÚ_check_convolve_modeÚ_fix_waveform_shapeÚ_get_sinc_resample_kernelÚ_stretch_waveformc                   óÐ   ‡ — e Zd ZdZg d¢Zddddej                  ddddd	ddfd
edee   dee   dede	de
f   dee   deeef   dee   dedededee   ddfˆ fd„Zde
de
fd„Zˆ xZS )ÚSpectrogramaù  Create a spectrogram from a audio signal.

    .. devices:: CPU CUDA

    .. properties:: Autograd TorchScript

    Args:
        n_fft (int, optional): Size of FFT, creates ``n_fft // 2 + 1`` bins. (Default: ``400``)
        win_length (int or None, optional): Window size. (Default: ``n_fft``)
        hop_length (int or None, optional): Length of hop between STFT windows. (Default: ``win_length // 2``)
        pad (int, optional): Two sided padding of signal. (Default: ``0``)
        window_fn (Callable[..., Tensor], optional): A function to create a window tensor
            that is applied/multiplied to each frame/window. (Default: ``torch.hann_window``)
        power (float or None, optional): Exponent for the magnitude spectrogram,
            (must be > 0) e.g., 1 for magnitude, 2 for power, etc.
            If None, then the complex spectrum is returned instead. (Default: ``2``)
        normalized (bool or str, optional): Whether to normalize by magnitude after stft. If input is str, choices are
            ``"window"`` and ``"frame_length"``, if specific normalization type is desirable. ``True`` maps to
            ``"window"``. (Default: ``False``)
        wkwargs (dict or None, optional): Arguments for window function. (Default: ``None``)
        center (bool, optional): whether to pad :attr:`waveform` on both sides so
            that the :math:`t`-th frame is centered at time :math:`t \times \text{hop\_length}`.
            (Default: ``True``)
        pad_mode (string, optional): controls the padding method used when
            :attr:`center` is ``True``. (Default: ``"reflect"``)
        onesided (bool, optional): controls whether to return half of results to
            avoid redundancy (Default: ``True``)
        return_complex (bool, optional):
            Deprecated and not used.

    Example
        >>> waveform, sample_rate = torchaudio.load("test.wav", normalize=True)
        >>> transform = torchaudio.transforms.Spectrogram(n_fft=800)
        >>> spectrogram = transform(waveform)

    ©Ún_fftÚ
win_lengthÚ
hop_lengthÚpadÚpowerÚ
normalizedé�  Nr   ç       @FTÚreflectr   r   r   r   Ú	window_fn.r   r   ÚwkwargsÚcenterÚpad_modeÚonesidedÚreturn_complexÚreturnc                 ó²  •— t         t        | �  «        t        j                  j                  d«       || _        |�|n|| _        |�|n| j                  dz  | _        |€ || j                  «      n || j                  fi |¤Ž}| j                  d|«       || _
        || _        || _        |	| _        |
| _        || _        |�t!        j"                  d«       y y )Nz!torchaudio.transforms.Spectrogramé   ÚwindowzÍ`return_complex` argument is now deprecated and is not effective.`torchaudio.transforms.Spectrogram(power=None)` always returns a tensor with complex dtype. Please remove the argument in the function call.)Úsuperr   Ú__init__ÚtorchÚ_CÚ_log_api_usage_oncer   r   r   Úregister_bufferr   r   r   r   r    r!   ÚwarningsÚwarn)Úselfr   r   r   r   r   r   r   r   r   r    r!   r"   r&   Ú	__class__s                 €úd/root/repos/pocs/video-evals/.venv/lib/python3.12/site-packages/torchaudio/transforms/_transforms.pyr(   zSpectrogram.__init__?   sÎ   ø€ ô 	Œk˜4Ñ)Ô+Ü�‰×$Ñ$Ð%HÔIØˆŒ
ð )3Ð(>™*ÀEˆŒØ(2Ð(>™*ÀDÇOÁOÐWXÑDXˆŒØ/6¨‘˜4Ÿ?™?Ô+ÁIÈdÏoÉoÑDiÐahÑDiˆØ×Ñ˜X vÔ.ØˆŒØˆŒ
Ø$ˆŒØˆŒØ ˆŒØ ˆŒØÐ%Ü�M‰MðRõð &ó    Úwaveformc                 ó  — t        j                  || j                  | j                  | j                  | j
                  | j                  | j                  | j                  | j                  | j                  | j                  «      S )a<  
        Args:
            waveform (Tensor): Tensor of audio of dimension (..., time).

        Returns:
            Tensor: Dimension (..., freq, time), where freq is
            ``n_fft // 2 + 1`` where ``n_fft`` is the number of
            Fourier bins, and time is the number of window hops (n_frame).
        )ÚFÚspectrogramr   r&   r   r   r   r   r   r   r    r!   ©r/   r3   s     r1   ÚforwardzSpectrogram.forwardd   s^   € ô �}‰}ØØ�H‰HØ�K‰KØ�J‰JØ�O‰OØ�O‰OØ�J‰JØ�O‰OØ�K‰KØ�M‰MØ�M‰Mó
ð 	
r2   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__constants__r)   Úhann_windowÚintr   r   r   Úfloatr   ÚboolÚstrÚdictr(   r8   Ú__classcell__©r0   s   @r1   r   r      sü   ø„ ñ#òH X€Mð Ø$(Ø$(ØØ+0×+<Ñ+<Ø!$Ø',Ø"&ØØ!ØØ)-ñ#àð#ð ˜S‘Mð#ð ˜S‘Mð	#ð
 ð#ð ˜C ˜KÑ(ð#ð ˜‰ð#ð ˜$ ˜)Ñ$ð#ð ˜$‘ð#ð ð#ð ð#ð ð#ð ! ™ð#ð 
õ#ðJ
 ð 
¨6÷ 
r2   r   c                   óÄ   ‡ — e Zd ZdZg d¢Zddddej                  dddddf
d	ed
ee   dee   dede	de
f   deeef   dee   dedededdfˆ fd„Zdde
dee   de
fd„Zˆ xZS )ÚInverseSpectrogramaJ  Create an inverse spectrogram to recover an audio signal from a spectrogram.

    .. devices:: CPU CUDA

    .. properties:: Autograd TorchScript

    Args:
        n_fft (int, optional): Size of FFT, creates ``n_fft // 2 + 1`` bins. (Default: ``400``)
        win_length (int or None, optional): Window size. (Default: ``n_fft``)
        hop_length (int or None, optional): Length of hop between STFT windows. (Default: ``win_length // 2``)
        pad (int, optional): Two sided padding of signal. (Default: ``0``)
        window_fn (Callable[..., Tensor], optional): A function to create a window tensor
            that is applied/multiplied to each frame/window. (Default: ``torch.hann_window``)
        normalized (bool or str, optional): Whether the stft output was normalized by magnitude. If input is str,
            choices are ``"window"`` and ``"frame_length"``, dependent on normalization mode. ``True`` maps to
            ``"window"``. (Default: ``False``)
        wkwargs (dict or None, optional): Arguments for window function. (Default: ``None``)
        center (bool, optional): whether the signal in spectrogram was padded on both sides so
            that the :math:`t`-th frame is centered at time :math:`t \times \text{hop\_length}`.
            (Default: ``True``)
        pad_mode (string, optional): controls the padding method used when
            :attr:`center` is ``True``. (Default: ``"reflect"``)
        onesided (bool, optional): controls whether spectrogram was used to return half of results to
            avoid redundancy (Default: ``True``)

    Example
        >>> batch, freq, time = 2, 257, 100
        >>> length = 25344
        >>> spectrogram = torch.randn(batch, freq, time, dtype=torch.cdouble)
        >>> transform = transforms.InverseSpectrogram(n_fft=512)
        >>> waveform = transform(spectrogram, length)
    r   r   Nr   FTr   r   r   r   r   r   .r   r   r   r    r!   r#   c                 ó6  •— t         t        | �  «        || _        |�|n|| _        |�|n| j                  dz  | _        |€ || j                  «      n || j                  fi |¤Ž}| j                  d|«       || _        || _        || _	        |	| _
        |
| _        y ©Nr%   r&   )r'   rG   r(   r   r   r   r,   r   r   r   r    r!   )r/   r   r   r   r   r   r   r   r   r    r!   r&   r0   s               €r1   r(   zInverseSpectrogram.__init__    s˜   ø€ ô 	Ô  $Ñ0Ô2ØˆŒ
ð )3Ð(>™*ÀEˆŒØ(2Ð(>™*ÀDÇOÁOÐWXÑDXˆŒØ/6¨‘˜4Ÿ?™?Ô+ÁIÈdÏoÉoÑDiÐahÑDiˆØ×Ñ˜X vÔ.ØˆŒØ$ˆŒØˆŒØ ˆŒØ ˆ�r2   r6   Úlengthc                 óô   — t        j                  ||| j                  | j                  | j                  | j
                  | j                  | j                  | j                  | j                  | j                  «      S )a.  
        Args:
            spectrogram (Tensor): Complex tensor of audio of dimension (..., freq, time).
            length (int or None, optional): The output length of the waveform.

        Returns:
            Tensor: Dimension (..., time), Least squares estimation of the original signal.
        )r5   Úinverse_spectrogramr   r&   r   r   r   r   r   r    r!   )r/   r6   rJ   s      r1   r8   zInverseSpectrogram.forward»   s\   € ô ×$Ñ$ØØØ�H‰HØ�K‰KØ�J‰JØ�O‰OØ�O‰OØ�O‰OØ�K‰KØ�M‰MØ�M‰Mó
ð 	
r2   ©N)r9   r:   r;   r<   r=   r)   r>   r?   r   r   r   r   rA   rB   rC   r(   r8   rD   rE   s   @r1   rG   rG   }   sä   ø„ ñò@ X€Mð Ø$(Ø$(ØØ+0×+<Ñ+<Ø',Ø"&ØØ!Øñ!àð!ð ˜S‘Mð!ð ˜S‘Mð	!ð
 ð!ð ˜C ˜KÑ(ð!ð ˜$ ˜)Ñ$ð!ð ˜$‘ð!ð ð!ð ð!ð ð!ð 
õ!ñ6
 6ð 
°8¸C±=ð 
ÈF÷ 
r2   rG   c                   ó´   ‡ — e Zd ZdZg d¢Zddddej                  dddddf
d	ed
edee   dee   de	de
f   dedee   dedee   deddfˆ fd„Zde
de
fd„Zˆ xZS )Ú
GriffinLimai  Compute waveform from a linear scale magnitude spectrogram using the Griffin-Lim transformation.

    .. devices:: CPU CUDA

    .. properties:: Autograd TorchScript

    Implementation ported from
    *librosa* :cite:`brian_mcfee-proc-scipy-2015`, *A fast Griffin-Lim algorithm* :cite:`6701851`
    and *Signal estimation from modified short-time Fourier transform* :cite:`1172092`.

    Args:
        n_fft (int, optional): Size of FFT, creates ``n_fft // 2 + 1`` bins. (Default: ``400``)
        n_iter (int, optional): Number of iteration for phase recovery process. (Default: ``32``)
        win_length (int or None, optional): Window size. (Default: ``n_fft``)
        hop_length (int or None, optional): Length of hop between STFT windows. (Default: ``win_length // 2``)
        window_fn (Callable[..., Tensor], optional): A function to create a window tensor
            that is applied/multiplied to each frame/window. (Default: ``torch.hann_window``)
        power (float, optional): Exponent for the magnitude spectrogram,
            (must be > 0) e.g., 1 for magnitude, 2 for power, etc. (Default: ``2``)
        wkwargs (dict or None, optional): Arguments for window function. (Default: ``None``)
        momentum (float, optional): The momentum parameter for fast Griffin-Lim.
            Setting this to 0 recovers the original Griffin-Lim method.
            Values near 1 can lead to faster convergence, but above 1 may not converge. (Default: ``0.99``)
        length (int, optional): Array length of the expected output. (Default: ``None``)
        rand_init (bool, optional): Initializes phase randomly if True and to zero otherwise. (Default: ``True``)

    Example
        >>> batch, freq, time = 2, 257, 100
        >>> spectrogram = torch.randn(batch, freq, time)
        >>> transform = transforms.GriffinLim(n_fft=512)
        >>> waveform = transform(spectrogram)
    )r   Ún_iterr   r   r   rJ   ÚmomentumÚ	rand_initr   é    Nr   ç®Gáz®ï?Tr   rP   r   r   r   .r   r   rQ   rJ   rR   r#   c                 ó„  •— t         t        | �  «        d|cxk  rdk  sn t        dj	                  |«      «      ‚|| _        || _        |�|n|| _        |�|n| j                  dz  | _        |€ || j                  «      n || j                  fi |¤Ž}| j                  d|«       |	| _
        || _        || _        |
| _        y )Nr   é   z/momentum must be in the range [0, 1). Found: {}r%   r&   )r'   rO   r(   Ú
ValueErrorÚformatr   rP   r   r   r,   rJ   r   rQ   rR   )r/   r   rP   r   r   r   r   r   rQ   rJ   rR   r&   r0   s               €r1   r(   zGriffinLim.__init__ö   sº   ø€ ô 	Œj˜$Ñ(Ô*à�XÔ! Ô!ÜÐN×UÑUÐV^Ó_Ó`Ð`àˆŒ
ØˆŒØ(2Ð(>™*ÀEˆŒØ(2Ð(>™*ÀDÇOÁOÐWXÑDXˆŒØ/6¨‘˜4Ÿ?™?Ô+ÁIÈdÏoÉoÑDiÐahÑDiˆØ×Ñ˜X vÔ.ØˆŒØˆŒ
Ø ˆŒØ"ˆ�r2   Úspecgramc                 óò   — t        j                  || j                  | j                  | j                  | j
                  | j                  | j                  | j                  | j                  | j                  «
      S )a/  
        Args:
            specgram (Tensor):
                A magnitude-only STFT spectrogram of dimension (..., freq, frames)
                where freq is ``n_fft // 2 + 1``.

        Returns:
            Tensor: waveform of (..., time), where time equals the ``length`` parameter if given.
        )r5   Ú
griffinlimr&   r   r   r   r   rP   rQ   rJ   rR   ©r/   rY   s     r1   r8   zGriffinLim.forward  sW   € ô �|‰|ØØ�K‰KØ�J‰JØ�O‰OØ�O‰OØ�J‰JØ�K‰KØ�M‰MØ�K‰KØ�N‰Nó
ð 	
r2   )r9   r:   r;   r<   r=   r)   r>   r?   r   r   r   r@   rC   rA   r(   r8   rD   rE   s   @r1   rO   rO   Ó   sÔ   ø„ ñò@ p€Mð ØØ$(Ø$(Ø+0×+<Ñ+<ØØ"&ØØ $Øñ#àð#ð ð#ð ˜S‘Mð	#ð
 ˜S‘Mð#ð ˜C ˜KÑ(ð#ð ð#ð ˜$‘ð#ð ð#ð ˜‘ð#ð ð#ð 
õ#ð:
 ð 
¨6÷ 
r2   rO   c                   óP   ‡ — e Zd ZdZg d¢Zd
dedee   ddfˆ fd„Zde	de	fd	„Z
ˆ xZS )ÚAmplitudeToDBaW  Turn a tensor from the power/amplitude scale to the decibel scale.

    .. devices:: CPU CUDA

    .. properties:: Autograd TorchScript

    This output depends on the maximum value in the input tensor, and so
    may return different values for an audio clip split into snippets vs. a
    a full clip.

    Args:
        stype (str, optional): scale of input tensor (``"power"`` or ``"magnitude"``). The
            power being the elementwise square of the magnitude. (Default: ``"power"``)
        top_db (float or None, optional): minimum negative cut-off in decibels.  A reasonable
            number is 80. (Default: ``None``)

    Example
        >>> waveform, sample_rate = torchaudio.load("test.wav", normalize=True)
        >>> transform = transforms.AmplitudeToDB(stype="amplitude", top_db=80)
        >>> waveform_db = transform(waveform)
    )Ú
multiplierÚaminÚ	ref_valueÚdb_multiplierNÚstypeÚtop_dbr#   c                 ó  •— t         t        | �  «        || _        |�|dk  rt	        d«      ‚|| _        |dk(  rdnd| _        d| _        d| _        t        j                  t        | j                  | j                  «      «      | _        y )Nr   ztop_db must be positive valuer   g      $@ç      4@g»½×Ùß|Û=ç      ð?)r'   r^   r(   rc   rW   rd   r_   r`   ra   ÚmathÚlog10Úmaxrb   )r/   rc   rd   r0   s      €r1   r(   zAmplitudeToDB.__init__C  st   ø€ ÜŒm˜TÑ+Ô-ØˆŒ
ØÐ &¨1¢*ÜÐ<Ó=Ð=ØˆŒØ"'¨7Ò"2™$¸ˆŒØˆŒ	ØˆŒÜ!ŸZ™Z¬¨D¯I©I°t·~±~Ó(FÓGˆÕr2   Úxc                 ó„   — t        j                  || j                  | j                  | j                  | j
                  «      S )a*  Numerically stable implementation from Librosa.

        https://librosa.org/doc/latest/generated/librosa.amplitude_to_db.html

        Args:
            x (Tensor): Input tensor before being converted to decibel scale.

        Returns:
            Tensor: Output tensor in decibel scale.
        )r5   Úamplitude_to_DBr_   r`   rb   rd   ©r/   rk   s     r1   r8   zAmplitudeToDB.forwardN  s2   € ô × Ñ   D§O¡O°T·Y±YÀ×@RÑ@RÐTX×T_ÑT_Ó`Ð`r2   )r   N)r9   r:   r;   r<   r=   rB   r   r@   r(   r   r8   rD   rE   s   @r1   r^   r^   +  sI   ø„ ñò* I€Mñ	H˜cð 	H°X¸e±_ð 	HÐPTõ 	Hða˜ð a F÷ ar2   r^   c                   óx   ‡ — e Zd ZdZg d¢Z	 	 	 	 	 	 	 ddedededee   ded	ee   d
eddfˆ fd„Z	de
de
fd„Zˆ xZS )ÚMelScaleaf  Turn a normal STFT into a mel frequency STFT with triangular filter banks.

    .. devices:: CPU CUDA

    .. properties:: Autograd TorchScript

    Args:
        n_mels (int, optional): Number of mel filterbanks. (Default: ``128``)
        sample_rate (int, optional): Sample rate of audio signal. (Default: ``16000``)
        f_min (float, optional): Minimum frequency. (Default: ``0.``)
        f_max (float or None, optional): Maximum frequency. (Default: ``sample_rate // 2``)
        n_stft (int, optional): Number of bins in STFT. See ``n_fft`` in :class:`Spectrogram`. (Default: ``201``)
        norm (str or None, optional): If ``"slaney"``, divide the triangular mel weights by the width of the mel band
            (area normalization). (Default: ``None``)
        mel_scale (str, optional): Scale to use: ``htk`` or ``slaney``. (Default: ``htk``)

    Example
        >>> waveform, sample_rate = torchaudio.load("test.wav", normalize=True)
        >>> spectrogram_transform = transforms.Spectrogram(n_fft=1024)
        >>> spectrogram = spectrogram_transform(waveform)
        >>> melscale_transform = transforms.MelScale(sample_rate=sample_rate, n_stft=1024 // 2 + 1)
        >>> melscale_spectrogram = melscale_transform(spectrogram)

    See also:
        :py:func:`torchaudio.functional.melscale_fbanks` - The function used to
        generate the filter banks.
    )Ún_melsÚsample_rateÚf_minÚf_maxNrq   rr   rs   rt   Ún_stftÚnormÚ	mel_scaler#   c           	      óØ  •— t         t        | �  «        || _        || _        |�|nt        |dz  «      | _        || _        || _        || _	        || j                  kD  r%t        dj                  || j                  «      «      ‚t        j                  || j                  | j                  | j                  | j                  | j                  | j                  «      }| j                  d|«       y )Nr%   úRequire f_min: {} <= f_max: {}Úfb)r'   rp   r(   rq   rr   r@   rt   rs   rv   rw   rW   rX   r5   Úmelscale_fbanksr,   )
r/   rq   rr   rs   rt   ru   rv   rw   rz   r0   s
            €r1   r(   zMelScale.__init__z  sÃ   ø€ ô 	Œh˜Ñ&Ô(ØˆŒØ&ˆÔØ#Ð/‘U´U¸;È!Ñ;KÓ5LˆŒ
ØˆŒ
ØˆŒ	Ø"ˆŒà�4—:‘:ÒÜÐ=×DÑDÀUÈDÏJÉJÓWÓXÐXä×Ñ˜v t§z¡z°4·:±:¸t¿{¹{ÈD×L\ÑL\Ð^b×^gÑ^gÐim×iwÑiwÓxˆØ×Ñ˜T 2Õ&r2   rY   c                 ó†   — t        j                  |j                  dd«      | j                  «      j                  dd«      }|S )zÊ
        Args:
            specgram (Tensor): A spectrogram STFT of dimension (..., freq, time).

        Returns:
            Tensor: Mel frequency spectrogram of size (..., ``n_mels``, time).
        éÿÿÿÿéþÿÿÿ)r)   ÚmatmulÚ	transposerz   )r/   rY   Úmel_specgrams      r1   r8   zMelScale.forward’  s:   € ô —|‘| H×$6Ñ$6°r¸2Ó$>ÀÇÁÓH×RÑRÐSUÐWYÓZˆàÐr2   )é€   é€>  ç        NéÉ   NÚhtk©r9   r:   r;   r<   r=   r?   r@   r   rB   r(   r   r8   rD   rE   s   @r1   rp   rp   \  s•   ø„ ñò6 @€Mð Ø ØØ!%ØØ"Øñ'àð'ð ð'ð ð	'ð
 ˜‰ð'ð ð'ð �s‰mð'ð ð'ð 
õ'ð0 ð ¨6÷ r2   rp   c                   ó|   ‡ — e Zd ZdZg d¢Z	 	 	 	 	 	 	 ddededededee   d	ee   d
ededdfˆ fd„Z	de
de
fd„Zˆ xZS )ÚInverseMelScalea�  Estimate a STFT in normal frequency domain from mel frequency domain.

    .. devices:: CPU CUDA

    It minimizes the euclidian norm between the input mel-spectrogram and the product between
    the estimated spectrogram and the filter banks using `torch.linalg.lstsq`.

    Args:
        n_stft (int): Number of bins in STFT. See ``n_fft`` in :class:`Spectrogram`.
        n_mels (int, optional): Number of mel filterbanks. (Default: ``128``)
        sample_rate (int, optional): Sample rate of audio signal. (Default: ``16000``)
        f_min (float, optional): Minimum frequency. (Default: ``0.``)
        f_max (float or None, optional): Maximum frequency. (Default: ``sample_rate // 2``)
        norm (str or None, optional): If "slaney", divide the triangular mel weights by the width of the mel band
            (area normalization). (Default: ``None``)
        mel_scale (str, optional): Scale to use: ``htk`` or ``slaney``. (Default: ``htk``)
        driver (str, optional): Name of the LAPACK/MAGMA method to be used for `torch.lstsq`.
            For CPU inputs the valid values are ``"gels"``, ``"gelsy"``, ``"gelsd"``, ``"gelss"``.
            For CUDA input, the only valid driver is ``"gels"``, which assumes that A is full-rank.
            (Default: ``"gels``)

    Example
        >>> waveform, sample_rate = torchaudio.load("test.wav", normalize=True)
        >>> mel_spectrogram_transform = transforms.MelSpectrogram(sample_rate, n_fft=1024)
        >>> mel_spectrogram = mel_spectrogram_transform(waveform)
        >>> inverse_melscale_transform = transforms.InverseMelScale(n_stft=1024 // 2 + 1)
        >>> spectrogram = inverse_melscale_transform(mel_spectrogram)
    )ru   rq   rr   rs   rt   Nru   rq   rr   rs   rt   rv   rw   Údriverr#   c	           	      óÈ  •— t         t        | �  «        || _        || _        |xs t        |dz  «      | _        || _        || _        || j                  kD  r%t        dj                  || j                  «      «      ‚|dvrt        d|› d�«      ‚t        j                  || j                  | j                  | j                  | j                  ||«      }	| j                  d|	«       y )Nr%   ry   )ÚgelsÚgelsyÚgelsdÚgelsszAdriver must be one of ["gels", "gelsy", "gelsd", "gelss"]. Found ú.rz   )r'   r‰   r(   rq   rr   r@   rt   rs   rŠ   rW   rX   r5   r{   r,   )r/   ru   rq   rr   rs   rt   rv   rw   rŠ   rz   r0   s             €r1   r(   zInverseMelScale.__init__Æ  sÏ   ø€ ô 	Œo˜tÑ-Ô/ØˆŒØ&ˆÔØÒ5œe K°1Ñ$4Ó5ˆŒ
ØˆŒ
ØˆŒà�4—:‘:ÒÜÐ=×DÑDÀUÈDÏJÉJÓWÓXÐXàÐ<Ñ<ÜÐ`ÐagÐ`hÐhiÐjÓkÐkä×Ñ˜v t§z¡z°4·:±:¸t¿{¹{ÈD×L\ÑL\Ð^bÐdmÓnˆØ×Ñ˜T 2Õ&r2   Úmelspecc                 ó  — |j                  «       }|j                  d|d   |d   «      }|d   |d   }}| j                  j                  «       \  }}| j                  |k7  r%t	        dj                  | j                  |«      «      ‚t        j                  t        j                  j                  | j                  j                  dd«      d   || j                  ¬«      j                  «      }|j                  |dd ||fz   «      }|S )zÏ
        Args:
            melspec (Tensor): A Mel frequency spectrogram of dimension (..., ``n_mels``, time)

        Returns:
            Tensor: Linear scale spectrogram of size (..., freq, time)
        r}   r~   z-Expected an input with {} mel bins. Found: {}N)rŠ   )ÚsizeÚviewrz   rq   rW   rX   r)   ÚreluÚlinalgÚlstsqr€   rŠ   Úsolution)r/   r‘   Úshaperq   ÚtimeÚfreqÚ_rY   s           r1   r8   zInverseMelScale.forwardá  sæ   € ð —‘“ˆØ—,‘,˜r 5¨¡9¨e°B©iÓ8ˆà˜R‘y %¨¡)�ˆØ—'‘'—,‘,“.‰ˆˆaØ�;‰;˜&Ò ÜÐL×SÑSÐTX×T_ÑT_ÐagÓhÓiÐiä—:‘:œeŸl™l×0Ñ0°·±×1BÑ1BÀ2ÀrÓ1JÈ4Ñ1PÐRYÐbf×bmÑbmÐ0Ón×wÑwÓxˆð —=‘=  s¨ ¨t°T¨lÑ!:Ó;ˆØˆr2   )r‚   rƒ   r„   NNr†   rŒ   r‡   rE   s   @r1   r‰   r‰   ¡  sž   ø„ ñò8€Mð Ø ØØ!%Ø"ØØñ'àð'ð ð'ð ð	'ð
 ð'ð ˜‰ð'ð �s‰mð'ð ð'ð ð'ð 
õ'ð6˜vð ¨&÷ r2   r‰   c            %       óê   ‡ — e Zd ZdZg d¢Zddddddddej                  d	d
ddddddfdededee   dee   de	dee	   dedede
def   de	dedee   dededee   dee   ded df$ˆ fd!„Zd"ed efd#„Zˆ xZS )$ÚMelSpectrograma¸
  Create MelSpectrogram for a raw audio signal.

    .. devices:: CPU CUDA

    .. properties:: Autograd TorchScript

    This is a composition of :py:func:`torchaudio.transforms.Spectrogram`
    and :py:func:`torchaudio.transforms.MelScale`.

    Sources
        * https://gist.github.com/kastnerkyle/179d6e9a88202ab0a2fe
        * https://timsainb.github.io/spectrograms-mfccs-and-inversion-in-python.html
        * http://haythamfayek.com/2016/04/21/speech-processing-for-machine-learning.html

    Args:
        sample_rate (int, optional): Sample rate of audio signal. (Default: ``16000``)
        n_fft (int, optional): Size of FFT, creates ``n_fft // 2 + 1`` bins. (Default: ``400``)
        win_length (int or None, optional): Window size. (Default: ``n_fft``)
        hop_length (int or None, optional): Length of hop between STFT windows. (Default: ``win_length // 2``)
        f_min (float, optional): Minimum frequency. (Default: ``0.``)
        f_max (float or None, optional): Maximum frequency. (Default: ``None``)
        pad (int, optional): Two sided padding of signal. (Default: ``0``)
        n_mels (int, optional): Number of mel filterbanks. (Default: ``128``)
        window_fn (Callable[..., Tensor], optional): A function to create a window tensor
            that is applied/multiplied to each frame/window. (Default: ``torch.hann_window``)
        power (float, optional): Exponent for the magnitude spectrogram,
            (must be > 0) e.g., 1 for magnitude, 2 for power, etc. (Default: ``2``)
        normalized (bool, optional): Whether to normalize by magnitude after stft. (Default: ``False``)
        wkwargs (Dict[..., ...] or None, optional): Arguments for window function. (Default: ``None``)
        center (bool, optional): whether to pad :attr:`waveform` on both sides so
            that the :math:`t`-th frame is centered at time :math:`t \times \text{hop\_length}`.
            (Default: ``True``)
        pad_mode (string, optional): controls the padding method used when
            :attr:`center` is ``True``. (Default: ``"reflect"``)
        onesided: Deprecated and unused.
        norm (str or None, optional): If "slaney", divide the triangular mel weights by the width of the mel band
            (area normalization). (Default: ``None``)
        mel_scale (str, optional): Scale to use: ``htk`` or ``slaney``. (Default: ``htk``)

    Example
        >>> waveform, sample_rate = torchaudio.load("test.wav", normalize=True)
        >>> transform = transforms.MelSpectrogram(sample_rate)
        >>> mel_specgram = transform(waveform)  # (channel, n_mels, time)

    See also:
        :py:func:`torchaudio.functional.melscale_fbanks` - The function used to
        generate the filter banks.
    )rr   r   r   r   r   rq   rs   rƒ   r   Nr„   r   r‚   r   FTr   r†   rr   r   r   r   rs   rt   r   rq   r   .r   r   r   r   r    r!   rv   rw   r#   c                 ó–  •— t         t        | �  «        t        j                  j                  d«       |�t        j                  d«       || _        || _	        |�|n|| _
        |�|n| j                  dz  | _        || _        |
| _        || _        || _        || _        || _        t%        | j                  | j                  | j                  | j                  |	| j                  | j                  |||d¬«      | _        t)        | j                  | j                  | j"                  | j                   | j                  dz  dz   ||«      | _        y )Nz$torchaudio.transforms.MelSpectrogramz\Argument 'onesided' has been deprecated and has no influence on the behavior of this module.r%   T)r   r   r   r   r   r   r   r   r   r    r!   rV   )r'   rž   r(   r)   r*   r+   r-   r.   rr   r   r   r   r   r   r   rq   rt   rs   r   r6   rp   rw   )r/   rr   r   r   r   rs   rt   r   rq   r   r   r   r   r   r    r!   rv   rw   r0   s                     €r1   r(   zMelSpectrogram.__init__,  s!  ø€ ô( 	Œn˜dÑ,Ô.Ü�‰×$Ñ$Ð%KÔLàÐÜ�M‰MØnôð 'ˆÔØˆŒ
Ø(2Ð(>™*ÀEˆŒØ(2Ð(>™*ÀDÇOÁOÐWXÑDXˆŒØˆŒØˆŒ
Ø$ˆŒØˆŒØˆŒ
ØˆŒ
Ü&Ø—*‘*Ø—‘Ø—‘Ø—‘ØØ—*‘*Ø—‘ØØØØô
ˆÔô "Ø�K‰K˜×)Ñ)¨4¯:©:°t·z±zÀ4Ç:Á:ÐQRÁ?ÐUVÑCVÐX\Ð^gó
ˆ�r2   r3   c                 óJ   — | j                  |«      }| j                  |«      }|S )zÁ
        Args:
            waveform (Tensor): Tensor of audio of dimension (..., time).

        Returns:
            Tensor: Mel frequency spectrogram of size (..., ``n_mels``, time).
        )r6   rw   )r/   r3   rY   r�   s       r1   r8   zMelSpectrogram.forwardc  s(   € ð ×#Ñ# HÓ-ˆØ—~‘~ hÓ/ˆØÐr2   )r9   r:   r;   r<   r=   r)   r>   r?   r   r@   r   r   rA   rC   rB   r(   r8   rD   rE   s   @r1   rž   rž   ù  s8  ø„ ñ/ò` c€Mð !ØØ$(Ø$(ØØ!%ØØØ+0×+<Ñ+<ØØ Ø"&ØØ!Ø#'Ø"Øñ%5
àð5
ð ð5
ð ˜S‘Mð	5
ð
 ˜S‘Mð5
ð ð5
ð ˜‰ð5
ð ð5
ð ð5
ð ˜C ˜KÑ(ð5
ð ð5
ð ð5
ð ˜$‘ð5
ð ð5
ð ð5
ð  ˜4‘.ð!5
ð" �s‰mð#5
ð$ ð%5
ð& 
õ'5
ðn
 ð 
¨6÷ 
r2   rž   c                   ól   ‡ — e Zd ZdZg d¢Z	 	 	 	 	 	 ddededededed	ee	   d
dfˆ fd„Z
ded
efd„Zˆ xZS )ÚMFCCaý  Create the Mel-frequency cepstrum coefficients from an audio signal.

    .. devices:: CPU CUDA

    .. properties:: Autograd TorchScript

    By default, this calculates the MFCC on the DB-scaled Mel spectrogram.
    This is not the textbook implementation, but is implemented here to
    give consistency with librosa.

    This output depends on the maximum value in the input spectrogram, and so
    may return different values for an audio clip split into snippets vs. a
    a full clip.

    Args:
        sample_rate (int, optional): Sample rate of audio signal. (Default: ``16000``)
        n_mfcc (int, optional): Number of mfc coefficients to retain. (Default: ``40``)
        dct_type (int, optional): type of DCT (discrete cosine transform) to use. (Default: ``2``)
        norm (str, optional): norm to use. (Default: ``"ortho"``)
        log_mels (bool, optional): whether to use log-mel spectrograms instead of db-scaled. (Default: ``False``)
        melkwargs (dict or None, optional): arguments for MelSpectrogram. (Default: ``None``)

    Example
        >>> waveform, sample_rate = torchaudio.load("test.wav", normalize=True)
        >>> transform = transforms.MFCC(
        >>>     sample_rate=sample_rate,
        >>>     n_mfcc=13,
        >>>     melkwargs={"n_fft": 400, "hop_length": 160, "n_mels": 23, "center": False},
        >>> )
        >>> mfcc = transform(waveform)

    See also:
        :py:func:`torchaudio.functional.melscale_fbanks` - The function used to
        generate the filter banks.
    )rr   Ún_mfccÚdct_typerd   Úlog_melsNrr   r£   r¤   rv   r¥   Ú	melkwargsr#   c                 ó8  •— t         t        | �  «        dg}||vrt        dj	                  |«      «      ‚|| _        || _        || _        || _        d| _	        t        d| j                  «      | _        |xs i }t        dd| j
                  i|¤Ž| _        | j                  | j                  j                  kD  rt        d«      ‚t        j                  | j                  | j                  j                  | j                  «      }| j!                  d|«       || _        y )	Nr%   úDCT type not supported: {}ç      T@r   rr   z4Cannot select more MFCC coefficients than # mel binsÚdct_mat© )r'   r¢   r(   rW   rX   rr   r£   r¤   rv   rd   r^   rm   rž   rq   r5   Ú
create_dctr,   r¥   )
r/   rr   r£   r¤   rv   r¥   r¦   Úsupported_dct_typesrª   r0   s
            €r1   r(   zMFCC.__init__–  sö   ø€ ô 	Œd�DÑ"Ô$Ø ˜cÐØÐ.Ñ.ÜÐ9×@Ñ@ÀÓJÓKÐKØ&ˆÔØˆŒØ ˆŒØˆŒ	ØˆŒÜ,¨W°d·k±kÓBˆÔà’O ˆ	Ü,ÑW¸×9IÑ9IÐWÈYÑWˆÔà�;‰;˜×,Ñ,×3Ñ3Ò3ÜÐSÓTÐTÜ—,‘,˜tŸ{™{¨D×,?Ñ,?×,FÑ,FÈÏ	É	ÓRˆØ×Ñ˜Y¨Ô0Ø ˆ�r2   r3   c                 ó  — | j                  |«      }| j                  rd}t        j                  ||z   «      }n| j	                  |«      }t        j
                  |j                  dd«      | j                  «      j                  dd«      }|S )z·
        Args:
            waveform (Tensor): Tensor of audio of dimension (..., time).

        Returns:
            Tensor: specgram_mel_db of size (..., ``n_mfcc``, time).
        ç�íµ ÷Æ°>r}   r~   )rž   r¥   r)   Úlogrm   r   r€   rª   )r/   r3   r�   Ú
log_offsetÚmfccs        r1   r8   zMFCC.forward³  sz   € ð ×*Ñ*¨8Ó4ˆØ�=Š=ØˆJÜ Ÿ9™9 \°JÑ%>Ó?‰Là×/Ñ/°Ó=ˆLô �|‰|˜L×2Ñ2°2°rÓ:¸D¿L¹LÓI×SÑSÐTVÐXZÓ[ˆØˆr2   )rƒ   é(   r%   ÚorthoFN)r9   r:   r;   r<   r=   r?   rB   rA   r   rC   r(   r   r8   rD   rE   s   @r1   r¢   r¢   p  s…   ø„ ñ"òF P€Mð !ØØØØØ$(ñ!àð!ð ð!ð ð	!ð
 ð!ð ð!ð ˜D‘>ð!ð 
õ!ð: ð ¨6÷ r2   r¢   c                   ó„   ‡ — e Zd ZdZg d¢Z	 	 	 	 	 	 	 	 	 ddedededee   ded	ed
ede	dee
   ddfˆ fd„Zdedefd„Zˆ xZS )ÚLFCCaæ  Create the linear-frequency cepstrum coefficients from an audio signal.

    .. devices:: CPU CUDA

    .. properties:: Autograd TorchScript

    By default, this calculates the LFCC on the DB-scaled linear filtered spectrogram.
    This is not the textbook implementation, but is implemented here to
    give consistency with librosa.

    This output depends on the maximum value in the input spectrogram, and so
    may return different values for an audio clip split into snippets vs. a
    a full clip.

    Args:
        sample_rate (int, optional): Sample rate of audio signal. (Default: ``16000``)
        n_filter (int, optional): Number of linear filters to apply. (Default: ``128``)
        n_lfcc (int, optional): Number of lfc coefficients to retain. (Default: ``40``)
        f_min (float, optional): Minimum frequency. (Default: ``0.``)
        f_max (float or None, optional): Maximum frequency. (Default: ``None``)
        dct_type (int, optional): type of DCT (discrete cosine transform) to use. (Default: ``2``)
        norm (str, optional): norm to use. (Default: ``"ortho"``)
        log_lf (bool, optional): whether to use log-lf spectrograms instead of db-scaled. (Default: ``False``)
        speckwargs (dict or None, optional): arguments for Spectrogram. (Default: ``None``)

    Example
        >>> waveform, sample_rate = torchaudio.load("test.wav", normalize=True)
        >>> transform = transforms.LFCC(
        >>>     sample_rate=sample_rate,
        >>>     n_lfcc=13,
        >>>     speckwargs={"n_fft": 400, "hop_length": 160, "center": False},
        >>> )
        >>> lfcc = transform(waveform)

    See also:
        :py:func:`torchaudio.functional.linear_fbanks` - The function used to
        generate the filter banks.
    )rr   Ún_filterÚn_lfccr¤   rd   Úlog_lfNrr   r·   rs   rt   r¸   r¤   rv   r¹   Ú
speckwargsr#   c
                 ó2  •— t         t        | �  «        dg}
||
vrt        dj	                  |«      «      ‚|| _        || _        |�|nt        |dz  «      | _        || _	        || _
        || _        || _        d| _        t        d| j                  «      | _        |	xs i }	t!        d
i |	¤Ž| _        | j                  | j                   j"                  kD  rt        d«      ‚t%        j&                  | j                   j"                  dz  dz   | j                  | j                  | j                  | j
                  ¬«      }| j)                  d|«       t%        j*                  | j                  | j                  | j                  «      }| j)                  d	|«       || _        y )Nr%   r¨   r©   r   z4Cannot select more LFCC coefficients than # fft binsrV   )Ún_freqsrs   rt   r·   rr   Ú
filter_matrª   r«   )r'   r¶   r(   rW   rX   rr   rs   r@   rt   r·   r¸   r¤   rv   rd   r^   rm   r   r   r5   Úlinear_fbanksr,   r¬   r¹   )r/   rr   r·   rs   rt   r¸   r¤   rv   r¹   rº   r­   r½   rª   r0   s                €r1   r(   zLFCC.__init__ð  sa  ø€ ô 	Œd�DÑ"Ô$Ø ˜cÐØÐ.Ñ.ÜÐ9×@Ñ@ÀÓJÓKÐKØ&ˆÔØˆŒ
Ø#Ð/‘U´U¸;È!Ñ;KÓ5LˆŒ
Ø ˆŒØˆŒØ ˆŒØˆŒ	ØˆŒÜ,¨W°d·k±kÓBˆÔàÒ% 2ˆ
Ü&Ñ4¨Ñ4ˆÔà�;‰;˜×)Ñ)×/Ñ/Ò/ÜÐSÓTÐTä—_‘_Ø×$Ñ$×*Ñ*¨aÑ/°!Ñ3Ø—*‘*Ø—*‘*Ø—]‘]Ø×(Ñ(ô
ˆ
ð 	×Ñ˜\¨:Ô6ä—,‘,˜tŸ{™{¨D¯M©M¸4¿9¹9ÓEˆØ×Ñ˜Y¨Ô0Øˆ�r2   r3   c                 ó˜  — | j                  |«      }t        j                  |j                  dd«      | j                  «      j                  dd«      }| j
                  rd}t        j                  ||z   «      }n| j                  |«      }t        j                  |j                  dd«      | j                  «      j                  dd«      }|S )zÎ
        Args:
            waveform (Tensor): Tensor of audio of dimension (..., time).

        Returns:
            Tensor: Linear Frequency Cepstral Coefficients of size (..., ``n_lfcc``, time).
        r}   r~   r¯   )	r   r)   r   r€   r½   r¹   r°   rm   rª   )r/   r3   rY   r±   Úlfccs        r1   r8   zLFCC.forward  s¬   € ð ×#Ñ# HÓ-ˆô —<‘< × 2Ñ 2°2°rÓ :¸D¿O¹OÓL×VÑVÐWYÐ[]Ó^ˆà�;Š;ØˆJÜ—y‘y ¨JÑ!6Ó7‰Hà×+Ñ+¨HÓ5ˆHô �|‰|˜H×.Ñ.¨r°2Ó6¸¿¹ÓE×OÑOÐPRÐTVÓWˆØˆr2   )	rƒ   r‚   r„   Nr³   r%   r´   FN)r9   r:   r;   r<   r=   r?   r@   r   rB   rA   rC   r(   r   r8   rD   rE   s   @r1   r¶   r¶   Ç  s±   ø„ ñ%òL Z€Mð !ØØØ!%ØØØØØ%)ñ+àð+ð ð+ð ð	+ð
 ˜‰ð+ð ð+ð ð+ð ð+ð ð+ð ˜T‘Nð+ð 
õ+ðZ ð ¨6÷ r2   r¶   c                   óD   ‡ — e Zd ZdZdgZddeddfˆ fd„Zdedefd„Zˆ xZ	S )	ÚMuLawEncodinga­  Encode signal based on mu-law companding.

    .. devices:: CPU CUDA

    .. properties:: TorchScript

    For more info see the
    `Wikipedia Entry <https://en.wikipedia.org/wiki/%CE%9C-law_algorithm>`_

    This algorithm assumes the signal has been scaled to between -1 and 1 and
    returns a signal encoded with values from 0 to quantization_channels - 1

    Args:
        quantization_channels (int, optional): Number of channels. (Default: ``256``)

    Example
       >>> waveform, sample_rate = torchaudio.load("test.wav", normalize=True)
       >>> transform = torchaudio.transforms.MuLawEncoding(quantization_channels=512)
       >>> mulawtrans = transform(waveform)

    Úquantization_channelsr#   Nc                 ó8   •— t         t        | �  «        || _        y rM   )r'   rÂ   r(   rÃ   ©r/   rÃ   r0   s     €r1   r(   zMuLawEncoding.__init__M  ó   ø€ ÜŒm˜TÑ+Ô-Ø%:ˆÕ"r2   rk   c                 óB   — t        j                  || j                  «      S )z€
        Args:
            x (Tensor): A signal to be encoded.

        Returns:
            Tensor: An encoded signal.
        )r5   Úmu_law_encodingrÃ   rn   s     r1   r8   zMuLawEncoding.forwardQ  s   € ô × Ñ   D×$>Ñ$>Ó?Ð?r2   ©é   ©
r9   r:   r;   r<   r=   r?   r(   r   r8   rD   rE   s   @r1   rÂ   rÂ   5  s;   ø„ ñð* -Ð-€Mñ;¨cð ;¸Dõ ;ð@˜ð @ F÷ @r2   rÂ   c                   óD   ‡ — e Zd ZdZdgZddeddfˆ fd„Zdedefd„Zˆ xZ	S )	ÚMuLawDecodingaŒ  Decode mu-law encoded signal.

    .. devices:: CPU CUDA

    .. properties:: TorchScript

    For more info see the
    `Wikipedia Entry <https://en.wikipedia.org/wiki/%CE%9C-law_algorithm>`_

    This expects an input with values between 0 and ``quantization_channels - 1``
    and returns a signal scaled between -1 and 1.

    Args:
        quantization_channels (int, optional): Number of channels. (Default: ``256``)

    Example
        >>> waveform, sample_rate = torchaudio.load("test.wav", normalize=True)
        >>> transform = torchaudio.transforms.MuLawDecoding(quantization_channels=512)
        >>> mulawtrans = transform(waveform)
    rÃ   r#   Nc                 ó8   •— t         t        | �  «        || _        y rM   )r'   rÍ   r(   rÃ   rÅ   s     €r1   r(   zMuLawDecoding.__init__s  rÆ   r2   Úx_muc                 óB   — t        j                  || j                  «      S )zŸ
        Args:
            x_mu (Tensor): A mu-law encoded signal which needs to be decoded.

        Returns:
            Tensor: The signal decoded.
        )r5   Úmu_law_decodingrÃ   )r/   rÏ   s     r1   r8   zMuLawDecoding.forwardw  s   € ô × Ñ   t×'AÑ'AÓBÐBr2   rÉ   rË   rE   s   @r1   rÍ   rÍ   \  s;   ø„ ñð( -Ð-€Mñ;¨cð ;¸Dõ ;ðC˜Fð C v÷ Cr2   rÍ   c                   óˆ   ‡ — e Zd ZdZ	 	 	 	 	 	 dddœdededededed	ee   d
eej                     ddfˆ fd„Z
dedefd„Zˆ xZS )ÚResamplea¹  Resample a signal from one frequency to another. A resampling method can be given.

    .. devices:: CPU CUDA

    .. properties:: Autograd TorchScript

    Note:
        If resampling on waveforms of higher precision than float32, there may be a small loss of precision
        because the kernel is cached once as float32. If high precision resampling is important for your application,
        the functional form will retain higher precision, but run slower because it does not cache the kernel.
        Alternatively, you could rewrite a transform that caches a higher precision kernel.

    Args:
        orig_freq (int, optional): The original frequency of the signal. (Default: ``16000``)
        new_freq (int, optional): The desired frequency. (Default: ``16000``)
        resampling_method (str, optional): The resampling method to use.
            Options: [``sinc_interp_hann``, ``sinc_interp_kaiser``] (Default: ``"sinc_interp_hann"``)
        lowpass_filter_width (int, optional): Controls the sharpness of the filter, more == sharper
            but less efficient. (Default: ``6``)
        rolloff (float, optional): The roll-off frequency of the filter, as a fraction of the Nyquist.
            Lower values reduce anti-aliasing, but also reduce some of the highest frequencies. (Default: ``0.99``)
        beta (float or None, optional): The shape parameter used for kaiser window.
        dtype (torch.device, optional):
            Determnines the precision that resampling kernel is pre-computed and cached. If not provided,
            kernel is computed with ``torch.float64`` then cached as ``torch.float32``.
            If you need higher precision, provide ``torch.float64``, and the pre-computed kernel is computed and
            cached as ``torch.float64``. If you use resample with lower precision, then instead of providing this
            providing this argument, please use ``Resample.to(dtype)``, so that the kernel generation is still
            carried out on ``torch.float64``.

    Example
        >>> waveform, sample_rate = torchaudio.load("test.wav", normalize=True)
        >>> transform = transforms.Resample(sample_rate, sample_rate/10)
        >>> waveform = transform(waveform)
    N©ÚdtypeÚ	orig_freqÚnew_freqÚresampling_methodÚlowpass_filter_widthÚrolloffÚbetarÕ   r#   c          
      óþ  •— t         ‰	| �  «        || _        || _        t	        j
                  t        | j                  «      t        | j                  «      «      | _        || _        || _        || _	        || _
        | j                  | j                  k7  rjt        | j                  | j                  | j
                  | j                  | j                  | j                  ||¬«      \  }| _        | j                  d|«       y y )NrÔ   Úkernel)r'   r(   rÖ   r×   rh   Úgcdr?   rØ   rÙ   rÚ   rÛ   r   Úwidthr,   )
r/   rÖ   r×   rØ   rÙ   rÚ   rÛ   rÕ   rÝ   r0   s
            €r1   r(   zResample.__init__§  sÌ   ø€ ô 	‰ÑÔà"ˆŒØ ˆŒÜ—8‘8œC §¡Ó/´°T·]±]Ó1CÓDˆŒØ!2ˆÔØ$8ˆÔ!ØˆŒØˆŒ	à�>‰>˜TŸ]™]Ò*Ü!:Ø—‘Ø—‘Ø—‘Ø×)Ñ)Ø—‘Ø×&Ñ&ØØô	"ÑˆF�D”Jð × Ñ  ¨6Õ2ð +r2   r3   c                 ó¼   — | j                   | j                  k(  r|S t        || j                   | j                  | j                  | j                  | j
                  «      S )z®
        Args:
            waveform (Tensor): Tensor of audio of dimension (..., time).

        Returns:
            Tensor: Output signal of dimension (..., time).
        )rÖ   r×   r   rÞ   rÝ   rß   r7   s     r1   r8   zResample.forwardÉ  sK   € ð �>‰>˜TŸ]™]Ò*ØˆOÜ*¨8°T·^±^ÀTÇ]Á]ÐTX×T\ÑT\Ð^b×^iÑ^iÐko×kuÑkuÓvÐvr2   )rƒ   rƒ   Úsinc_interp_hanné   rT   N)r9   r:   r;   r<   r?   rB   r@   r   r)   rÕ   r(   r   r8   rD   rE   s   @r1   rÓ   rÓ   ‚  sž   ø„ ñ"ðL ØØ!3Ø$%ØØ $ð 3ð (,ò 3àð 3ð ð 3ð ð	 3ð
 "ð 3ð ð 3ð �u‰oð 3ð ˜Ÿ™Ñ$ð 3ð 
õ 3ðD
w ð 
w¨6÷ 
wr2   rÓ   c                   óH   ‡ — e Zd ZdZdgZd	dededdfˆ fd„Zdedefd„Z	ˆ xZ
S )
ÚComputeDeltasa‘  Compute delta coefficients of a tensor, usually a spectrogram.

    .. devices:: CPU CUDA

    .. properties:: Autograd TorchScript

    See `torchaudio.functional.compute_deltas` for more details.

    Args:
        win_length (int, optional): The window length used for computing delta. (Default: ``5``)
        mode (str, optional): Mode parameter passed to padding. (Default: ``"replicate"``)
    r   Úmoder#   Nc                 óF   •— t         t        | �  «        || _        || _        y rM   )r'   rä   r(   r   rå   )r/   r   rå   r0   s      €r1   r(   zComputeDeltas.__init__å  s   ø€ ÜŒm˜TÑ+Ô-Ø$ˆŒØˆ�	r2   rY   c                 óZ   — t        j                  || j                  | j                  ¬«      S )z½
        Args:
            specgram (Tensor): Tensor of audio of dimension (..., freq, time).

        Returns:
            Tensor: Tensor of deltas of dimension (..., freq, time).
        )r   rå   )r5   Úcompute_deltasr   rå   r\   s     r1   r8   zComputeDeltas.forwardê  s!   € ô ×Ñ °T·_±_È4Ï9É9ÔUÐUr2   )é   Ú	replicate)r9   r:   r;   r<   r=   r?   rB   r(   r   r8   rD   rE   s   @r1   rä   rä   Ö  sA   ø„ ñð "�N€Mñ 3ð °#ð Èõ ð
V ð V¨6÷ Vr2   rä   c            	       ód   ‡ — e Zd ZdZdgZddee   dedee   ddfˆ fd„Zdde	d	ee   de	fd
„Z
ˆ xZS )ÚTimeStretchaœ  Stretch stft in time without modifying pitch for a given rate.

    .. devices:: CPU CUDA

    .. properties:: Autograd TorchScript

    Proposed in *SpecAugment* :cite:`specaugment`.

    Args:
        hop_length (int or None, optional): Length of hop between STFT windows.
            (Default: ``n_fft // 2``, where ``n_fft == (n_freq - 1) * 2``)
        n_freq (int, optional): number of filter banks from stft. (Default: ``201``)
        fixed_rate (float or None, optional): rate to speed up or slow down by.
            If None is provided, rate must be passed to the forward method. (Default: ``None``)

    .. note::

       The expected input is raw, complex-valued spectrogram.

    Example
        >>> spectrogram = torchaudio.transforms.Spectrogram(power=None)
        >>> stretch = torchaudio.transforms.TimeStretch()
        >>>
        >>> original = spectrogram(waveform)
        >>> stretched_1_2 = stretch(original, 1.2)
        >>> stretched_0_9 = stretch(original, 0.9)

        .. image:: https://download.pytorch.org/torchaudio/doc-assets/specaugment_time_stretch.png
           :width: 600
           :alt: The visualization of stretched spectrograms.
    Ú
fixed_rateNr   Ún_freqr#   c                 óÐ   •— t         t        | �  «        || _        |dz
  dz  }|�|n|dz  }| j	                  dt        j                  dt        j                  |z  |«      d   «       y )NrV   r%   Úphase_advancer   ).N)	r'   rì   r(   rí   r,   r)   Úlinspacerh   Úpi)r/   r   rî   rí   r   r0   s        €r1   r(   zTimeStretch.__init__  sb   ø€ ÜŒk˜4Ñ)Ô+à$ˆŒà˜!‘˜qÑ ˆØ#-Ð#9‘Z¸uÈ¹zˆ
Ø×Ñ˜_¬e¯n©n¸QÄÇÁÈ*Ñ@TÐV\Ó.]Ð^gÑ.hÕir2   Úcomplex_specgramsÚoverriding_ratec                 óì   — t        j                  |«      st        j                  dd¬«       |€$| j                  €t        d«      ‚| j                  }n|}t        j                  ||| j                  «      S )a2  
        Args:
            complex_specgrams (Tensor):
                A tensor of dimension `(..., freq, num_frame)` with complex dtype.
            overriding_rate (float or None, optional): speed up to apply to this batch.
                If no rate is passed, use ``self.fixed_rate``. (Default: ``None``)

        Returns:
            Tensor:
                Stretched spectrogram. The resulting tensor is of the corresponding complex dtype
                as the input spectrogram, and the number of frames is changed to ``ceil(num_frame / rate)``.
        zeThe input to TimeStretch must be complex type. Providing non-complex tensor produces invalid results.é   )Ú
stacklevelzLIf no fixed_rate is specified, must pass a valid rate to the forward method.)	r)   Ú
is_complexr-   r.   rí   rW   r5   Úphase_vocoderrð   )r/   ró   rô   Úrates       r1   r8   zTimeStretch.forward   sn   € ô ×ÑÐ 1Ô2Ü�M‰MðIàõð Ð"Ø�‰Ð&Ü Ð!oÓpÐpØ—?‘?‰Dà"ˆDÜ�‰Ð0°$¸×8JÑ8JÓKÐKr2   )Nr…   NrM   )r9   r:   r;   r<   r=   r   r?   r@   r(   r   r8   rD   rE   s   @r1   rì   rì   õ  sf   ø„ ñð> "�N€Mñj 8¨C¡=ð jÀð jÐX`ÐafÑXgð jÐswõ jñL¨ð LÀ(È5Á/ð LÐ]c÷ Lr2   rì   c            	       ó–   ‡ — e Zd ZdZddedededdfˆ fd„Zdedefd	„Zd
ede	j                  defd„Zd
ede	j                  defd„Zˆ xZS )ÚFadeaü  Add a fade in and/or fade out to an waveform.

    .. devices:: CPU CUDA

    .. properties:: Autograd TorchScript

    Args:
        fade_in_len (int, optional): Length of fade-in (time frames). (Default: ``0``)
        fade_out_len (int, optional): Length of fade-out (time frames). (Default: ``0``)
        fade_shape (str, optional): Shape of fade. Must be one of: "quarter_sine",
            ``"half_sine"``, ``"linear"``, ``"logarithmic"``, ``"exponential"``.
            (Default: ``"linear"``)

    Example
        >>> waveform, sample_rate = torchaudio.load("test.wav", normalize=True)
        >>> transform = transforms.Fade(fade_in_len=sample_rate, fade_out_len=2 * sample_rate, fade_shape="linear")
        >>> faded_waveform = transform(waveform)
    Úfade_in_lenÚfade_out_lenÚ
fade_shaper#   Nc                 óT   •— t         t        | �  «        || _        || _        || _        y rM   )r'   rü   r(   rý   rþ   rÿ   )r/   rý   rþ   rÿ   r0   s       €r1   r(   zFade.__init__Q  s'   ø€ ÜŒd�DÑ"Ô$Ø&ˆÔØ(ˆÔØ$ˆ�r2   r3   c                 ó�   — |j                  «       d   }|j                  }| j                  ||«      | j                  ||«      z  |z  S )ú´
        Args:
            waveform (Tensor): Tensor of audio of dimension `(..., time)`.

        Returns:
            Tensor: Tensor of audio of dimension `(..., time)`.
        r}   )r“   ÚdeviceÚ_fade_inÚ	_fade_out)r/   r3   Úwaveform_lengthr  s       r1   r8   zFade.forwardW  sE   € ð #Ÿ-™-›/¨"Ñ-ˆØ—‘ˆØ�}‰}˜_¨fÓ5¸¿¹ÀÐX^Ó8_Ñ_ÐbjÑjÐjr2   r  r  c                 ó¸  — t        j                  dd| j                  |¬«      }t        j                  || j                  z
  |¬«      }| j                  dk(  r|}| j                  dk(  rt        j
                  d|dz
  «      |z  }| j                  dk(  rt        j                  d|z   «      dz   }| j                  d	k(  r)t        j                  |t        j                  z  dz  «      }| j                  d
k(  r@t        j                  |t        j                  z  t        j                  dz  z
  «      dz  dz   }t        j                  ||f«      j                  dd«      S )Nr   rV   ©r  ÚlinearÚexponentialr%   Úlogarithmicçš™™™™™¹?Úquarter_sineÚ	half_sineç      à?)r)   rñ   rý   Úonesrÿ   Úpowri   Úsinrh   rò   ÚcatÚclamp_©r/   r  r  Úfader  s        r1   r  zFade._fade_inc  s  € Ü�~‰~˜a  D×$4Ñ$4¸VÔDˆÜ�z‰z˜/¨D×,<Ñ,<Ñ<ÀVÔLˆà�?‰?˜hÒ&ØˆDà�?‰?˜mÒ+Ü—9‘9˜Q ¨¡Ó+¨dÑ2ˆDà�?‰?˜mÒ+Ü—;‘;˜s T™zÓ*¨QÑ.ˆDà�?‰?˜nÒ,Ü—9‘9˜T¤D§G¡G™^¨aÑ/Ó0ˆDà�?‰?˜kÒ)Ü—9‘9˜T¤D§G¡G™^¬d¯g©g¸©kÑ9Ó:¸QÑ>ÀÑDˆDä�y‰y˜$ ˜Ó&×-Ñ-¨a°Ó3Ð3r2   c                 óê  — t        j                  dd| j                  |¬«      }t        j                  || j                  z
  |¬«      }| j                  dk(  r| dz   }| j                  dk(  rt        j
                  d| «      d|z
  z  }| j                  dk(  rt        j                  d|z
  «      dz   }| j                  d	k(  r=t        j                  |t        j                  z  dz  t        j                  dz  z   «      }| j                  d
k(  r@t        j                  |t        j                  z  t        j                  dz  z   «      dz  dz   }t        j                  ||f«      j                  dd«      S )Nr   rV   r  r	  r
  r%   r  gš™™™™™ñ?r  r  r  )r)   rñ   rþ   r  rÿ   r  ri   r  rh   rò   r  r  r  s        r1   r  zFade._fade_outx  s%  € Ü�~‰~˜a  D×$5Ñ$5¸fÔEˆÜ�z‰z˜/¨D×,=Ñ,=Ñ=ÀfÔMˆà�?‰?˜hÒ&Ø�5˜1‘9ˆDà�?‰?˜mÒ+Ü—9‘9˜Q  Ó&¨!¨d©(Ñ3ˆDà�?‰?˜mÒ+Ü—;‘;˜s T™zÓ*¨QÑ.ˆDà�?‰?˜nÒ,Ü—9‘9˜T¤D§G¡G™^¨aÑ/´$·'±'¸A±+Ñ=Ó>ˆDà�?‰?˜kÒ)Ü—9‘9˜T¤D§G¡G™^¬d¯g©g¸©kÑ9Ó:¸QÑ>ÀÑDˆDä�y‰y˜$ ˜Ó&×-Ñ-¨a°Ó3Ð3r2   )r   r   r	  )r9   r:   r;   r<   r?   rB   r(   r   r8   r)   r  r  r  rD   rE   s   @r1   rü   rü   =  s}   ø„ ññ&% Cð %¸3ð %ÐPSð %Ðcgõ %ð
k ð 
k¨6ó 
kð4¨ð 4°U·\±\ð 4Àfó 4ð*4¨ð 4°e·l±lð 4Àv÷ 4r2   rü   c                   óX   ‡ — e Zd ZdZg d¢Zddededededdf
ˆ fd	„Zdd
e	dede	fd„Z
ˆ xZS )Ú_AxisMaskinga/  Apply masking to a spectrogram.

    Args:
        mask_param (int): Maximum possible length of the mask.
        axis (int): What dimension the mask is applied on (assuming the tensor is 3D).
            For frequency masking, axis = 1.
            For time masking, axis = 2.
        iid_masks (bool): Applies iid masks to each of the examples in the batch dimension.
            This option is applicable only when the dimension of the input tensor is >= 3.
        p (float, optional): maximum proportion of columns that can be masked. (Default: 1.0)
    )Ú
mask_paramÚaxisÚ	iid_masksÚpr  r  r  r  r#   Nc                 ób   •— t         t        | �  «        || _        || _        || _        || _        y rM   )r'   r  r(   r  r  r  r  )r/   r  r  r  r  r0   s        €r1   r(   z_AxisMasking.__init__œ  s,   ø€ ÜŒl˜DÑ*Ô,Ø$ˆŒØˆŒ	Ø"ˆŒØˆ�r2   rY   Ú
mask_valuec                 óJ  — | j                   rLt        j                  || j                  || j                  |j                  «       z   dz
  | j                  ¬«      S t        j                  || j                  || j                  |j                  «       z   dz
  | j                  ¬«      S )a  
        Args:
            specgram (Tensor): Tensor of dimension `(..., freq, time)`.
            mask_value (float): Value to assign to the masked columns.

        Returns:
            Tensor: Masked spectrogram of dimensions `(..., freq, time)`.
        é   ©r  )r  r5   Úmask_along_axis_iidr  r  Údimr  Úmask_along_axis)r/   rY   r  s      r1   r8   z_AxisMasking.forward£  sˆ   € ð �>Š>Ü×(Ñ(Ø˜$Ÿ/™/¨:°t·y±yÀ8Ç<Á<Ã>Ñ7QÐTUÑ7UÐY]×Y_ÑY_ôð ô ×$Ñ$ X¨t¯©À
ÈDÏIÉIÐX`×XdÑXdÓXfÑLfÐijÑLjÐnr×ntÑntÔuÐur2   )rg   )r„   ©r9   r:   r;   r<   r=   r?   rA   r@   r(   r   r8   rD   rE   s   @r1   r  r  Ž  sV   ø„ ñ
ò =€Mñ 3ð ¨cð ¸dð Àuð ÐW[õ ñv ð v°Eð vÀF÷ vr2   r  c                   ó2   ‡ — e Zd ZdZddededdfˆ fd„Zˆ xZS )ÚFrequencyMaskingaH  Apply masking to a spectrogram in the frequency domain.

    .. devices:: CPU CUDA

    .. properties:: Autograd TorchScript

    Proposed in *SpecAugment* :cite:`specaugment`.

    Args:
        freq_mask_param (int): maximum possible length of the mask.
            Indices uniformly sampled from [0, freq_mask_param).
        iid_masks (bool, optional): whether to apply different masks to each
            example/channel in the batch. (Default: ``False``)
            This option is applicable only when the input tensor >= 3D.

    Example
        >>> spectrogram = torchaudio.transforms.Spectrogram()
        >>> masking = torchaudio.transforms.FrequencyMasking(freq_mask_param=80)
        >>>
        >>> original = spectrogram(waveform)
        >>> masked = masking(original)

        .. image::  https://download.pytorch.org/torchaudio/doc-assets/specaugment_freq_masking1.png
           :alt: The original spectrogram

        .. image::  https://download.pytorch.org/torchaudio/doc-assets/specaugment_freq_masking2.png
           :alt: The spectrogram masked along frequency axis
    Úfreq_mask_paramr  r#   Nc                 ó0   •— t         t        | �  |d|«       y )NrV   )r'   r(  r(   )r/   r)  r  r0   s      €r1   r(   zFrequencyMasking.__init__Õ  s   ø€ ÜÔ Ñ.¨ÀÀ9ÕMr2   )F)r9   r:   r;   r<   r?   rA   r(   rD   rE   s   @r1   r(  r(  ·  s,   ø„ ññ:N¨ð N¸ð NÈ÷ Nñ Nr2   r(  c            	       ó6   ‡ — e Zd ZdZddedededdfˆ fd„Zˆ xZS )	ÚTimeMaskingaÇ  Apply masking to a spectrogram in the time domain.

    .. devices:: CPU CUDA

    .. properties:: Autograd TorchScript

    Proposed in *SpecAugment* :cite:`specaugment`.

    Args:
        time_mask_param (int): maximum possible length of the mask.
            Indices uniformly sampled from [0, time_mask_param).
        iid_masks (bool, optional): whether to apply different masks to each
            example/channel in the batch. (Default: ``False``)
            This option is applicable only when the input tensor >= 3D.
        p (float, optional): maximum proportion of time steps that can be masked.
            Must be within range [0.0, 1.0]. (Default: 1.0)

    Example
        >>> spectrogram = torchaudio.transforms.Spectrogram()
        >>> masking = torchaudio.transforms.TimeMasking(time_mask_param=80)
        >>>
        >>> original = spectrogram(waveform)
        >>> masked = masking(original)

        .. image::  https://download.pytorch.org/torchaudio/doc-assets/specaugment_time_masking1.png
           :alt: The original spectrogram

        .. image::  https://download.pytorch.org/torchaudio/doc-assets/specaugment_time_masking2.png
           :alt: The spectrogram masked along time axis
    Útime_mask_paramr  r  r#   Nc                 ól   •— d|cxk  rdk  sn t        d|› d�«      ‚t        t        | �  |d||¬«       y )Nr„   rg   z,The value of p must be between 0.0 and 1.0 (z given).r%   r"  )rW   r'   r,  r(   )r/   r-  r  r  r0   s       €r1   r(   zTimeMasking.__init__ù  s;   ø€ Ø�aŒ˜3ŒÜÐKÈAÈ3ÈhÐWÓXÐXÜŒk˜4Ñ)¨/¸1¸iÈ1Ð)ÕMr2   )Frg   )	r9   r:   r;   r<   r?   rA   r@   r(   rD   rE   s   @r1   r,  r,  Ù  s5   ø„ ññ>N¨ð N¸ð NÈð NÐY]÷ Nñ Nr2   r,  c                   ód   ‡ — e Zd ZdZg d¢Z	 	 	 ddedededededed	ed
dfˆ fd„Zde	d
e	fd„Z
ˆ xZS )ÚSpecAugmenta•  Apply time and frequency masking to a spectrogram.
    Args:
        n_time_masks (int): Number of time masks. If its value is zero, no time masking will be applied.
        time_mask_param (int): Maximum possible length of the time mask.
        n_freq_masks (int): Number of frequency masks. If its value is zero, no frequency masking will be applied.
        freq_mask_param (int): Maximum possible length of the frequency mask.
        iid_masks (bool, optional): Applies iid masks to each of the examples in the batch dimension.
            This option is applicable only when the input tensor is 4D. (Default: ``True``)
        p (float, optional): maximum proportion of time steps that can be masked.
            Must be within range [0.0, 1.0]. (Default: 1.0)
        zero_masking (bool, optional): If ``True``, use 0 as the mask value,
            else use mean of the input tensor. (Default: ``False``)
    )Ún_time_masksr-  Ún_freq_masksr)  r  r  Úzero_maskingr1  r-  r2  r)  r  r  r3  r#   Nc                 óŒ   •— t         t        | �  «        || _        || _        || _        || _        || _        || _        || _	        y rM   )
r'   r0  r(   r1  r-  r2  r)  r  r  r3  )	r/   r1  r-  r2  r)  r  r  r3  r0   s	           €r1   r(   zSpecAugment.__init__  sH   ø€ ô 	Œk˜4Ñ)Ô+Ø(ˆÔØ.ˆÔØ(ˆÔØ.ˆÔØ"ˆŒØˆŒØ(ˆÕr2   rY   c                 óú  — | j                   rd}n|j                  «       }|j                  «       dz
  }|dz
  }|j                  «       dkD  r | j                  du r’t	        | j
                  «      D ]0  }t        j                  || j                  ||| j                  ¬«      }Œ2 t	        | j                  «      D ]0  }t        j                  || j                  ||| j                  ¬«      }Œ2 |S t	        | j
                  «      D ]0  }t        j                  || j                  ||| j                  ¬«      }Œ2 t	        | j                  «      D ]0  }t        j                  || j                  ||| j                  ¬«      }Œ2 |S )z±
        Args:
            specgram (Tensor): Tensor of shape `(..., freq, time)`.
        Returns:
            Tensor: Masked spectrogram of shape `(..., freq, time)`.
        r„   rV   r%   Tr"  )r3  Úmeanr$  r  Úranger1  r5   r#  r-  r  r2  r)  r%  )r/   rY   r  Útime_dimÚfreq_dimrœ   s         r1   r8   zSpecAugment.forward*  si  € ð ×ÒØ‰Jà!Ÿ™›ˆJØ—<‘<“> AÑ%ˆØ˜a‘<ˆà�<‰<‹>˜AÒ $§.¡.°DÑ"8Ü˜4×,Ñ,Ó-ò q�Ü×0Ñ0°¸4×;OÑ;OÐQ[Ð]eÐim×ioÑioÔp‘ðqä˜4×,Ñ,Ó-ò q�Ü×0Ñ0°¸4×;OÑ;OÐQ[Ð]eÐim×ioÑioÔp‘ðqð ˆô ˜4×,Ñ,Ó-ò m�Ü×,Ñ,¨X°t×7KÑ7KÈZÐYaÐei×ekÑekÔl‘ðmä˜4×,Ñ,Ó-ò m�Ü×,Ñ,¨X°t×7KÑ7KÈZÐYaÐei×ekÑekÔl‘ðmð ˆr2   )Trg   Fr&  rE   s   @r1   r0  r0  ÿ  s€   ø„ ñò€Mð  ØØ"ñ)àð)ð ð)ð ð	)ð
 ð)ð ð)ð ð)ð ð)ð 
õ)ð& ð ¨6÷ r2   r0  c                   ó:   ‡ — e Zd ZdZdgZdefˆ fd„Zdefd„Zˆ xZ	S )ÚLoudnessaÚ  Measure audio loudness according to the ITU-R BS.1770-4 recommendation.

    .. devices:: CPU CUDA

    .. properties:: TorchScript

    Args:
        sample_rate (int): Sample rate of audio signal.

    Example
        >>> waveform, sample_rate = torchaudio.load("test.wav", normalize=True)
        >>> transform = transforms.Loudness(sample_rate)
        >>> loudness = transform(waveform)

    Reference:
        - https://www.itu.int/rec/R-REC-BS.1770-4-201510-I/en
    rr   c                 ó8   •— t         t        | �  «        || _        y rM   )r'   r;  r(   rr   )r/   rr   r0   s     €r1   r(   zLoudness.__init__Z  s   ø€ ÜŒh˜Ñ&Ô(Ø&ˆÕr2   Úwavefromc                 óB   — t        j                  || j                  «      S )z¯
        Args:
            waveform(torch.Tensor): audio waveform of dimension `(..., channels, time)`

        Returns:
            Tensor: loudness estimates (LKFS)
        )r5   Úloudnessrr   )r/   r=  s     r1   r8   zLoudness.forward^  s   € ô �z‰z˜( D×$4Ñ$4Ó5Ð5r2   rË   rE   s   @r1   r;  r;  F  s)   ø„ ñð" #�O€Mð' Cõ 'ð6 ÷ 6r2   r;  c                   ó>   ‡ — e Zd ZdZddedefˆ fd„Zdedefd„Zˆ xZ	S )	ÚVolaå  Adjust volume of waveform.

    .. devices:: CPU CUDA

    .. properties:: Autograd TorchScript

    Args:
        gain (float): Interpreted according to the given gain_type:
            If ``gain_type`` = ``amplitude``, ``gain`` is a positive amplitude ratio.
            If ``gain_type`` = ``power``, ``gain`` is a power (voltage squared).
            If ``gain_type`` = ``db``, ``gain`` is in decibels.
        gain_type (str, optional): Type of gain. One of: ``amplitude``, ``power``, ``db`` (Default: ``amplitude``)

    Example
        >>> waveform, sample_rate = torchaudio.load("test.wav", normalize=True)
        >>> transform = transforms.Vol(gain=0.5, gain_type="amplitude")
        >>> quieter_waveform = transform(waveform)
    ÚgainÚ	gain_typec                 óp   •— t         t        | �  «        || _        || _        |dv r|dk  rt        d«      ‚y y )N)Ú	amplituder   r   z9If gain_type = amplitude or power, gain must be positive.)r'   rA  r(   rB  rC  rW   )r/   rB  rC  r0   s      €r1   r(   zVol.__init__}  sA   ø€ ÜŒc�4Ñ!Ô#ØˆŒ	Ø"ˆŒàÐ.Ñ.°4¸!²8ÜÐXÓYÐYð 4<Ð.r2   r3   r#   c                 óT  — | j                   dk(  r|| j                  z  }| j                   dk(  r t        j                  || j                  «      }| j                   dk(  r6t        j                  |dt        j                  | j                  «      z  «      }t        j                  |dd«      S )r  rE  Údbr   é
   r}   rV   )rC  rB  r5   rh   ri   r)   Úclampr7   s     r1   r8   zVol.forward…  s   € ð �>‰>˜[Ò(Ø $§)¡)Ñ+ˆHà�>‰>˜TÒ!Ü—v‘v˜h¨¯	©	Ó2ˆHà�>‰>˜WÒ$Ü—v‘v˜h¨¬T¯Z©Z¸¿	¹	Ó-BÑ(BÓCˆHä�{‰{˜8 R¨Ó+Ð+r2   )rE  )
r9   r:   r;   r<   r@   rB   r(   r   r8   rD   rE   s   @r1   rA  rA  i  s1   ø„ ññ&Z˜Uð Z¨sõ Zð, ð ,¨6÷ ,r2   rA  c                   óL   ‡ — e Zd ZdZ	 ddededededdf
ˆ fd„Zd	edefd
„Zˆ xZ	S )ÚSlidingWindowCmnaë  
    Apply sliding-window cepstral mean (and optionally variance) normalization per utterance.

    .. devices:: CPU CUDA

    .. properties:: Autograd TorchScript

    Args:
        cmn_window (int, optional): Window in frames for running average CMN computation (int, default = 600)
        min_cmn_window (int, optional):  Minimum CMN window used at start of decoding (adds latency only at start).
            Only applicable if center == false, ignored if center==true (int, default = 100)
        center (bool, optional): If true, use a window centered on the current frame
            (to the extent possible, modulo end effects). If false, window is to the left. (bool, default = false)
        norm_vars (bool, optional): If true, normalize variance to one. (bool, default = false)

    Example
        >>> waveform, sample_rate = torchaudio.load("test.wav", normalize=True)
        >>> transform = transforms.SlidingWindowCmn(cmn_window=1000)
        >>> cmn_waveform = transform(waveform)
    Ú
cmn_windowÚmin_cmn_windowr   Ú	norm_varsr#   Nc                 óZ   •— t         ‰| �  «        || _        || _        || _        || _        y rM   )r'   r(   rL  rM  r   rN  )r/   rL  rM  r   rN  r0   s        €r1   r(   zSlidingWindowCmn.__init__¯  s-   ø€ ô 	‰ÑÔØ$ˆŒØ,ˆÔØˆŒØ"ˆ�r2   rY   c                 óˆ   — t        j                  || j                  | j                  | j                  | j
                  «      }|S )zÌ
        Args:
            specgram (Tensor): Tensor of spectrogram of dimension `(..., time, freq)`.

        Returns:
            Tensor: Tensor of spectrogram of dimension `(..., time, freq)`.
        )r5   Úsliding_window_cmnrL  rM  r   rN  )r/   rY   Úcmn_specgrams      r1   r8   zSlidingWindowCmn.forward¸  s:   € ô ×+Ñ+¨H°d·o±oÀt×GZÑGZÐ\`×\gÑ\gÐim×iwÑiwÓxˆØÐr2   )iX  éd   FF)
r9   r:   r;   r<   r?   rA   r(   r   r8   rD   rE   s   @r1   rK  rK  ™  sO   ø„ ñð, inñ#Øð#Ø58ð#ØHLð#Øaeð#à	õ#ð	 ð 	¨6÷ 	r2   rK  c            %       ó¤   ‡ — e Zd ZdZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddedededededed	ed
ededededee   dedededededdf$ˆ fd„Zdedefd„Z	ˆ xZ
S )ÚVadu  Voice Activity Detector. Similar to SoX implementation.

    .. devices:: CPU CUDA

    .. properties:: TorchScript

    Attempts to trim silence and quiet background sounds from the ends of recordings of speech.
    The algorithm currently uses a simple cepstral power measurement to detect voice,
    so may be fooled by other things, especially music.

    The effect can trim only from the front of the audio,
    so in order to trim from the back, the reverse effect must also be used.

    Args:
        sample_rate (int): Sample rate of audio signal.
        trigger_level (float, optional): The measurement level used to trigger activity detection.
            This may need to be changed depending on the noise level, signal level,
            and other characteristics of the input audio. (Default: 7.0)
        trigger_time (float, optional): The time constant (in seconds)
            used to help ignore short bursts of sound. (Default: 0.25)
        search_time (float, optional): The amount of audio (in seconds)
            to search for quieter/shorter bursts of audio to include prior
            to the detected trigger point. (Default: 1.0)
        allowed_gap (float, optional): The allowed gap (in seconds) between
            quiteter/shorter bursts of audio to include prior
            to the detected trigger point. (Default: 0.25)
        pre_trigger_time (float, optional): The amount of audio (in seconds) to preserve
            before the trigger point and any found quieter/shorter bursts. (Default: 0.0)
        boot_time (float, optional) The algorithm (internally) uses adaptive noise
            estimation/reduction in order to detect the start of the wanted audio.
            This option sets the time for the initial noise estimate. (Default: 0.35)
        noise_up_time (float, optional) Time constant used by the adaptive noise estimator
            for when the noise level is increasing. (Default: 0.1)
        noise_down_time (float, optional) Time constant used by the adaptive noise estimator
            for when the noise level is decreasing. (Default: 0.01)
        noise_reduction_amount (float, optional) Amount of noise reduction to use in
            the detection algorithm (e.g. 0, 0.5, ...). (Default: 1.35)
        measure_freq (float, optional) Frequency of the algorithmâ€™s
            processing/measurements. (Default: 20.0)
        measure_duration: (float or None, optional) Measurement duration.
            (Default: Twice the measurement period; i.e. with overlap.)
        measure_smooth_time (float, optional) Time constant used to smooth
            spectral measurements. (Default: 0.4)
        hp_filter_freq (float, optional) "Brick-wall" frequency of high-pass filter applied
            at the input to the detector algorithm. (Default: 50.0)
        lp_filter_freq (float, optional) "Brick-wall" frequency of low-pass filter applied
            at the input to the detector algorithm. (Default: 6000.0)
        hp_lifter_freq (float, optional) "Brick-wall" frequency of high-pass lifter used
            in the detector algorithm. (Default: 150.0)
        lp_lifter_freq (float, optional) "Brick-wall" frequency of low-pass lifter used
            in the detector algorithm. (Default: 2000.0)

    Example
        >>> waveform, sample_rate = torchaudio.load("test.wav", normalize=True)
        >>> waveform_reversed, sample_rate = apply_effects_tensor(waveform, sample_rate, [["reverse"]])
        >>> transform = transforms.Vad(sample_rate=sample_rate, trigger_level=7.5)
        >>> waveform_reversed_front_trim = transform(waveform_reversed)
        >>> waveform_end_trim, sample_rate = apply_effects_tensor(
        >>>     waveform_reversed_front_trim, sample_rate, [["reverse"]]
        >>> )

    Reference:
        - http://sox.sourceforge.net/sox.html
    Nrr   Útrigger_levelÚtrigger_timeÚsearch_timeÚallowed_gapÚpre_trigger_timeÚ	boot_timeÚnoise_up_timeÚnoise_down_timeÚnoise_reduction_amountÚmeasure_freqÚmeasure_durationÚmeasure_smooth_timeÚhp_filter_freqÚlp_filter_freqÚhp_lifter_freqÚlp_lifter_freqr#   c                 ó  •— t         ‰| �  «        || _        || _        || _        || _        || _        || _        || _        || _	        |	| _
        |
| _        || _        || _        || _        || _        || _        || _        || _        y rM   )r'   r(   rr   rV  rW  rX  rY  rZ  r[  r\  r]  r^  r_  r`  ra  rb  rc  rd  re  )r/   rr   rV  rW  rX  rY  rZ  r[  r\  r]  r^  r_  r`  ra  rb  rc  rd  re  r0   s                     €r1   r(   zVad.__init__  s—   ø€ ô( 	‰ÑÔà&ˆÔØ*ˆÔØ(ˆÔØ&ˆÔØ&ˆÔØ 0ˆÔØ"ˆŒØ*ˆÔØ.ˆÔØ&<ˆÔ#Ø(ˆÔØ 0ˆÔØ#6ˆÔ Ø,ˆÔØ,ˆÔØ,ˆÔØ,ˆÕr2   r3   c                 óè  — t        j                  di d|“d| j                  “d| j                  “d| j                  “d| j
                  “d| j                  “d| j                  “d| j                  “d	| j                  “d
| j                  “d| j                  “d| j                  “d| j                  “d| j                  “d| j                  “d| j                   “d| j"                  “d| j$                  “ŽS )aW  
        Args:
            waveform (Tensor): Tensor of audio of dimension `(channels, time)` or `(time)`
                Tensor of shape `(channels, time)` is treated as a multi-channel recording
                of the same event and the resulting output will be trimmed to the earliest
                voice activity in any channel.
        r3   rr   rV  rW  rX  rY  rZ  r[  r\  r]  r^  r_  r`  ra  rb  rc  rd  re  r«   )r5   Úvadrr   rV  rW  rX  rY  rZ  r[  r\  r]  r^  r_  r`  ra  rb  rc  rd  re  r7   s     r1   r8   zVad.forward.  s)  € ô �u‰uò 
Ùð
à×(Ò(ð
ð ×,Ò,ð
ð ×*Ò*ð	
ð
 ×(Ò(ð
ð ×(Ò(ð
ð "×2Ò2ð
ð —n’nð
ð ×,Ò,ð
ð !×0Ò0ð
ð $(×#>Ò#>ð
ð ×*Ò*ð
ð "×2Ò2ð
ð !%× 8Ò 8ð
ð  ×.Ò.ð
ð   ×.Ò.ð!
ð"  ×.Ò.ð#
ð$  ×.Ò.ð%
ð 	
r2   )g      @ç      Ð?rg   ri  r„   gffffffÖ?r  g{®Gáz„?gš™™™™™õ?rf   Ngš™™™™™Ù?g      I@g     p·@g     Àb@g     @Ÿ@)r9   r:   r;   r<   r?   r@   r   r(   r   r8   rD   rE   s   @r1   rU  rU  Ä  s
  ø„ ñ?ðH  #Ø"Ø Ø!Ø"%ØØ"Ø!%Ø(,Ø"Ø,0Ø%(Ø $Ø &Ø %Ø &ñ%&-àð&-ð ð&-ð ð	&-ð
 ð&-ð ð&-ð  ð&-ð ð&-ð ð&-ð ð&-ð !&ð&-ð ð&-ð # 5™/ð&-ð #ð&-ð ð&-ð  ð!&-ð" ð#&-ð$ ð%&-ð& 
õ'&-ðP
 ð 
¨6÷ 
r2   rU  c                   óš   ‡ — e Zd ZdZg d¢Zddddej                  dfdededee   d	ee   d
ede	de
f   dee   ddfˆ fd„Zde
de
fd„Zˆ xZS )ÚSpectralCentroidaª  Compute the spectral centroid for each channel along the time axis.

    .. devices:: CPU CUDA

    .. properties:: Autograd TorchScript

    The spectral centroid is defined as the weighted average of the
    frequency values, weighted by their magnitude.

    Args:
        sample_rate (int): Sample rate of audio signal.
        n_fft (int, optional): Size of FFT, creates ``n_fft // 2 + 1`` bins. (Default: ``400``)
        win_length (int or None, optional): Window size. (Default: ``n_fft``)
        hop_length (int or None, optional): Length of hop between STFT windows. (Default: ``win_length // 2``)
        pad (int, optional): Two sided padding of signal. (Default: ``0``)
        window_fn (Callable[..., Tensor], optional): A function to create a window tensor
            that is applied/multiplied to each frame/window. (Default: ``torch.hann_window``)
        wkwargs (dict or None, optional): Arguments for window function. (Default: ``None``)

    Example
        >>> waveform, sample_rate = torchaudio.load("test.wav", normalize=True)
        >>> transform = transforms.SpectralCentroid(sample_rate)
        >>> spectral_centroid = transform(waveform)  # (channel, time)
    )rr   r   r   r   r   r   Nr   rr   r   r   r   r   r   .r   r#   c                 ó  •— t         t        | �  «        || _        || _        |�|n|| _        |�|n| j
                  dz  | _        |€ || j
                  «      n || j
                  fi |¤Ž}| j                  d|«       || _        y rI   )	r'   rk  r(   rr   r   r   r   r,   r   )
r/   rr   r   r   r   r   r   r   r&   r0   s
            €r1   r(   zSpectralCentroid.__init__g  s‚   ø€ ô 	Ô Ñ.Ô0Ø&ˆÔØˆŒ
Ø(2Ð(>™*ÀEˆŒØ(2Ð(>™*ÀDÇOÁOÐWXÑDXˆŒØ/6¨‘˜4Ÿ?™?Ô+ÁIÈdÏoÉoÑDiÐahÑDiˆØ×Ñ˜X vÔ.Øˆ�r2   r3   c           	      ó°   — t        j                  || j                  | j                  | j                  | j
                  | j                  | j                  «      S )z±
        Args:
            waveform (Tensor): Tensor of audio of dimension `(..., time)`.

        Returns:
            Tensor: Spectral Centroid of size `(..., time)`.
        )r5   Úspectral_centroidrr   r   r&   r   r   r   r7   s     r1   r8   zSpectralCentroid.forwardz  sC   € ô ×"Ñ"Ø�d×&Ñ&¨¯©°$·+±+¸t¿z¹zÈ4Ï?É?Ð\`×\kÑ\kó
ð 	
r2   )r9   r:   r;   r<   r=   r)   r>   r?   r   r   r   rC   r(   r8   rD   rE   s   @r1   rk  rk  L  s¥   ø„ ñò0 P€Mð
 Ø$(Ø$(ØØ+0×+<Ñ+<Ø"&ñàðð ðð ˜S‘Mð	ð
 ˜S‘Mðð ðð ˜C ˜KÑ(ðð ˜$‘ðð 
õð&
 ð 
¨6÷ 
r2   rk  c                   óº   ‡ — e Zd ZU dZg d¢Zeed<   eed<   ddddej                  dfded	ed
edede
e   de
e   dedef   de
e   ddfˆ fd„Zd„ Zdedefd„Zˆ xZS )Ú
PitchShifta¦  Shift the pitch of a waveform by ``n_steps`` steps.

    .. devices:: CPU CUDA

    .. properties:: TorchScript

    Args:
        waveform (Tensor): The input waveform of shape `(..., time)`.
        sample_rate (int): Sample rate of `waveform`.
        n_steps (int): The (fractional) steps to shift `waveform`.
        bins_per_octave (int, optional): The number of steps per octave (Default : ``12``).
        n_fft (int, optional): Size of FFT, creates ``n_fft // 2 + 1`` bins (Default: ``512``).
        win_length (int or None, optional): Window size. If None, then ``n_fft`` is used. (Default: ``None``).
        hop_length (int or None, optional): Length of hop between STFT windows. If None, then ``win_length // 4``
            is used (Default: ``None``).
        window (Tensor or None, optional): Window tensor that is applied/multiplied to each frame/window.
            If None, then ``torch.hann_window(win_length)`` is used (Default: ``None``).

    Example
        >>> waveform, sample_rate = torchaudio.load("test.wav", normalize=True)
        >>> transform = transforms.PitchShift(sample_rate, 4)
        >>> waveform_shift = transform(waveform)  # (channel, time)
    )rr   Ún_stepsÚbins_per_octaver   r   r   rÝ   rß   é   i   Nrr   rq  rr  r   r   r   r   .r   r#   c	                 ó  •— t         ‰| �  «        || _        || _        || _        || _        |�|n|| _        |�|n| j                  dz  | _        |€ || j                  «      n || j                  fi |¤Ž}	| j                  d|	«       dt        |«       |z  z  }
t        ||
z  «      | _        t        j                  t        | j                  «      t        |«      «      | _        | j                  |k7  rd| _        t        d d ¬«      | _        y y )Nrö   r&   r   r}   )r  rÕ   )r'   r(   rq  rr  rr   r   r   r   r,   r@   r?   rÖ   rh   rÞ   rß   r
   rÝ   )r/   rr   rq  rr  r   r   r   r   r   r&   rú   r0   s              €r1   r(   zPitchShift.__init__¥  só   ø€ ô 	‰ÑÔØˆŒØ.ˆÔØ&ˆÔØˆŒ
Ø(2Ð(>™*ÀEˆŒØ(2Ð(>™*ÀDÇOÁOÐWXÑDXˆŒØ/6¨‘˜4Ÿ?™?Ô+ÁIÈdÏoÉoÑDiÐahÑDiˆØ×Ñ˜X vÔ.Øœ˜g›�¨Ñ8Ñ9ˆÜ˜[¨4Ñ/Ó0ˆŒÜ—8‘8œC §¡Ó/´°[Ó1AÓBˆŒà�>‰>˜[Ò(ØˆDŒJÜ0¸ÀDÔIˆD�Kð )r2   c                 óÀ  — | j                  «       rÂ| j                  | j                  k7  r¨t        j                  «       5  t        | j                  | j                  | j                  |j                  |j                  ¬«      \  }| _	        | j                  j                  |j                  «       | j                  j                  |«       d d d «       y y y # 1 sw Y   y xY w)N)rÕ   r  )Úhas_uninitialized_paramsrÖ   rr   r)   Úno_gradr   rÞ   rÕ   r  rß   rÝ   Úmaterializer™   Úcopy_)r/   ÚinputrÝ   s      r1   Úinitialize_parametersz PitchShift.initialize_parametersÁ  s­   € Ø×(Ñ(Ô*Ø�~‰~ ×!1Ñ!1Ò1Ü—]‘]“_ñ 	.Ü)BØŸ™Ø×(Ñ(ØŸ™Ø#Ÿk™kØ$Ÿ|™|ô*Ñ&�F˜DœJð —K‘K×+Ñ+¨F¯L©LÔ9Ø—K‘K×%Ñ% fÔ-÷	.ð 	.ð 2ð +÷	.ð 	.ús   ¾BCÃCr3   c           	      ó�  — |j                  «       }t        || j                  | j                  | j                  | j
                  | j                  | j                  «      }| j                  | j                  k7  rCt        || j                  | j                  | j                  | j                  | j                  «      }n|}t        ||«      S )z¸
        Args:
            waveform (Tensor): Tensor of audio of dimension `(..., time)`.

        Returns:
            Tensor: The pitch-shifted audio of shape `(..., time)`.
        )r“   r   rq  rr  r   r   r   r&   rÖ   rr   r   rÞ   rÝ   rß   r   )r/   r3   r™   Úwaveform_stretchÚwaveform_shifts        r1   r8   zPitchShift.forwardÏ  s©   € ð —‘“ˆä,ØØ�L‰LØ× Ñ Ø�J‰JØ�O‰OØ�O‰OØ�K‰Kó
Ðð �>‰>˜T×-Ñ-Ò-Ü8Ø Ø—‘Ø× Ñ Ø—‘Ø—‘Ø—
‘
ó‰Nð .ˆNä"ØØó
ð 	
r2   )r9   r:   r;   r<   r=   r
   Ú__annotations__r?   r)   r>   r   r   r   rC   r(   r{  r8   rD   rE   s   @r1   rp  rp  ˆ  sÉ   ø… ñò. g€Mà"Ó"ØƒJð  "ØØ$(Ø$(Ø+0×+<Ñ+<Ø"&ñJàðJð ðJð ð	Jð
 ðJð ˜S‘MðJð ˜S‘MðJð ˜C ˜KÑ(ðJð ˜$‘ðJð 
õJò8.ð#
 ð #
¨6÷ #
r2   rp  c            	       óV   ‡ — e Zd ZdZ	 	 	 	 ddedededefˆ fd„Zde	de	d	e	d
e	fd„Z
ˆ xZS )ÚRNNTLossaœ  Compute the RNN Transducer loss from *Sequence Transduction with Recurrent Neural Networks*
    :cite:`graves2012sequence`.

    .. devices:: CPU CUDA

    .. properties:: Autograd TorchScript

    The RNN Transducer loss extends the CTC loss by defining a distribution over output
    sequences of all lengths, and by jointly modelling both input-output and output-output
    dependencies.

    Args:
        blank (int, optional): blank label (Default: ``-1``)
        clamp (float, optional): clamp for gradients (Default: ``-1``)
        reduction (string, optional): Specifies the reduction to apply to the output:
            ``"none"`` | ``"mean"`` | ``"sum"``. (Default: ``"mean"``)
        fused_log_softmax (bool): set to False if calling log_softmax outside of loss (Default: ``True``)

    Example
        >>> # Hypothetical values
        >>> logits = torch.tensor([[[[0.1, 0.6, 0.1, 0.1, 0.1],
        >>>                          [0.1, 0.1, 0.6, 0.1, 0.1],
        >>>                          [0.1, 0.1, 0.2, 0.8, 0.1]],
        >>>                         [[0.1, 0.6, 0.1, 0.1, 0.1],
        >>>                          [0.1, 0.1, 0.2, 0.1, 0.1],
        >>>                          [0.7, 0.1, 0.2, 0.1, 0.1]]]],
        >>>                       dtype=torch.float32,
        >>>                       requires_grad=True)
        >>> targets = torch.tensor([[1, 2]], dtype=torch.int)
        >>> logit_lengths = torch.tensor([2], dtype=torch.int)
        >>> target_lengths = torch.tensor([2], dtype=torch.int)
        >>> transform = transforms.RNNTLoss(blank=0)
        >>> loss = transform(logits, targets, logit_lengths, target_lengths)
        >>> loss.backward()
    ÚblankrI  Ú	reductionÚfused_log_softmaxc                 óZ   •— t         ‰| �  «        || _        || _        || _        || _        y rM   )r'   r(   r‚  rI  rƒ  r„  )r/   r‚  rI  rƒ  r„  r0   s        €r1   r(   zRNNTLoss.__init__  s-   ø€ ô 	‰ÑÔØˆŒ
ØˆŒ
Ø"ˆŒØ!2ˆÕr2   ÚlogitsÚtargetsÚlogit_lengthsÚtarget_lengthsc           
      óŠ   — t        j                  ||||| j                  | j                  | j                  | j
                  «      S )a¦  
        Args:
            logits (Tensor): Tensor of dimension `(batch, max seq length, max target length + 1, class)`
                containing output from joiner
            targets (Tensor): Tensor of dimension `(batch, max target length)` containing targets with zero padded
            logit_lengths (Tensor): Tensor of dimension `(batch)` containing lengths of each sequence from encoder
            target_lengths (Tensor): Tensor of dimension `(batch)` containing lengths of targets for each sequence
        Returns:
            Tensor: Loss with the reduction option applied. If ``reduction`` is  ``"none"``, then size (batch),
            otherwise scalar.
        )r5   Ú	rnnt_lossr‚  rI  rƒ  r„  )r/   r†  r‡  rˆ  r‰  s        r1   r8   zRNNTLoss.forward'  s?   € ô$ �{‰{ØØØØØ�J‰JØ�J‰JØ�N‰NØ×"Ñ"ó	
ð 		
r2   )r}   g      ð¿r6  T)r9   r:   r;   r<   r?   r@   rB   rA   r(   r   r8   rD   rE   s   @r1   r�  r�  õ  sm   ø„ ñ"ðL ØØØ"&ñ3àð3ð ð3ð ð	3ð
  õ3ð
àð
ð ð
ð ð	
ð
 ÷
r2   r�  c                   ó~   ‡ — e Zd ZdZd	deddfˆ fd„Zdej                  dej                  dej                  fd„Zˆ xZ	S )
ÚConvolveaº  
    Convolves inputs along their last dimension using the direct method.
    Note that, in contrast to :class:`torch.nn.Conv1d`, which actually applies the valid cross-correlation
    operator, this module applies the true `convolution`_ operator.

    .. devices:: CPU CUDA

    .. properties:: Autograd TorchScript

    Args:
        mode (str, optional): Must be one of ("full", "valid", "same").

            * "full": Returns the full convolution result, with shape `(..., N + M - 1)`, where
              `N` and `M` are the trailing dimensions of the two inputs. (Default)
            * "valid": Returns the segment of the full convolution result corresponding to where
              the two inputs overlap completely, with shape `(..., max(N, M) - min(N, M) + 1)`.
            * "same": Returns the center segment of the full convolution result, with shape `(..., N)`.

    .. _convolution:
        https://en.wikipedia.org/wiki/Convolution
    rå   r#   Nc                 óF   •— t        |«       t        ‰| �	  «        || _        y rM   ©r   r'   r(   rå   ©r/   rå   r0   s     €r1   r(   zConvolve.__init__\  ó   ø€ Ü˜TÔ"ä‰ÑÔØˆ�	r2   rk   Úyc                 óF   — t        j                  ||| j                  ¬«      S ©aÐ  
        Args:
            x (torch.Tensor): First convolution operand, with shape `(..., N)`.
            y (torch.Tensor): Second convolution operand, with shape `(..., M)`
                (leading dimensions must be broadcast-able with those of ``x``).

        Returns:
            torch.Tensor: Result of convolving ``x`` and ``y``, with shape `(..., L)`, where
            the leading dimensions match those of ``x`` and `L` is dictated by ``mode``.
        )rå   )r5   Úconvolverå   ©r/   rk   r’  s      r1   r8   zConvolve.forwardb  s   € ô �z‰z˜!˜Q T§Y¡YÔ/Ð/r2   ©Úfull©
r9   r:   r;   r<   rB   r(   r)   r   r8   rD   rE   s   @r1   r�  r�  E  sA   ø„ ññ,˜Sð ¨dõ ð0˜Ÿ™ð 0¨%¯,©,ð 0¸5¿<¹<÷ 0r2   r�  c                   ó~   ‡ — e Zd ZdZd	deddfˆ fd„Zdej                  dej                  dej                  fd„Zˆ xZ	S )
ÚFFTConvolvea|  
    Convolves inputs along their last dimension using FFT. For inputs with large last dimensions, this module
    is generally much faster than :class:`Convolve`.
    Note that, in contrast to :class:`torch.nn.Conv1d`, which actually applies the valid cross-correlation
    operator, this module applies the true `convolution`_ operator.
    Also note that this module can only output float tensors (int tensor inputs will be cast to float).

    .. devices:: CPU CUDA

    .. properties:: Autograd TorchScript

    Args:
        mode (str, optional): Must be one of ("full", "valid", "same").

            * "full": Returns the full convolution result, with shape `(..., N + M - 1)`, where
              `N` and `M` are the trailing dimensions of the two inputs. (Default)
            * "valid": Returns the segment of the full convolution result corresponding to where
              the two inputs overlap completely, with shape `(..., max(N, M) - min(N, M) + 1)`.
            * "same": Returns the center segment of the full convolution result, with shape `(..., N)`.

    .. _convolution:
        https://en.wikipedia.org/wiki/Convolution
    rå   r#   Nc                 óF   •— t        |«       t        ‰| �	  «        || _        y rM   r�  r�  s     €r1   r(   zFFTConvolve.__init__‰  r‘  r2   rk   r’  c                 óF   — t        j                  ||| j                  ¬«      S r”  )r5   Úfftconvolverå   r–  s      r1   r8   zFFTConvolve.forward�  s   € ô �}‰}˜Q ¨¯	©	Ô2Ð2r2   r—  r™  rE   s   @r1   r›  r›  p  sA   ø„ ññ0˜Sð ¨dõ ð3˜Ÿ™ð 3¨%¯,©,ð 3¸5¿<¹<÷ 3r2   r›  rÖ   Úspeedr#   c                 ót   — t        || z  «      }t        | «      }t        j                  ||«      }||z  ||z  fS rM   )r?   rh   rÞ   )rÖ   rŸ  Úsource_sample_rateÚtarget_sample_raterÞ   s        r1   Ú_source_target_sample_rater£  �  sD   € Ü˜U YÑ.Ó/ÐÜ˜Y›ÐÜ
�(‰(Ð%Ð'9Ó
:€CØ Ñ$Ð&8¸CÑ&?Ð?Ð?r2   c                   óˆ   ‡ — e Zd ZdZdˆ fd„Zddeej                     deej                  eej                     f   fd„Z	ˆ xZ
S )ÚSpeedax  Adjusts waveform speed.

    .. devices:: CPU CUDA

    .. properties:: Autograd TorchScript

    Args:
        orig_freq (int): Original frequency of the signals in ``waveform``.
        factor (float): Factor by which to adjust speed of input. Values greater than 1.0
            compress ``waveform`` in time, whereas values less than 1.0 stretch ``waveform`` in time.
    r#   c                 ó¼   •— t         ‰| �  «        || _        || _        t	        ||«      \  | _        | _        t        | j
                  | j                  ¬«      | _        y )N)rÖ   r×   )	r'   r(   rÖ   Úfactorr£  r¡  r¢  rÓ   Ú	resampler)r/   rÖ   r§  r0   s      €r1   r(   zSpeed.__init__±  sO   ø€ Ü‰ÑÔà"ˆŒØˆŒä;UÐV_ÐagÓ;hÑ8ˆÔ Ô!8Ü!¨D×,CÑ,CÈd×NeÑNeÔfˆ�r2   Úlengthsc                 óÂ   — |€d}nHt        j                  || j                  z  | j                  z  «      j	                  |j
                  «      }| j                  |«      |fS )á´  
        Args:
            waveform (torch.Tensor): Input signals, with shape `(..., time)`.
            lengths (torch.Tensor or None, optional): Valid lengths of signals in ``waveform``, with shape `(...)`.
                If ``None``, all elements in ``waveform`` are treated as valid. (Default: ``None``)

        Returns:
            (torch.Tensor, torch.Tensor or None):
                torch.Tensor
                    Speed-adjusted waveform, with shape `(..., new_time).`
                torch.Tensor or None
                    If ``lengths`` is not ``None``, valid lengths of signals in speed-adjusted waveform,
                    with shape `(...)`; otherwise, ``None``.
        N)r)   Úceilr¢  r¡  ÚtorÕ   r¨  )r/   r3   r©  Úout_lengthss       r1   r8   zSpeed.forwardº  sX   € ð  ˆ?Ø‰KäŸ*™* W¨t×/FÑ/FÑ%FÈ×I`ÑI`Ñ%`Óa×dÑdÐel×erÑerÓsˆKà�~‰~˜hÓ'¨Ð4Ð4r2   )r#   NrM   )r9   r:   r;   r<   r(   r   r)   r   r   r8   rD   rE   s   @r1   r¥  r¥  ¤  sH   ø„ ñ
õgñ5¨°%·,±,Ñ)?ð 5È5ÐQV×Q]ÑQ]Ð_gÐhm×htÑhtÑ_uÐQuÑKv÷ 5r2   r¥  c            
       ó´   ‡ — e Zd ZdZdedee   ddfˆ fd„Z	 d
dej                  de
ej                     deej                  e
ej                     f   fd	„Zˆ xZS )ÚSpeedPerturbationaÚ  Applies the speed perturbation augmentation introduced in
    *Audio augmentation for speech recognition* :cite:`ko15_interspeech`. For a given input,
    the module samples a speed-up factor from ``factors`` uniformly at random and adjusts
    the speed of the input by that factor.

    .. devices:: CPU CUDA

    .. properties:: Autograd TorchScript

    Args:
        orig_freq (int): Original frequency of the signals in ``waveform``.
        factors (Sequence[float]): Factors by which to adjust speed of input. Values greater than 1.0
            compress ``waveform`` in time, whereas values less than 1.0 stretch ``waveform`` in time.

    Example
        >>> speed_perturb = SpeedPerturbation(16000, [0.9, 1.1, 1.0, 1.0, 1.0])
        >>> # waveform speed will be adjusted by factor 0.9 with 20% probability,
        >>> # 1.1 with 20% probability, and 1.0 (i.e. kept the same) with 60% probability.
        >>> speed_perturbed_waveform = speed_perturb(waveform, lengths)
    rÖ   Úfactorsr#   Nc           	      ó¦   •— t         ‰| �  «        t        j                  j	                  |D �cg c]  }t        ||¬«      ‘Œ c}«      | _        y c c}w )N)rÖ   r§  )r'   r(   r)   ÚnnÚ
ModuleListr¥  Úspeeders)r/   rÖ   r±  r§  r0   s       €r1   r(   zSpeedPerturbation.__init__è  s;   ø€ Ü‰ÑÔäŸ™×+Ñ+ÐelÖ,mÐ[a¬U¸YÈvÖ-VÒ,mÓnˆ�ùÒ,ms   ­Ar3   r©  c                 óÖ   — t        t        j                  t        | j                  «      d«      «      }t        | j                  «      D ]  \  }}||k(  sŒ |||«      c S  t        d«      ‚)r«  r«   z<Speeder not found; execution should have never reached here.)r?   r)   ÚrandintÚlenrµ  Ú	enumerateÚRuntimeError)r/   r3   r©  ÚidxÚspeeder_idxÚspeeders         r1   r8   zSpeedPerturbation.forwardí  sd   € ô$ ”%—-‘-¤ D§M¡MÓ 2°BÓ7Ó8ˆô %.¨d¯m©mÓ$<ò 	2Ñ ˆK˜Ø�kÓ!Ù˜x¨Ó1Ò1ð	2ô ÐYÓZÐZr2   rM   )r9   r:   r;   r<   r?   r   r@   r(   r)   r   r   r   r8   rD   rE   s   @r1   r°  r°  Ò  sv   ø„ ñð*o #ð o°¸±ð oÀDõ oð IMñ[ØŸ™ð[Ø/7¸¿¹Ñ/Eð[à	ˆu�|‰|˜X e§l¡lÑ3Ð3Ñ	4÷[r2   r°  c                   óš   — e Zd ZdZ	 d	dej
                  dej
                  dej
                  deej
                     dej
                  f
d„Zy)
ÚAddNoisezÈScales and adds noise to waveform per signal-to-noise ratio.
    See :meth:`torchaudio.functional.add_noise` for more details.

    .. devices:: CPU CUDA

    .. properties:: Autograd TorchScript
    Nr3   ÚnoiseÚsnrr©  r#   c                 ó2   — t        j                  ||||«      S )aê  
        Args:
            waveform (torch.Tensor): Input waveform, with shape `(..., L)`.
            noise (torch.Tensor): Noise, with shape `(..., L)` (same shape as ``waveform``).
            snr (torch.Tensor): Signal-to-noise ratios in dB, with shape `(...,)`.
            lengths (torch.Tensor or None, optional): Valid lengths of signals in ``waveform`` and ``noise``,
            with shape `(...,)` (leading dimensions must match those of ``waveform``). If ``None``, all
            elements in ``waveform`` and ``noise`` are treated as valid. (Default: ``None``)

        Returns:
            torch.Tensor: Result of scaling and adding ``noise`` to ``waveform``, with shape `(..., L)`
            (same shape as ``waveform``).
        )r5   Ú	add_noise)r/   r3   rÀ  rÁ  r©  s        r1   r8   zAddNoise.forward  s   € ô  �{‰{˜8 U¨C°Ó9Ð9r2   rM   )r9   r:   r;   r<   r)   r   r   r8   r«   r2   r1   r¿  r¿    sW   „ ñð quñ:ØŸ™ð:Ø-2¯\©\ð:Ø@EÇÁð:ØW_Ð`e×`lÑ`lÑWmð:à	�‰ô:r2   r¿  c                   óf   ‡ — e Zd ZdZddeddfˆ fd„Zdej                  dej                  fd„Zˆ xZ	S )	ÚPreemphasisaB  Pre-emphasizes a waveform along its last dimension.
    See :meth:`torchaudio.functional.preemphasis` for more details.

    .. devices:: CPU CUDA

    .. properties:: Autograd TorchScript

    Args:
        coeff (float, optional): Pre-emphasis coefficient. Typically between 0.0 and 1.0.
            (Default: 0.97)
    Úcoeffr#   Nc                 ó0   •— t         ‰| �  «        || _        y rM   ©r'   r(   rÆ  ©r/   rÆ  r0   s     €r1   r(   zPreemphasis.__init__1  ó   ø€ Ü‰ÑÔØˆ�
r2   r3   c                 óD   — t        j                  || j                  ¬«      S )z¹
        Args:
            waveform (torch.Tensor): Waveform, with shape `(..., N)`.

        Returns:
            torch.Tensor: Pre-emphasized waveform, with shape `(..., N)`.
        ©rÆ  )r5   ÚpreemphasisrÆ  r7   s     r1   r8   zPreemphasis.forward5  s   € ô �}‰}˜X¨T¯Z©ZÔ8Ð8r2   ©g
×£p=
ï?©
r9   r:   r;   r<   r@   r(   r)   r   r8   rD   rE   s   @r1   rÅ  rÅ  $  s6   ø„ ñ
ñ˜eð ¨tõ ð9 §¡ð 9°·±÷ 9r2   rÅ  c                   óf   ‡ — e Zd ZdZddeddfˆ fd„Zdej                  dej                  fd„Zˆ xZ	S )	Ú
Deemphasisa?  De-emphasizes a waveform along its last dimension.
    See :meth:`torchaudio.functional.deemphasis` for more details.

    .. devices:: CPU CUDA

    .. properties:: Autograd TorchScript

    Args:
        coeff (float, optional): De-emphasis coefficient. Typically between 0.0 and 1.0.
            (Default: 0.97)
    rÆ  r#   Nc                 ó0   •— t         ‰| �  «        || _        y rM   rÈ  rÉ  s     €r1   r(   zDeemphasis.__init__M  rÊ  r2   r3   c                 óD   — t        j                  || j                  ¬«      S )z¸
        Args:
            waveform (torch.Tensor): Waveform, with shape `(..., N)`.

        Returns:
            torch.Tensor: De-emphasized waveform, with shape `(..., N)`.
        rÌ  )r5   Ú
deemphasisrÆ  r7   s     r1   r8   zDeemphasis.forwardQ  s   € ô �|‰|˜H¨D¯J©JÔ7Ð7r2   rÎ  rÏ  rE   s   @r1   rÑ  rÑ  @  s6   ø„ ñ
ñ˜eð ¨tõ ð8 §¡ð 8°·±÷ 8r2   rÑ  )>rh   r-   Útypingr   r   r   r   r   r)   r   Útorch.nn.modules.lazyr	   Útorch.nn.parameterr
   Ú
torchaudior   r5   Ú torchaudio.functional.functionalr   r   r   r   r   Ú__all__r³  ÚModuler   rG   rO   r^   rp   r‰   rž   r¢   r¶   rÂ   rÍ   rÓ   rä   rì   rü   r  r(  r,  r0  r;  rA  rK  rU  rk  rp  r�  r�  r›  r?   r@   r£  r¥  r°  r¿  rÅ  rÑ  r«   r2   r1   ú<module>rÜ     s.  ðó Û ß =Õ =ã Ý Ý 1Ý 5å &÷õ ð €ôb
�%—(‘(—/‘/ô b
ôJS
˜Ÿ™Ÿ™ô S
ôlU
�—‘—‘ô U
ôp.a�E—H‘H—O‘Oô .aôbBˆu�x‰x�‰ô BôJU�e—h‘h—o‘oô Uôpt�U—X‘X—_‘_ô tônTˆ5�8‰8�?‰?ô Tônkˆ5�8‰8�?‰?ô kô\$@�E—H‘H—O‘Oô $@ôN#C�E—H‘H—O‘Oô #CôLQwˆu�x‰x�‰ô QwôhV�E—H‘H—O‘Oô Vô>EL�%—(‘(—/‘/ô ELôPN4ˆ5�8‰8�?‰?ô N4ôb&v�5—8‘8—?‘?ô &vôRN�|ô NôD#N�,ô #NôLD�%—(‘(—/‘/ô DôN 6ˆu�x‰x�‰ô  6ôF-,ˆ%�(‰(�/‰/ô -,ô`(�u—x‘x—‘ô (ôVE
ˆ%�(‰(�/‰/ô E
ôP9
�u—x‘x—‘ô 9
ôxj
� %§(¡(§/¡/ô j
ôZM
ˆu�x‰x�‰ô M
ô`(0ˆu�x‰x�‰ô (0ôV*3�%—(‘(—/‘/ô *3ðZ@¨#ð @°eð @ÀÀcÈ3ÀhÁó @ô+5ˆE�H‰H�O‰Oô +5ô\3[˜Ÿ™Ÿ™ô 3[ôl:ˆu�x‰x�‰ô :ô89�%—(‘(—/‘/ô 9ô88�—‘—‘õ 8r2   