mfcc1.m
上传用户:shjsjz
上传日期:2022-07-09
资源大小:3k
文件大小:1k
- function m = mfcc1(x,dim)
- % 8khz
- %归一化mel滤波器组系数
- framelen = 256; %帧长
- frameinc = 80; %帧移
- banknum = dim; %滤波器组数
- fs = 8000; %采样频率
- %dim = 40; %输出系数的维数的0.5倍
- bank=melbankm(banknum,framelen,fs,0,0.5,'m');
- bank=full(bank);
- bank=bank/max(bank(:));
- % DCT系数,12*24
- for k=1:dim
- n=0:banknum-1;
- dctcoef(k,:)=cos((2*n+1)*k*pi/(2*banknum));
- end
- % 归一化倒谱提升窗口
- w = 1 + 6 * sin(pi * [1:dim] ./ dim);
- w = w/max(w);
- % 预加重滤波器
- xx=double(x);
- xx=filter([1 -0.9375],1,xx);
- % 语音信号分帧
- xx=enframe(xx,framelen,frameinc);
- % 计算每帧的MFCC参数
- for i=1:size(xx,1)
- y = xx(i,:); %取一帧语音信号(长256)
- s = y' .* hamming(framelen);%加海明窗
- t = abs(fft(s));%FFT
- t = t.^2; %每一个分量平方
- c1=dctcoef * (bank * t(1:framelen/2+1));%乘mel滤波器组系数,取对数,乘DCT系数
- c2 = c1.*w'; %加倒谱提升窗口
- m(i,:)=c2';
- end