### mfcc feature
from __future__ import division
from python_speech_features import mfcc
from python_speech_features import logfbank
import scipy.io.wavfile as wav
import numpy as np
for i in range(0,65):
(rate,sig) = wav.read(/home/***/+'A2_'+str(i)+'.wav')
mfcc_feat = mfcc(sig,rate)
#logfeature=logfbank(sig,rate)
#print logfeature
tmp =0
for cnt in range(1,3):
tmp = tmp +cnt*cnt
nrm = 2*tmp
nrm=np.sqrt(nrm)
nrm=1.0/nrm
dt = np.zeros(np.shape(mfcc_feat))
rows =np.shape(mfcc_feat)[0]
cols = np.shape(mfcc_feat)[1]
for col in range(0,cols):
for cnt in range(1,3):
inx1 = col-cnt
inx2 = col+cnt
if inx1 <0 :
inx1 =col
int2=col+1
dt[:,col]=mfcc_feat[:,inx2]-mfcc_feat[:,inx1]
break
if inx2>=cols:
inx1=col-1
inx2 = col
dt[:,col]=mfcc_feat[:,inx2]-mfcc_feat[:,inx1]
break
dt[:,col] = dt[:,col]+(mfcc_feat[:,inx2]-mfcc_feat[:,inx1])*cnt*nrm
#c=dt[:,:]
#print dt[:,:]
mfcc_feat_tr=np.transpose(mfcc_feat)
dt_tr=np.transpose(dt)
mfcc_dt_tr=np.concatenate((mfcc_feat_tr,dt_tr),axis=0)
mfcc_dt_tr=np.array(mfcc_dt_tr,dtype=np.float32)
#print mfcc_dt_tr[0:13,0]
#print mfcc_dt_tr[13:26,0]
print(mfcc_dt_tr.shape)
np.save('/home/***/examples/data/feature/'+'A2_'str(i)+'wav.trn.npy',mfcc_dt_tr)
mfcc提取语音的mel倒谱系数及其一阶导数
最新推荐文章于 2024-08-10 07:14:51 发布