shumaila.iqbal
Newbie level 2

i have don with initial code of voice print. which can read voice and display its graph.now i want to impliment mfcc on this voice sample but hav problem in doing so..my codes are............
for voice print.......
-------------------------------------------------------
plzzzz help me how i can interrelate both of above codes
for voice print.......
Code:
function x;
%function FMatrix=mfccf(num,s,Fs)
Fs = 10000; % Sampling Frequency (Hz)
Nseconds = 5; % Length of speech signal
fprintf('say a word immediately after hitting enter: ');
input('');
x = wavrecord(Nseconds*Fs, Fs, 'int16'); % Recording the sound
wavplay(x,Fs); % Playing the recorded sound
ms20=Fs/50; % minimum speech Fx at 50Hz
ms1=Fs/1000; % maximum speech Fx at 1000Hz
t=(0:length(x)-1)/Fs; % times of sampling instants
subplot(2,1,1);
plot(t,x);
legend('Waveform');
xlabel('Time (s)');
ylabel('Amplitude');
------------------------------------------------------ and for mfcc
function FMatrix=mfccf(num,x,Fs)
%Fs=1000;
n=512; %Number of FFT points
Tf=0.025; %Frame duration in seconds
N=Fs*Tf; %Number of samples per frame
fn=24; %Number of mel filters
l=length(x); %total number of samples in speech
Ts=0.01; %Frame step in seconds
FrameStep=Fs*Ts; %Frame step in samples
a=1;
b=[1, -0.97]; %a and b are high pass filter coefficients
noFrames=floor(l/FrameStep); %Maximum no of frames in speech sample
FMatrix=zeros(noFrames-2, num); %Matrix to hold cepstral coefficients
lifter=1:num; %Lifter vector index
lifter=1+floor((num)/2)*(sin(lifter*pi/num));%raised sine lifter version
if mean(abs(s)) > 0.01
s=s/max(s); %Normalises to compensate for mic vol differences
end
%Segment the signal into overlapping frames and compute MFCC coefficients
for i=1:noFrames-2
frame=x((i-1)*FrameStep+1:(i-1)*FrameStep+N); %Holds individual frames
Ce1=sum(frame.^2); %Frame energy
Ce2=max(Ce1,2e-22); %floors to 2 X 10 raised to power -22
Ce=log(Ce2);
framef=filter(b,a,frame); %High pass pre-emphasis filter
F=framef.*hamming(N); %multiplies each frame with hamming window
FFTo=fft(F,N); %computes the fft
melf=melbankm(fn,n,Fs); %creates 24 filter, mel filter bank
halfn=1+floor(n/2);
spectr1=log10(melf*abs(FFTo(1:halfn)).^2);%result is mel-scale filtered
spectr=max(spectr1(:),1e-22);
c=dct(spectr); %obtains DCT, changes to cepstral domain
c(1)=Ce; %replaces first coefficient
coeffs=c(1:num); %retains first num coefficients
ncoeffs=coeffs.*lifter'; %Multiplies coefficients by lifter value
FMatrix(i, :)=ncoeffs'; %assigns mfcc coeffs to succesive rows i
end
%Call the deltacoeff function to compute derivatives of MFCC
%coefficients; add all together to yield a matrix with 3*num columns
d=(deltacoeff(FMatrix)).*0.6; %Computes delta-mfcc
d1=(deltacoeff(d)).*0.4; %as above for delta-delta-mfcc
FMatrix=[FMatrix,d,d1]; %concatenates all together
plzzzz help me how i can interrelate both of above codes
Last edited by a moderator: