comparison MFCC.py @ 24:34b4b44299be

getMFCCs(): prevent issue with silence producing infinities (cherry picked from commit 68e18c44dfdac06ca6967ce79ff7ae1806b4b0ee)
author Dan Stowell <danstowell@users.sourceforge.net>
date Thu, 24 Oct 2013 08:37:00 +0100
parents c7fa1f02f5f8
children
comparison
equal deleted inserted replaced
23:8319429b20da 24:34b4b44299be
99 '''Compute DCT of input matrix.''' 99 '''Compute DCT of input matrix.'''
100 return numpy.dot(self.DCTMatrix,data_matrix) 100 return numpy.dot(self.DCTMatrix,data_matrix)
101 101
102 def getMFCCs(self,warpedSpectrum,cn=True): 102 def getMFCCs(self,warpedSpectrum,cn=True):
103 '''Compute MFCC coefficients from Mel warped magnitude spectrum.''' 103 '''Compute MFCC coefficients from Mel warped magnitude spectrum.'''
104 mfccs=self.dct(numpy.log(warpedSpectrum)) 104 mfccs=self.dct(numpy.log(numpy.clip(warpedSpectrum, 1e-9, numpy.inf)))
105 if cn is False : mfccs[0] = 0.0 105 if cn is False : mfccs[0] = 0.0
106 return mfccs 106 return mfccs
107 107