Shortcuts

torchaudio.functional.griffinlim

torchaudio.functional.griffinlim(specgram: Tensor, window: Tensor, n_fft: int, hop_length: int, win_length: int, power: float, n_iter: int, momentum: float, length: Optional[int], rand_init: bool) Tensor[source]

Compute waveform from a linear scale magnitude spectrogram using the Griffin-Lim transformation.

This feature supports the following devices: CPU, CUDA This API supports the following properties: Autograd, TorchScript

Implementation ported from librosa [Brian McFee et al., 2015], A fast Griffin-Lim algorithm [Perraudin et al., 2013] and Signal estimation from modified short-time Fourier transform [Griffin and Lim, 1983].

Parameters
  • specgram (Tensor) – A magnitude-only STFT spectrogram of dimension (…, freq, frames) where freq is n_fft // 2 + 1.

  • window (Tensor) – Window tensor that is applied/multiplied to each frame/window

  • n_fft (int) – Size of FFT, creates n_fft // 2 + 1 bins

  • hop_length (int) – Length of hop between STFT windows. ( Default: win_length // 2)

  • win_length (int) – Window size. (Default: n_fft)

  • power (float) – Exponent for the magnitude spectrogram, (must be > 0) e.g., 1 for magnitude, 2 for power, etc.

  • n_iter (int) – Number of iteration for phase recovery process.

  • momentum (float) – The momentum parameter for fast Griffin-Lim. Setting this to 0 recovers the original Griffin-Lim method. Values near 1 can lead to faster convergence, but above 1 may not converge.

  • length (int or None) – Array length of the expected output.

  • rand_init (bool) – Initializes phase randomly if True, to zero otherwise.

Returns

waveform of (…, time), where time equals the length parameter if given.

Return type

Tensor

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources