Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Speaker Recognition using neural networks

  • Author iVenky
  • Create date
  • Updated
  • Blog entry read time 6 min read
(Speaker and speech recognition follow the same principle. So you can change this code to suit to your wish)



I see that many of you are asking code for speaker recognition. I have used mfcc for feature extraction and neural networks for pattern recognition. Here's the code
Code:
load dad
load 20amma
load venkatraman
load present
fs=44100;
v1=melcepst(venky1,fs);
v2=melcepst(venky2,fs);
v3=melcepst(venky3,fs);
v4=melcepst(venky4,fs);
v5=melcepst(venky5,fs);
v6=melcepst(venky6,fs);
v7=melcepst(venky7,fs);
v8=melcepst(venky8,fs);
v9=melcepst(venky9,fs);
v10=melcepst(venky10,fs);
v11=melcepst(venky11,fs);
v12=melcepst(venky12,fs);
v13=melcepst(venky13,fs);
v14=melcepst(venky14,fs);
v15=melcepst(venky15,fs);
v16=melcepst(venky16,fs);
v17=melcepst(venky17,fs);
v18=melcepst(venky18,fs);
v19=melcepst(venky19,fs);
v20=melcepst(venky20,fs);
a1=melcepst(amma1,fs);
a2=melcepst(amma2,fs);
a3=melcepst(amma3,fs);
a4=melcepst(amma4,fs);
a5=melcepst(amma5,fs);
a6=melcepst(amma6,fs);
a7=melcepst(amma7,fs);
a8=melcepst(amma8,fs);
a9=melcepst(amma9,fs);
a10=melcepst(amma10,fs);
a11=melcepst(amma11,fs);
a12=melcepst(amma12,fs);
a13=melcepst(amma13,fs);
a14=melcepst(amma14,fs);
a15=melcepst(amma15,fs);
a16=melcepst(amma16,fs);
a17=melcepst(amma17,fs);
a18=melcepst(amma18,fs);
a19=melcepst(amma19,fs);
a20=melcepst(amma20,fs);
f1=melcepst(dad1,fs);
f2=melcepst(dad2,fs);
f3=melcepst(dad3,fs);
f4=melcepst(dad4,fs);
f5=melcepst(dad5,fs);
f6=melcepst(dad6,fs);
f7=melcepst(dad7,fs);
f8=melcepst(dad8,fs);
f9=melcepst(dad9,fs);
f10=melcepst(dad10,fs);
f11=melcepst(dad11,fs);
f12=melcepst(dad12,fs);
f13=melcepst(dad13,fs);
f14=melcepst(dad14,fs);
f15=melcepst(dad15,fs);
f16=melcepst(dad16,fs);
f17=melcepst(dad17,fs);
f18=melcepst(dad18,fs);
f19=melcepst(dad19,fs);
f20=melcepst(dad20,fs);
sri1=melcepst(y1,fs);
sri2=melcepst(y2,fs);
sri3=melcepst(y3,fs);
sri4=melcepst(y4,fs);
sri5=melcepst(y5,fs);
sri6=melcepst(y6,fs);
sri7=melcepst(y7,fs);
sri8=melcepst(y8,fs);
sri9=melcepst(y9,fs);
sri10=melcepst(y10,fs);

v1=v1(:);
v2=v2(:);
v3=v3(:);
v4=v4(:);
v5=v5(:);
v6=v6(:);
v7=v7(:);
v8=v8(:);
v9=v9(:);
v10=v10(:);
v11=v11(:);
v12=v12(:);
v13=v13(:);
v14=v14(:);
v15=v15(:);
v16=v16(:);
v17=v17(:);
v18=v18(:);
v19=v19(:);
v20=v20(:);
a1=a1(:);
a2=a2(:);
a3=a3(:);
a4=a4(:);
a5=a5(:);
a6=a6(:);
a7=a7(:);
a8=a8(:);
a9=a9(:);
a10=a10(:);
a11=a11(:);
a12=a12(:);
a13=a13(:);
a14=a14(:);
a15=a15(:);
a16=a16(:);
a17=a17(:);
a18=a18(:);
a19=a19(:);
a20=a20(:);
f1=f1(:);
f2=f2(:);
f3=f3(:);
f4=f4(:);
f5=f5(:);
f6=f6(:);
f7=f7(:);
f8=f8(:);
f9=f9(:);
f10=f10(:);
f11=f11(:);
f12=f12(:);
f13=f13(:);
f14=f14(:);
f15=f15(:);
f16=f16(:);
f17=f17(:);
f18=f18(:);
f19=f19(:);
f20=f20(:);
sri1=sri1(:);
sri2=sri2(:);
sri3=sri3(:);
sri4=sri4(:);
sri5=sri5(:);
sri6=sri6(:);
sri7=sri7(:);
sri8=sri8(:);
sri9=sri9(:);
sri10=sri10(:);


