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 beBorderType.REFLECT
,BorderType.CONSTANT
,BorderType.EDGE
orBorderType.SYMMETRIC
. Default:BorderType.REFLECT
.onesided (bool, optional) – Controls whether spectrogram was used to return half of results to avoid redundancy. Default:
True
.
- Raises
TypeError – If length is not of type int.
ValueError – If length is a negative number.
TypeError – If n_fft is not of type int.
ValueError – If n_fft is not positive.
TypeError – If win_length is not of type int.
ValueError – If win_length is not positive.
TypeError – If hop_length is not of type int.
ValueError – If hop_length is not positive.
TypeError – If pad is not of type int.
ValueError – If pad is a negative number.
TypeError – If window is not of type
mindspore.dataset.audio.WindowType
.TypeError – If normalized is not of type bool.
TypeError – If center is not of type bool.
TypeError – If pad_mode is not of type
mindspore.dataset.audio.BorderType
.TypeError – If onesided is not of type bool.
- Supported Platforms:
CPU
Examples
>>> import numpy as np >>> import mindspore.dataset as ds >>> import mindspore.dataset.audio as audio >>> >>> 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"])
- Tutorial Examples: