nnAudio.features.griffin_lim.Griffin_Lim¶
- class nnAudio.features.griffin_lim.Griffin_Lim(n_fft, n_iter=32, hop_length=None, win_length=None, window='hann', center=True, pad_mode='reflect', momentum=0.99, device='cpu')¶
Bases:
torch.nn.modules.module.Module
Converting Magnitude spectrograms back to waveforms based on the “fast Griffin-Lim”[1]. This Griffin Lim is a direct clone from librosa.griffinlim.
[1] Perraudin, N., Balazs, P., & Søndergaard, P. L. “A fast Griffin-Lim algorithm,” IEEE Workshop on Applications of Signal Processing to Audio and Acoustics (pp. 1-4), Oct. 2013.
- Parameters
n_fft (int) – The window size. Default value is 2048.
n_iter=32 (int) – The number of iterations for Griffin-Lim. The default value is
32
hop_length (int) – The hop (or stride) size. Default value is
None
which is equivalent ton_fft//4
. Please make sure the value is the same as the forward STFT.window (str) – The windowing function for iSTFT. It uses
scipy.signal.get_window
, please refer to scipy documentation for possible windowing functions. The default value is ‘hann’. Please make sure the value is the same as the forward STFT.center (bool) – Putting the iSTFT keneral at the center of the time-step or not. If
False
, the time index is the beginning of the iSTFT kernel, ifTrue
, the time index is the center of the iSTFT kernel. Default value ifTrue
. Please make sure the value is the same as the forward STFT.momentum (float) – The momentum for the update rule. The default value is
0.99
.device (str) – Choose which device to initialize this layer. Default value is ‘cpu’
Methods
__init__
Initializes internal Module state, shared by both nn.Module and ScriptModule.
Convert a batch of magnitude spectrograms to waveforms.
- forward(S)¶
Convert a batch of magnitude spectrograms to waveforms.
- Parameters
S (torch tensor) – Spectrogram of the shape
(batch, n_fft//2+1, timesteps)