Caution

You're reading an old version of this documentation. If you want up-to-date information, please have a look at 0.9.1.

librosa.feature.inverse.mel_to_audio

librosa.feature.inverse.mel_to_audio(M, sr=22050, n_fft=2048, hop_length=512, win_length=None, window='hann', center=True, pad_mode='reflect', power=2.0, n_iter=32, length=None, dtype=<class 'numpy.float32'>, **kwargs)[source]

Invert a mel power spectrogram to audio using Griffin-Lim.

This is primarily a convenience wrapper for:

>>> S = librosa.feature.inverse.mel_to_stft(M)
>>> y = librosa.griffinlim(S)
Parameters
Mnp.ndarray [shape=(n_mels, n), non-negative]

The spectrogram as produced by feature.melspectrogram

srnumber > 0 [scalar]

sampling rate of the underlying signal

n_fftint > 0 [scalar]

number of FFT components in the resulting STFT

hop_lengthNone or int > 0

The hop length of the STFT. If not provided, it will default to n_fft // 4

win_lengthNone or int > 0

The window length of the STFT. By default, it will equal n_fft

windowstring, tuple, number, function, or np.ndarray [shape=(n_fft,)]

A window specification as supported by stft or istft

centerboolean

If True, the STFT is assumed to use centered frames. If False, the STFT is assumed to use left-aligned frames.

pad_modestring

If center=True, the padding mode to use at the edges of the signal. By default, STFT uses reflection padding.

powerfloat > 0 [scalar]

Exponent for the magnitude melspectrogram

n_iterint > 0

The number of iterations for Griffin-Lim

lengthNone or int > 0

If provided, the output y is zero-padded or clipped to exactly length samples.

dtypenp.dtype

Real numeric type for the time-domain signal. Default is 32-bit float.

kwargsadditional keyword arguments

Mel filter bank parameters

Returns
ynp.ndarray [shape(n,)]

time-domain signal reconstructed from M

See also

core.griffinlim
feature.melspectrogram
filters.mel
feature.inverse.mel_to_stft