www.pudn.com > LBG_GA.rar > mfcc.m, change:2011-05-13,size:711b


function r = mfcc(s, fs,k) 
%% 
% clear all 
% clc 
% s=wavread('cby0.wav',32000); 
fs=8000; 
m = 100; 
n = 256; 
l = length(s); 
% s=pret(s); 
nbFrame = floor((l - n) / m) + 1; 
M=zeros(n,nbFrame); 
for i = 1:n 
    for j = 1:nbFrame 
        M(i, j) = s(((j - 1) * m) + i); 
    end 
end 
h = hamming(n);                           %diag(h)生成以h为对角元素的矩阵,其余是0                                
M2 = diag(h) * M;                         %M2实际上是取出了M的对角元素,但是经过汉明窗处理  
frame=zeros(n,nbFrame); 
for i = 1:nbFrame 
    frame(:,i) = fft(M2(:, i)); 
end 
t = n / 2; 
tmax = l / fs; 
m = melfb(k, n, fs); 
n2 = 1 + floor(n / 2); 
z = m * abs(frame(1:n2, :)).^2; 
r = dct(log(z)); 
% end