espnet2.utils.griffin_lim.logmel2linear
Less than 1 minute
espnet2.utils.griffin_lim.logmel2linear
espnet2.utils.griffin_lim.logmel2linear(lmspc: ndarray, fs: int, n_fft: int, n_mels: int, fmin: int | None = None, fmax: int | None = None) → ndarray
Convert log Mel filterbank to linear spectrogram.
This function transforms a log Mel spectrogram into a linear spectrogram using the inverse of the Mel filterbank. It computes the inverse Mel basis and applies it to the log Mel spectrogram.
- Parameters:
- lmspc (np.ndarray) – Log Mel filterbank with shape (T, n_mels).
- fs (int) – Sampling frequency.
- n_fft (int) – The number of FFT points.
- n_mels (int) – The number of Mel basis.
- fmin (Optional *[*int ]) – Minimum frequency to analyze. If None, defaults to 0.
- fmax (Optional *[*int ]) – Maximum frequency to analyze. If None, defaults to fs / 2.
- Returns: Linear spectrogram with shape (T, n_fft // 2 + 1).
- Return type: np.ndarray
Examples
>>> import numpy as np
>>> lmspc = np.random.rand(100, 40) # Example log Mel spectrogram
>>> fs = 16000
>>> n_fft = 2048
>>> n_mels = 40
>>> linear_spc = logmel2linear(lmspc, fs, n_fft, n_mels)
>>> print(linear_spc.shape) # Should be (100, 1025) for 2048 FFT points
NOTE
The function uses the librosa library to create the Mel filterbank and compute its pseudoinverse.