librosa.effects.hpss

librosa.effects.hpss(y)[source]

Decompose an audio time series into harmonic and percussive components.

This function automates the STFT->HPSS->ISTFT pipeline, and ensures that the output waveforms have equal length to the input waveform y.

Parameters:

y : np.ndarray [shape=(n,)]

audio time series

Returns:

y_harmonic : np.ndarray [shape=(n,)]

audio time series of the harmonic elements

y_percussive : np.ndarray [shape=(n,)]

audio time series of the percussive elements

See also

harmonic
Extract only the harmonic component
percussive
Extract only the percussive component
librosa.decompose.hpss
HPSS on spectrograms

Examples

>>> y, sr = librosa.load(librosa.util.example_audio_file())
>>> y_harmonic, y_percussive = librosa.effects.hpss(y)