InverseMelScale¶
- class torchaudio.transforms.InverseMelScale(n_stft: int, n_mels: int = 128, sample_rate: int = 16000, f_min: float = 0.0, f_max: Optional[float] = None, max_iter: int = 100000, tolerance_loss: float = 1e-05, tolerance_change: float = 1e-08, sgdargs: Optional[dict] = None, norm: Optional[str] = None, mel_scale: str = 'htk')[source]¶
Estimate a STFT in normal frequency domain from mel frequency domain.
It minimizes the euclidian norm between the input mel-spectrogram and the product between the estimated spectrogram and the filter banks using SGD.
- Parameters:
n_stft (int) – Number of bins in STFT. See
n_fft
inSpectrogram
.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
)max_iter (int, optional) – Maximum number of optimization iterations. (Default:
100000
)tolerance_loss (float, optional) – Value of loss to stop optimization at. (Default:
1e-5
)tolerance_change (float, optional) – Difference in losses to stop optimization at. (Default:
1e-8
)sgdargs (dict or None, optional) – Arguments for the SGD optimizer. (Default:
None
)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
orslaney
. (Default:htk
)
- 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)