input=[ v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12 v13 v14 v15 v16 v17 v18 v19 v20 f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19 f20 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 sri2 sri3 sri4 sri5 sri7 sri8 sri9 sri10];
target=[ 1 0 0 0;1 0 0 0;1 0 0 0;1 0 0 0;1 0 0 0;1 0 0 0;1 0 0 0;1 0 0 0;1 0 0 0;1 0 0 0;1 0 0 0;1 0 0 0;1 0 0 0;1 0 0 0;1 0 0 0;1 0 0 0;1 0 0 0;1 0 0 0;1 0 0 0;1 0 0 0;
         0 1 0 0;0 1 0 0;0 1 0 0;0 1 0 0;0 1 0 0;0 1 0 0;0 1 0 0;0 1 0 0;0 1 0 0;0 1 0 0;0 1 0 0;0 1 0 0;0 1 0 0;0 1 0 0;0 1 0 0;0 1 0 0;0 1 0 0;0 1 0 0;0 1 0 0;0 1 0 0;
         0 0 1 0;0 0 1 0;0 0 1 0;0 0 1 0;0 0 1 0;0 0 1 0;0 0 1 0;0 0 1 0;0 0 1 0;0 0 1 0;0 0 1 0;0 0 1 0;0 0 1 0;0 0 1 0;0 0 1 0;0 0 1 0;0 0 1 0;0 0 1 0;0 0 1 0;0 0 1 0;
         0 0 0 1;0 0 0 1;0 0 0 1;0 0 0 1;0 0 0 1;0 0 0 1;0 0 0 1;0 0 0 1;];
 target=target';

Note: download the some speech processing functions that I have used from this link

https://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html




In the following code
dad, 20amma, venkatraman, present are the variable files (.mat files) each containing ten variables (i.e. Each person spoke the word "hello" ten times). If you stick to one word (in my case "hello") you should always stick to that word or else speaker recognition might not work 100%. I asked each of them to pronounce "hello" ten times and I recorded it in ten variables for every person. I saved those variables in 4 files each belonging to a particular person. Note that this code will not work without saving those variables containing the sound. If you know about the commands "save" and "load", you will know what I am saying. If you don't know about those commands learn from the Matlab tutorials and try those commands. The thing is I saved those variables such as venky1, venky2 etc. in those .mat files(dad, 20amma,venkatraman, present). If you wish to change the names of those variables and .mat files you can. This code is only for a sample and it will not work unless you save those variables with the same name as I have given in this code. If you change the name of the variables then you will have to change the names of the variables ( such as venky1 etc) in the code too. If you still can't understand what I am trying to say, then you have to learn about the basic things in MATLAB.

Next part is the neural network part. You train the neurons for these test inputs. No need to worry about neural networks because you have Pattern recognition dialog box in Matlab. In that you have to select input and target. Here the variables "input" and "target" specify the input and target that you should give in that Pattern recognition dialog box. If you have doubts in using neural networks toolbox ask in Matlab Central and see some videos in you tube or some other website. I have sent the code separately because I can't type more than 5000 letters in private messages. (Don't forget you have to record voices and store those variables in files like I did and then perform the speaker recognition part. If you have doubts in recording and storing in a separate file ask in Matlab Central. That's the best place for queries related to matlab).



After training those neurons, when those people said "hello" once again Neural Network found the exact person who was saying it. It worked 100% sometimes and sometimes it worked about 50% but didn't go below that. Speech processing is one of the fields where we are still not able to produce accurate results because of our voice characteristics.

Do you know that your voice change everyday and sometimes every second!. I experienced this while I was doing this project. It's necessary that you and other people should not change the way they say that word (eg: "hello") while testing the project. But the thing is that it worked perfectly if you don't change the way you speak. I forgot to tell you this-if you don't get accurate results increase the no of input variables to the neural networks. It will work then. Did you see that I have used 10 samples for every person? Only then you will get accurate results. If you have doubts related to neural networks ask in Matlab Central.
All the best.

Comments

amida;bt1787 said:
Hi iVenky,
May I know how did you define the Fs?

Thanks a lot,

It's the sampling frequency. As you can see from the code I have assigned fs=44100.
 
iVenky;bt1791 said:
It's the sampling frequency. As you can see from the code I have assigned fs=44100.

Thanks iVenky, I can see the fs=44100 . Actually I need to know how can we assigned the numbers?is it just put any number? I am sorry I still new in this field. Really need some advice from you.
 
Hi Ivenky, one more thing I need to ask, I can see that you used the melcepst in your coding. I tried to find the function in the Matlab but it doesn't exist. Can you help me with this? Thanks a lot
 
Hi iVenky
Than you for the link. Can you help me in testing the sound. I have 10 examples of gunshot and 5 various sound. I took the spectrogram of it. The input of the NN is the matrix value of the spectrogram. Now I have to test any sound whether it is a gunshot or random sound. Can you please help me with the testing part of the NN.
 
I really need help in this code as i am new to this, i tried this with other data files but it gives me error.
Thanks in advance
 
hi iVenky thank you so much for the code, can you please send me the complete code along with the data.my mail id is "krishnasatish2007@gmail.com"
 

Part and Inventory Search

Blog entry information

Author
iVenky
Read time
6 min read
Views
1,645
Comments
11
Last update

More entries in Uncategorized

More entries from iVenky

Share this entry

Back
Top