示例#1
0
 def mfcc(self, input):
     fb = get_filterbanks(24,256)
     db = dct_matrix(300,24)
     input_reshape = input.flatten(2)
     x_fft = T.abs_(fftabs(input_reshape,256,1)[:,:129]) ** 2
     x_mel= T.dot(x_fft,fb.T)
     x_logmel = T.log(x_mel)
     x_mfcc = db*x_logmel
     return x_mfcc
示例#2
0
import numpy as np
import theano.tensor as T
from theano.sandbox.fourier import *

from code.utils.features import get_filterbanks
import ipdb
import matplotlib.pyplot as plt

nfilters=24
x = T.matrix('x')
#fb = get_filterbanks(24,256)
#x_mel= T.dot(fft(x,256,1)[:,:129],fb.T)
#x_logmel = T.log(x_mel)
#x_mfcc = dct_matrix(10,24)*x_logmel

fb = get_filterbanks(24,256)
x_fft=T.abs_(fft(x,x.shape[1],1)[:,:x.shape[1]/2+1]) ** 2
x_mel= T.dot(x_fft,fb.T)
x_logmel = T.log(x_mel)
x_mfcc = dct_matrix(10,24)*x_logmel

get_fft = theano.function([x],x_mfcc)

ndata=10

sin_template=1*np.sin(np.arange(256)/5.)
sinc_template=1*np.sinc(np.arange(256)/5.)
rect_template=sin_template
rect_template[rect_template>0]=1
rect_template[rect_template<=0]=-1