mfcc提取语音的mel倒谱系数及其一阶导数

### 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)


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值