Skip to content

Commit 07720bd

Browse files
scienceopenybdarrenwang
authored andcommitted
complete example, REALLY make Python 2/3 compatible
1 parent a5e9c95 commit 07720bd

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

python_speech_features/base.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,14 @@ def get_filterbanks(nfilt=20,nfft=512,samplerate=16000,lowfreq=0,highfreq=None):
148148
# from Hz to fft bin number
149149
bin = numpy.floor((nfft+1)*mel2hz(melpoints)/samplerate)
150150

151+
fbank = numpy.zeros([nfilt,nfft//2+1])
152+
for j in range(0,nfilt):
153+
for i in range(int(bin[j]), int(bin[j+1])):
154+
fbank[j,i] = (i - bin[j]) / (bin[j+1]-bin[j])
155+
for i in range(int(bin[j+1]), int(bin[j+2])):
156+
fbank[j,i] = (bin[j+2]-i) / (bin[j+2]-bin[j+1])
157+
return fbank
158+
151159
def lifter(cepstra, L=22):
152160
"""Apply a cepstral lifter the the matrix of cepstra. This has the effect of increasing the
153161
magnitude of the high frequency DCT coeffs.

0 commit comments

Comments
 (0)