MelScale¶
- class torchaudio.transforms.MelScale(n_mels: int = 128, sample_rate: int = 16000, f_min: float = 0.0, f_max: Optional[float] = None, n_stft: int = 201, norm: Optional[str] = None, mel_scale: str = 'htk')[source]¶
Turn a normal STFT into a mel frequency STFT with triangular filter banks.
- Parameters:
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_fftinSpectrogram. (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:
htkorslaney. (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
torchaudio.functional.melscale_fbanks()- The function used to generate the filter banks.