我想使用James Lyons (Github page)的python_speech_features模块计算音频信号的MFCC。我修改了一下,所以我可以在使用Mel Scale和Bark Scale之间切换,如下所示:
def mfcc(signal, samplerate=16000, winlen=0.025, winstep=0.01, numcep=13,
nfilt=26, nfft=512, lowfreq=0, highfreq=None, preemph=0.97,
ceplifter=22, appendEnergy=True, mel=True,
winfunc=lambda x:numpy.ones((x,))):
if mel:
feat, energy = fbank(signal, samplerate, winlen, winstep, nfilt,
nfft, lowfreq, highfreq, preemph, winfunc, mel=True)
else:
feat, energy = fbank(signal, samplerate, winlen, winstep, nfilt,
nfft, lowfreq, highfreq, preemph, winfunc, mel=False)
feat = numpy.log(feat)
feat = dct(feat, type=2, axis=1, norm='ortho')[:,:numcep]
feat = lifter(feat,ceplifter)
if appendEnergy:
# replace first cepstral coefficient with log of frame energy
feat[:,0] = numpy.log(energy)
return feat
当mel=True
时,它将使用Mel Scale方程计算,当mel=False
时,它将使用Bark Scale方程计算。但是,当我尝试在另一个程序中使用此函数时,我收到此错误:
TypeError: mfcc() got an unexpected keyword argument 'mel'
任何人都可以帮我解决这个问题吗?