mindspore.dataset.audio.GriffinLim

View Source On Gitee
class mindspore.dataset.audio.GriffinLim(n_fft=400, n_iter=32, win_length=None, hop_length=None, window_type=WindowType.HANN, power=2.0, momentum=0.99, length=None, rand_init=True)[source]

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

About Griffin-Lim please refer to A fast Griffin-Lim algorithm and Signal estimation from modified short-time Fourier transform .

Parameters
  • n_fft (int, optional) – Size of FFT. Default: 400.

  • n_iter (int, optional) – Number of iteration for phase recovery. Default: 32.

  • win_length (int, optional) – Window size for GriffinLim. Default: None, will be set to n_fft .

  • hop_length (int, optional) – Length of hop between STFT windows. Default: None, will be set to win_length // 2 .

  • window_type (WindowType, optional) – Window type for GriffinLim, which can be WindowType.BARTLETT, WindowType.BLACKMAN, WindowType.HAMMING, WindowType.HANN or WindowType.KAISER. Default: WindowType.HANN. Currently kaiser window is not supported on macOS.

  • power (float, optional) – Exponent for the magnitude spectrogram. Default: 2.0.

  • momentum (float, optional) – The momentum for fast Griffin-Lim. Default: 0.99.

  • length (int, optional) – Length of the expected output waveform. Default: None, will be set to the value of last dimension of the stft matrix.

  • rand_init (bool, optional) – Flag for random phase initialization or all-zero phase initialization. Default: True.

Raises
Supported Platforms:

CPU

Examples

>>> import numpy as np
>>> import mindspore.dataset as ds
>>> import mindspore.dataset.audio as audio
>>>
>>> waveform = np.random.random([201, 6])
>>> numpy_slices_dataset = ds.NumpySlicesDataset(data=waveform, column_names=["audio"])
>>> transforms = [audio.GriffinLim(n_fft=400)]
>>> numpy_slices_dataset = numpy_slices_dataset.map(operations=transforms, input_columns=["audio"])
Tutorial Examples: