Professional Documents
Culture Documents
Aim: Obtain Mel filterbank (triangular) and find out the MFCCs for the sample speech signal.
MATLAB Script :
%% MFCC coefficients
c1=-kb(l)*m1;
c2 = -kb(l+2)*m2;
elseif ((x>kb(l+1))&&(x<=kb(l+2)))
y(k)=m2*x+c2;
else
y(k)=0;
end
k=k+1; % Update the dft bin index
end
B(l,:)=y; % stores all filter op in bank B ; all row vectors of B gives
tringle filter
% C(l,:)=[fliplr(y),y(2:end-1)]; % Two sided filters
plot(f,B(l,:))
hold on;
pause;
axis tight; ylabel('Amplitude'), xlabel('Frequency')
end
%% Compute MFCC
[x, fs]=audioread('sample_male.flac');
win=floor(30*fs/1000); % Default window duration = 20 ms
inc=floor(win/2);
wintype='h';
% Framing and spectral analysis
y=enframe(x,win,inc)'; % Perform framing
NF=size(y,2); % Get number of frames
y1=zeros(1+NFFT/2,NF); % Preallocate the data vector to store the DFT
coefficients
for k=1:NF % For every frame
y_tmp=abs(fft(y(:,k),NFFT)); % Compute Magnitude spectrum
y1(1:end,k)=y_tmp(1:1+NFFT/2); % Take positive spectrum values % NFFT/2 X
NF
end
% Take Log
c=log((B*y1).^2);
Nc=10;
% Take DCT
cep=dct(c);
% mfcc1 = cep(1:Nc,:)'; % Nc x p
figure
plot(cep(:,1))
xlabel('No. of coefficients'); ylabel('Amplitude')