Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [mfcc] = compute_mfcc(path)
- [wav,Fs,bits] = wavread(path)
- for i = 1:23248
- if i==1 then
- sof(i)=wav(i);
- else
- sof(i)=wav(i)-wav(i-1)+0.999*sof(i-1);
- end
- end
- logE = zeros(1,144);
- for j=0:143
- for i=1:400
- if(j*160+i <= length(sof)) then
- logE(j+1) = logE(j+1) + (sof(j*160+i))**2
- end
- end
- logE(j+1) = max(-50,log(logE(j+1)));
- end
- spe = zeros(1,23248);
- for i=1:23248
- if i==1 then
- spe(i) = sof(i)
- else
- spe(i) = sof(i) - 0.97*sof(i-1)
- end
- end
- hamming = window('hm',400)
- spec_rep = zeros(144,512);
- for i=0:143
- if(i*160+400>length(spe)) then
- spec_rep(i+1,:) = [conv([spe(i*160+1:length(spe)),zeros(1,400-length(spe)+(i*160))],hamming,'same'),zeros(1,112)]
- else
- spec_rep(i+1,:) = [conv(spe(i*160+1:i*160+400),hamming,'same'),zeros(1,112)]
- end
- spec_rep(i+1,:) = abs(fft(spec_rep(i+1,:)))
- end
- loadmatfile('C:\Users\freespace\Desktop\MFCC\mel_filters.mat')
- energy = zeros(144,23)
- for i=1:144
- energy(i,:) = spec_rep(i,1:257)*mel_filters
- end
- loadmatfile('C:\Users\freespace\Desktop\MFCC\gas_station_mfcc.mat')
- mfcc = zeros(14,144);
- mfcc(1,:) = logE
- for i=0:12
- for f=1:144
- for j=1:23
- mfcc(i+2,f) = mfcc(i+2,f) + max(-50,log(energy(f,j)))*cos(%pi*i/23*(j-1/2))
- end
- end
- end
- endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement