espnet2.utils.griffin_lim.Spectrogram2Waveform
espnet2.utils.griffin_lim.Spectrogram2Waveform
class espnet2.utils.griffin_lim.Spectrogram2Waveform(n_fft: int, n_shift: int, fs: int | None = None, n_mels: int | None = None, win_length: int | None = None, window: str | None = 'hann', fmin: int | None = None, fmax: int | None = None, griffin_lim_iters: int | None = 8)
Bases: object
Spectrogram to waveform conversion module.
This class provides functionality to convert log Mel filterbanks or linear spectrograms into waveforms using the Griffin-Lim algorithm. It allows for flexible configuration of parameters such as the sampling frequency, number of FFT points, and windowing options.
fs
Sampling frequency.
logmel2linear
Function to convert log Mel filterbank to linear spectrogram.
griffin_lim
Function to perform Griffin-Lim reconstruction.
params
Dictionary containing the parameters used for conversion.
- Parameters:
- n_fft – The number of FFT points.
- n_shift – Shift size in points.
- fs – Sampling frequency (optional).
- n_mels – The number of mel basis (optional).
- win_length – Window length in points (optional).
- window – Window function type (default: “hann”).
- fmin – Minimum frequency to analyze (optional).
- fmax – Maximum frequency to analyze (optional).
- griffin_lim_iters – The number of iterations for Griffin-Lim (default: 8).
Examples
>>> model = Spectrogram2Waveform(n_fft=2048, n_shift=512, fs=16000)
>>> logmel = torch.rand(100, 80) # Example log Mel filterbank
>>> waveform = model(logmel)
NOTE
This module is designed to work with PyTorch tensors and expects the input spectrogram to be in the shape (T_feats, n_mels) or (T_feats, n_fft // 2 + 1).
Initialize module.
- Parameters:
- fs – Sampling frequency.
- n_fft – The number of FFT points.
- n_shift – Shift size in points.
- n_mels – The number of mel basis.
- win_length – Window length in points.
- window – Window function type.
- f_min – Minimum frequency to analyze.
- f_max – Maximum frequency to analyze.
- griffin_lim_iters – The number of iterations.