
Speech Recognition in MATLAB using Correlation

Correlation is normally used in signal processing, where you need to compare two signals and need to find the similarity between them. It is also known as the dot product of those two signals. Correlation has many uses and you can read more about it on its Wiki Page. Correlation is also used for pattern recognition like you want to find some pattern in the signal then you can use Correlation. Anyways, in our project, we are using correlation to find similarities between our stored signals and the testing signal. So, let's get started with Speech Recognition in MATLAB using Correlation.
Speech Recognition in MATLAB using Correlation
- First of all, download this complete project by clicking the below button:
- Now in this package, you will find nine audio wav files.
- Five of them are the recorded sounds that are already feed in MATLAB.
- Two are test files that will be recognized by the code.
- The remaining two are success and failure files which will run if you got the recognition or not.
- Let me explain the code a bit. First of all, what we need to do is to upload the first five training audio files in the software so and then we need to test these fives files with the test files and we need to check which one is a maximum match.
- Here's the complete code:
function speechrecognition(filename)
voice=wavread(filename);
x=voice;
x=x';
x=x(1,:);
x=x';
y1=wavread('one.wav');
y1=y1';
y1=y1(1,:);
y1=y1';
z1=xcorr(x,y1);
m1=max(z1);
l1=length(z1);
t1=-((l1-1)/2):1:((l1-1)/2);
t1=t1';
%subplot(3,2,1);
plot(t1,z1);
y2=wavread('two.wav');
y2=y2';
y2=y2(1,:);
y2=y2';
z2=xcorr(x,y2);
m2=max(z2);
l2=length(z2);
t2=-((l2-1)/2):1:((l2-1)/2);
t2=t2';
%subplot(3,2,2);
figure
plot(t2,z2);
y3=wavread('three.wav');
y3=y3';
y3=y3(1,:);
y3=y3';
z3=xcorr(x,y3);
m3=max(z3);
l3=length(z3);
t3=-((l3-1)/2):1:((l3-1)/2);
t3=t3';
%subplot(3,2,3);
figure
plot(t3,z3);
y4=wavread('four.wav');
y4=y4';
y4=y4(1,:);
y4=y4';
z4=xcorr(x,y4);
m4=max(z4);
l4=length(z4);
t4=-((l4-1)/2):1:((l4-1)/2);
t4=t4';
%subplot(3,2,4);
figure
plot(t4,z4);
y5=wavread('five.wav');
y5=y5';
y5=y5(1,:);
y5=y5';
z5=xcorr(x,y5);
m5=max(z5);
l5=length(z5);
t5=-((l5-1)/2):1:((l5-1)/2);
t5=t5';
%subplot(3,2,5);
figure
plot(t5,z5);
m6=300;
a=[m1 m2 m3 m4 m5 m6];
m=max(a);
h=wavread('allow.wav');
if m<=m1
soundsc(wavread('one.wav'),50000)
soundsc(h,50000)
elseif m<=m2
soundsc(wavread('two.wav'),50000)
soundsc(h,50000)
elseif m<=m3
soundsc(wavread('three.wav'),50000)
soundsc(h,50000)
elseif m<=m4
soundsc(wavread('four.wav'),50000)
soundsc(h,50000)
elseif m<m5
soundsc(wavread('five.wav'),50000)
soundsc(h,50000)
else
{soundsc(wavread('denied.wav'),50000)}
end
- Now if you read the code from start then you can see, first of all, I uploaded the test file which I want to compare with my samples.
- After that, I uploaded all 5 samples and also get their correlation with the test sample.
- Finally, in the end, I compared the results and on the basis of it I figured out which one is the correct speech file.
- You will also get spectrum graphs of your sound files as shown in the below figure:
- It was quite an easy project and I have done it within half an hour and I hope you guys will understand.
- If you got any problems then ask in the comments and I will resolve them.
- Here's the complete video demonstration for this project and I hope it's going to help you out in understanding it.
It is showing "audioread returns empty waveforms, problem reading file"
What is the filename to be given in that function parameters
ashwinwin1997@Gmail.com
I got this error. Please help me in this matter.
Error in ==> speechrecognition at 5
voice=wavread(filename);
Dear sir i am getting problem in comping the speech recognition code kindly resolve it sir
??? Undefined function or variable 'x'.
??? Error using ==> run at 56
Input argument "filename" is undefined.
I also got this error. Please help me in this matter.
Error in ==> speechrecognition at 5
voice=wavread(filename);
how to rectify this
Thank you for sharing the code.
I would like to add some extra features
Can you suggest some ideas?
1 reply
did the code work for you?
The denied code is not working. When I give a file not part of test file, the denied line 88, getting 'too many output arguments' as error. Can you please explain that part?
1 reply
You need to change the waveread function to audioread
soundsc(wavread('denied.wav'),50000)
i want to know that what is 50000 ????? if it is sample rate then how it is same?? plz help men i am working on speech to text recognition anybody wants to help me?
sir i can get documentation of this project?
Dear sir,i got an error regarding speech recognition using correlation.Would you please help me out?
Error in ==> speechrecognition at 5
voice=wavread(filename)
Sir, how to upload the files to check ? Can u plz tel sir.
1 reply
Just click on "speechrecognition.m" file
And obviously an installed MATLAB is required as well
error is like Undefined function or variable 'speechrecognition'.
how it is to be solved?? plz suggest me..
Sir I'm doing a project on audio encoder and decoder.
I need a program two compare the quality (in terms of error or similarity or difference) of wav files before and after encoding.
Please help...
Thank You.... Waiting for your reply
Hello. I receive an error in line 5.
" >> speechrecognition
Not enough input arguments.
Error in speechrecognition (line 5)
voice=audioread(filename); "
Could anyone help?
1 reply
I think problem is with your MATLAB version. I have tested it on MATLAB 2009 and it worked fine.
2 replies
can u tell me how to input arguments in line 5
i have the latest version and it is not working. Having same error in line 5
Good afternoon sir,
My research is in speech enhancement. Can you suggest me how the noisy speech can be enhanced using DNN in matlab. Do u have any sample code for this speech enhancement using DNN?
Dear Sir,
Can you please reply me why did you do the following
x=x';
x=x(1,:);
x=x';
in line 4,5,6 respectively.
Thanks in advance
1 reply
what is the explanation ? did u get any reply from them ? can u please explain those three lines?
HELLO SIR I HAVE ONE ERROR LIKE THAT
Error using speechrecognition (line 5)
Not enough input arguments.
Dear Sir,
Can you please reply me why did you do the following
x=x’;
x=x(1,:);
x=x’;
in line 4,5,6 respectively.
Hello
For every voice signal, you used transpose and I didn't understand why it is necessary. After the transpose you took the one channel of the signal, then took the transpose again. I didn't understand these lines of this code and I tried to uploud my voice which is saved as .m4a , but I got an error. Please, can you explain for me how can I uploud my voice and what does these lines used for?
Can you answer urgently, i have an assignment.
Thankss
hi sir
do you have any code for speech recognition? only for one person?
it mean's that's work for one person
for high security
Not enough input arguments.
Error in speechrecognition
voice=wavread(filename);
How to fix this error?
Hi
Please can you tell me how can I use this code to be able to do the speech recognition using real-time audio?
I have tried so many, and I did a lot of changes still cannot figure it out. I added fft(x), fft(y1), ... etc. still did not work, it takes any audio and detects it as the same word such as three all the time. I have added abs(x), abs(y1) to the xcorr but still not luck.
Any help regarding this it will be really appreciated since I have a university project and I need to do speech recognition.
you can send me your reply on my email: tannous_lina@hotmail.com
thanks in advance!

























Comments
39