A python implementation of two-stage HPSS (a singing voice extraction method)
Two-stage HPSS separates a music signal into harmonic, vocal, and percussive components.
Copyright ©️ 2020 Hideyuki Tachibana, MIT License
# import
import numpy as np
import scipy.io.wavfile as wavfile
import py2shpss
# load music
sr, sig = wavfile.read("your_awesome_music.wav")
if len(sig.shape) == 2:
# mix left and right channels if stereo
sig = np.mean(sig, axis=1)
sig = sig / np.max(sig)
# process and save
twostageHPSS = py2shpss.twostageHPSS(samprate = sr)
harmonic, vocal, percussive = twostageHPSS(sig)
wavfile.write("vocal.wav", sr, vocal)
Two-stage HPSS was proposed in following papers.