Spech Recognation using Mfcc for Security

|i have project. to make security sistem for home using mfcc method in MATLAB.. one voice (sample .wav) would become database...
please help.... spyjaya@gmail.com
this is my work.. please download and help to find the error.. thanks

7 Kommentare

Daniel Shub
Daniel Shub am 27 Sep. 2012
I am closing this question since it is a clear doit4me homework type problem. Please add what you have tried and where you are stuck.
this is my work
clear;clc;close all; pc = 60; p=[0 0 0 1 0 1 1 1 0 1 1 1 0 1 1 1 0 0 0 1 0 0 0 1 1 0 0 0 0 0 0 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 0 1 1 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 0 1 1 0 0 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 0 1 1 1 0 1 1 1 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 0 1 1 1 0 0 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 1 0 1 1 1 0 1 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 0 1 1 1 0 0 1 1 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 1 0 0 1 1 0 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 0 0 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 0 1 0 0 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 0 1 0 0 0 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 0 1 1 1 0 1 1 1 0 0 1 0 0 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 0 0 1 1 1 0 0 1 0 0 0 0 0 0 0 0 1 1 0 1 1 1 0 0 1 1 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 1 0 0 1 1 0 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 0 1 0 0 0 1 1 0 0 1 1 0 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 0 1 0 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 1 1 0 1 1 1 0 0 0 1 0 0 0 0 0 0 0 1 1 0 1 1 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0 1 0 1 0 1 0 0 0 0 1 1 0 0 1 0 0 1 1 0 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 1 0 0 1 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 1 1 0 0 0 1 0 0 0 0 1 0 0 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 0 1 1 0 0 1 1 0 0 0 0 1 0 0 0 1 0 1 1 1 0 1 1 1 0 1 1 1 0 0 0 1 0 1 0 1 0 0 0 0 1];
file1 = uigetfile ('*.wav'); % mengambil file wav [y1,x1] = wavread (file1); %sound(y1); % untuk membaca file wav
%Mengubah sinyal suara dalam sampling ke dalam domain waktu y11 = y1(1:12000,1) t1 = 0:length(y11)/x1:1; t1 = 0:1.5/length(y11)-1:1.5; t1 = 0:1.5/length(y11):1.5; t1 = t1(1,1:end-1);
%Perintah untuk desain filter BPF N=10;fs=24000;fp1=2000;fp2=10000; [b,a] =ellip(N,0.5,2,[fp1 fp2]/(fs/2)); [e,f]=freqz(b,a,1024);
%perintah untuk memfilter sinyal suara z1 = filter(b,a,y11);
% set parameter decimate n = 10; %hanya diambil 1/10 sampel
% Hitung decimate g1 = decimate(z1,n);
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Untuk menampilkan magnitude tiap inputan display (y11); % input1 = amplitude %untuk menampilkan gambar sinyal suara figure subplot (2,1,1);plot(t1,y11); title('Bentuk Sinyal suara dengan Fs 9500Hz'); xlabel('Time (sec)'); ylabel('Amplitude');grid on subplot (2,1,2); plot(y11);title('Bentuk Sinyal suara dengan Fs 9500Hz'); xlabel('sample'); ylabel('Amplitude');grid on %perintah untuk menampilkan gambar filter figure plot(f/pi*(fs/2),abs(e)); title ('Band Pass Filter');grid %perintah menampilkan sinyal hsil filter figure plot (z1); title ('Sinyal suara setelah di filter');grid xlabel('sample');ylabel('Amplitude') %Tampilkan sinyal hasil BPF kontinu, diskrit, dan hasil decimate figure subplot (2,1,1); stem(g1); title('Decimated Signal1');grid xlabel('sample');ylabel('Amplitude'); subplot (2,1,2); plot(g1); title('Decimated Signal1');grid xlabel('sample');ylabel('Amplitude'); figure stem(z1);xlabel('sample');ylabel('Amplitude');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Ambil input dari hasil desimasi in1=g1; alpha=1/sqrt(2); z=1;i=1;m=1;k=1;l=1;
% Hitung ekstraksi ciri berdasarkan rumus MFCC for ii = 1:size(Letters,2); for jj = 1:size(Users,2); for kk = 1:NoOfSamples file_name = strcat(Users(jj),'_',Letters(ii),int2str(kk)); Samples = eval(char(file_name)); zz = find(Samples) < max(Samples/3);%Threshold speech regions Samples(zz) = 0; zz = find(Samples); Speech_Region = Samples(zz)/norm(Samples(zz)); WindowSize = floor((size(Speech_Region,1))/(NoOfWindows+1)); ww = 0; for ll = 0:OverlapSize:(NoOfWindows-1)/2 bb = Speech_Region(floor(ll*WindowSize)+1:floor(ll*WindowSize)+WindowSize).*hamming(WindowSize); fb = fft(bb); mb = 1000 * log10(1 + fb./8000); mfout = dct(log(abs(mb)),NoOfFilters); MFCC(ii,kk,ww*NoOfFilters+1:ww*NoOfFilters+NoOfFilters) = mfout; ww = ww + 1; end end end end
%% Perform Gaussian Modelling for MFCC Windows = size(mfcc,3); tempStorage = zeros(size(Users,2)*NoOfSamples,Windows); tempStorage(:,:) = mfcc(1,:,:); obj_A = gmdistribution.fit(tempStorage,1,'Regularize',0.01); tempStorage(:,:) = mfcc(2,:,:); obj_B = gmdistribution.fit(tempStorage,1,'Regularize',0.01); tempStorage(:,:) = mfcc(3,:,:); obj_C = gmdistribution.fit(tempStorage,1,'Regularize',0.01); tempStorage(:,:) = mfcc(4,:,:); obj_Five = gmdistribution.fit(tempStorage,1,'Regularize',0.01); tempStorage(:,:) = mfcc(5,:,:); obj_Point = gmdistribution.fit(tempStorage,1,'Regularize',0.01); tempStorage(:,:) = mfcc(6,:,:); obj_V = gmdistribution.fit(tempStorage,1,'Regularize',0.01);
for ii = 1:size(Letters,2); for jj = 1:size(Users,2); for kk = 1:NoOfTestSamples %% Extract MFCC for test data InputIn = strcat(Users(jj),'_',Letters(ii),int2str(kk)); Samples = eval(char(InputIn)); zz = find(Samples) < max(Samples/3);%Threshold speech regions Samples(zz) = 0; zz = find(Samples); Speech_Region = Samples(zz); mfcc_test = zeros(1,MFCCNo); WindowSize = floor((size(Speech_Region,1))/(NoOfWindows+1)); ww = 0; for ll = 0:OverlapSize:(NoOfWindows-1)/2 bb = Speech_Region(floor(ll*WindowSize)+1:floor(ll*WindowSize)+WindowSize).*hamming(WindowSize); fb = fft(bb); mb = 2595 * log10(1 + fb./700); mfout = dct(log(abs(mb)),NoOfFilters); mfcc_test(1,ww*NoOfFilters+1:ww*NoOfFilters+NoOfFilters) = mfout; ww = ww + 1; end %% Classify MFCC test data on Mahanalobis distance D1(1) = mahal(obj_A,mfcc_test); D1(2) = mahal(obj_B,mfcc_test); D1(3) = mahal(obj_C,mfcc_test); D1(4) = mahal(obj_Five,mfcc_test); D1(5) = mahal(obj_Point,mfcc_test); D1(6) = mahal(obj_V,mfcc_test); [m Ind] = min(D1); if(Ind == ii) MFCCCorrect_Test(jj,ii) = MFCCCorrect_Test(jj,ii) + 1; end end end end
% inisialisasi output sebagai vector ciri
vektorciri=outfil6;
% plot vector ciri figure plot (vektorciri); title ('Vektor ciri Suara'); hold off xlabel('vektor ciri ke-n');ylabel('ekstraksi ciri')
%program normalisasi dan pengkodean %normalisasi vektorciri v1=max(vektorciri); vektorciri=vektorciri./v1 for i=1:24 if vektorciri(i)>0.49 vektorciri(i)=1 else vektorciri(i)=0 end end disp(vektorciri);
% Nilai fitnes for i=1:25 nilaifitnes1=0; for j=1:24 if vektorciri(j)== p(i,j) nilaifitnes1=nilaifitnes1+1; end end nilaifitnes(i)=nilaifitnes1/24*100; end
bestfitnes=max(nilaifitnes);
generate=0;
%kriteria terministik disp(nilaifitnes); %probabilitas kumuatif totalfitnes=0;
for i=1:25 totalfitnes=nilaifitnes(i)+totalfitnes; end
probabilitaskumulatif(25)=0;
probabilitaskumulatif(1)=(nilaifitnes(1)*100/totalfitnes); for j=2:25 probabilitaskumulatif(j)=(nilaifitnes(j)*100/totalfitnes) + probabilitaskumulatif(j-1); end disp(probabilitaskumulatif);
while ( bestfitnes < 98 )&( generate < 10000 )
%Fungsi seleksi for o=1:30; putar=randperm(100); seleksi=putar(1); seleksi=seleksi+probabilitaskumulatif(1); t=0; for t=1:25; if probabilitaskumulatif(t) <= seleksi for k=1:29; induk(o,k)=p(t,k); end end end end
%susun induk u=0; for i=1:30 if induk(i,25)==1; u=u+1; for l=1:29 induk1(u,l)=induk(i,l); end end end for i=1:30 if induk(i,26)==1; u=u+1; for l=1:29 induk1(u,l)=induk(i,l); end end end
for i=1:30 if induk(i,27)==1; u=u+1; for l=1:29 induk1(u,l)=induk(i,l); end end end
for i=1:30 if induk(i,28)==1; u=u+1; for l=1:29 induk1(u,l)=induk(i,l); end end end
for i=1:30 if induk(i,29)==1; u=u+1; for l=1:29 induk1(u,l)=induk(i,l); end end end
%cross over for i=1:29 a=randperm(100); probabilitascrossover=a(50); if probabilitascrossover < pc b=randperm(29); titik=b(14); for k=1:titik offspring(i,k)=induk1(i+1,k); offspring(i+1,k)=induk1(i,k); end
for k=titik:29
offspring(i+1,k)=induk1(i+1,k);
offspring(i,k)=induk1(i,k);
end
else
for k=1:29
offspring(i,k)=induk1(i,k);
offspring(i+1,k)=induk1(i+1,k);
end
end
i=i+2;
end
for i=1:30 nilaifitnes1=0; for j=1:24 if vektorciri(j)== offspring(i,j) nilaifitnes1=nilaifitnes1+1; end end nilaifitnes(i)=nilaifitnes1/24*100; end bestfitnes=max(nilaifitnes); generate=generate+1; end
ANDI RiskiWijaya
ANDI RiskiWijaya am 4 Okt. 2012
how to attach file???
Walter Roberson
Walter Roberson am 4 Okt. 2012
A sample input .wav file might turn out to be useful to us, but not until the code is formatted to be readable.
ANDI RiskiWijaya
ANDI RiskiWijaya am 4 Okt. 2012
this is my work.. please help me correcly... thanks
Walter Roberson
Walter Roberson am 4 Okt. 2012
In particular, you need to describe what error message you are encountering and show the traceback.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Signal Processing finden Sie in Hilfe-Center und File Exchange

Produkte

Tags

Gefragt:

am 27 Sep. 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by