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, norm: Optional[str] = None, mel_scale: str = 'htk', driver: str = 'gels')[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 torch.linalg.lstsq.
- 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
)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
)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)