def NMF(stft, n_sources):
"""
Sound source separation using NMF
:param stft: the short-time Fourier Transform of the signal
:param n_sources: the number of sources
:returns:
- Ys: sources
"""
print "Computing approximations"
W, H = librosa.decompose.decompose(np.abs(stft), n_components=n_sources, sort=True)
print "Reconstructing signals"
Ys = list(scipy.outer(W[:,i], H[i])*np.exp(1j*np.angle(stft)) for i in xrange(n_sources))
print "Saving sound arrays"
ys = [librosa.istft(Y) for Y in Ys]
del Ys
return ys
评论列表
文章目录