librosa.feature.inverse.pitch_to_audio#
- librosa.feature.inverse.pitch_to_audio(P, *, sr=22050, n_fft=2048, hop_length=None, win_length=None, window='hann', center=True, pad_mode='constant', power=2.0, n_iter=32, length=None, dtype=<class 'numpy.float32'>, n_pitches=None, fmin=None, intervals='equal', bins_per_octave=12, tuning=0.0, filter_window=None, norm=None, **kwargs)[source]#
Invert a musical pitch spectrogram to audio using Griffin-Lim.
This is primarily a convenience wrapper for:
>>> S = librosa.feature.inverse.pitch_to_stft(P) >>> y = librosa.griffinlim(S)
- Parameters:
- Pnp.ndarray [shape=(…, n_pitches, t), non-negative]
The spectrogram as produced by feature.pitch_spectrogram
- srnumber > 0 [scalar]
Sampling rate of the underlying signal.
- n_fftint > 0 [scalar]
Length of the FFT frame for the intermediate 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.- windowstr, tuple, number, function, or np.ndarray [shape=(n_fft,)]
A window specification as supported by stft or istft.
- centerbool
If True, the STFT is assumed to use centered frames. If False, the STFT is assumed to use left-aligned frames.
- pad_modestr
If
center=True, the padding mode to use at the edges of the signal. By default, STFT uses zero padding.- powerfloat > 0 [scalar]
Exponent for the magnitude spectrogram.
- n_iterint > 0
The number of iterations for Griffin-Lim.
- lengthNone or int > 0
If provided, the output
yis zero-padded or clipped to exactlylengthsamples.- dtypenp.dtype
Real numeric type for the time-domain signal. Default is 32-bit float.
- n_pitchesint > 0 [scalar, optional]
Number of pitch bands. If None, defaults to
P.shape[-2].- fminfloat > 0, str, or None, optional
Minimum pitch center frequency (or note name in SPN format, e.g. ‘C1’). If None, defaults to MIDI 0 (~8.18 Hz) when
n_pitches=128, or ‘C1’.- intervalsstr or collection of float, default=’equal’
Interval system used to construct the pitch filterbank.
- bins_per_octaveint > 0 [scalar], default=12
Number of bins per octave in the interval system.
- tuningfloat, default=0.0
Tuning deviation from A440 in fractional bins.
- filter_windowstr, callable, or None, default=None
Filter shape for each pitch band.
- norm{None, ‘slaney’, or number}, default=None
Normalization applied to each filter row.
- **kwargsadditional keyword arguments
Additional keyword arguments for
librosa.filters.pitch_filterbank.
- Returns:
- ynp.ndarray [shape=(…, n)]
Time-domain signal reconstructed from
P.