mindspore.dataset.audio.GriffinLim
- class mindspore.dataset.audio.GriffinLim(n_fft=400, n_iter=32, win_length=None, hop_length=None, window_type=WindowType.HANN, power=2, momentum=0.99, length=None, rand_init=True)[源代码]
Approximate magnitude spectrogram inversion using the GriffinLim algorithm.
\[x(n)=\frac{\sum_{m=-\infty}^{\infty} w(m S-n) y_{w}(m S, n)}{\sum_{m=-\infty}^{\infty} w^{2}(m S-n)}\]where w represents the window function, y represents the reconstructed signal of each frame and x represents the whole signal.
- 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).
Examples
>>> import numpy as np >>> >>> 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"])