mindspore.dataset.audio.InverseSpectrogram

class mindspore.dataset.audio.InverseSpectrogram(length=None, n_fft=400, win_length=None, hop_length=None, pad=0, window=WindowType.HANN, normalized=False, center=True, pad_mode=BorderType.REFLECT, onesided=True)[source]

Create an inverse spectrogram to recover an audio signal from a spectrogram.

Parameters
  • length (int, optional) – The output length of the waveform, must be non negative. Default: None, means to output the whole waveform.

  • n_fft (int, optional) – Size of FFT, creates n_fft // 2 + 1 bins, which should be greater than 0. Default: 400.

  • win_length (int, optional) – Window size, which should be greater than 0. Default: None, will be set to n_fft .

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

  • pad (int, optional) – Two sided padding of signal, cannot be less than 0. Default: 0.

  • window (WindowType, optional) – A function to create a window tensor that is applied/multiplied to each frame/window. Default: WindowType.HANN.

  • normalized (bool, optional) – Whether the spectrogram was normalized by magnitude after stft. Default: False.

  • center (bool, optional) – Whether the signal in spectrogram was padded on both sides. Default: True.

  • pad_mode (BorderType, optional) – Controls the padding method used when center is True, can be BorderType.REFLECT, BorderType.CONSTANT, BorderType.EDGE or BorderType.SYMMETRIC. Default: BorderType.REFLECT.

  • onesided (bool, optional) – Controls whether spectrogram was used to return half of results to avoid redundancy. Default: True.

Raises
Supported Platforms:

CPU

Examples

>>> import numpy as np
>>>
>>> waveform = np.array([[[0.8236, 0.2049, 0.3335], [0.5933, 0.9911, 0.2482],
...                      [0.3007, 0.9054, 0.7598], [0.5394, 0.2842, 0.5634], [0.6363, 0.2226, 0.2288]]])
>>> numpy_slices_dataset = ds.NumpySlicesDataset(data=waveform, column_names=["audio"])
>>> transforms = [audio.InverseSpectrogram(1, 400, 400, 200)]
>>> numpy_slices_dataset = numpy_slices_dataset.map(operations=transforms, input_columns=["audio"])