Saturday, January 1, 2011

Speech Recognition Using Correlation

Correlation represents the similarities between the two signals. Here I use Correlation to recognize the uttered word (Expecially in the same voice).
First of all have to record the uttered word, sample it and save in a wav file and use this function to check whether it has already in the database.
Fs is the sampling frequency.

function speechRecog_corr(filename)

voice=wavread(filename); % READ THE FILE
x=voice;
x=x';
x=x(1,:); % GET THE FIRST RAW
x=x';

y1=wavread('test1.wav');
y1=y1';
y1=y1(1,:);
y1=y1';
z1=xcov(x,y1); % FIND THE COVARIANCE
m1=max(z1);

y2=wavread('test2.wav');
y2=y2';
y2=y2(1,:);
y2=y2';
z2=xcov(x,y2);
m2=max(z2);

y3=wavread('test3.wav');
y3=y3';
y3=y3(1,:);
y3=y3';
z3=xcov(x,y3);
m3=max(z3);

y4=wavread('test4.wav');
y4=y4';
y4=y4(1,:);
y4=y4';
z4=xcov(x,y4);
m4=max(z4);

y5=wavread('test5.wav');
y5=y5';
y5=y5(1,:);
y5=y5';
z5=xcov(x,y5);
m5=max(z5);

m6=5; % SET THE REFERENCE
a=[m1 m2 m3 m4 m5 m6];
m=max(a); % GET THE MAXIMUM CORRELATION

if m<=m1
    soundsc(wavread('test1.wav'),Fs) % PLAY THE FILE
        elseif m<=m2
    soundsc(wavread('test2.wav'),Fs)
        elseif m<=m3
    soundsc(wavread('test3.wav'),Fs)
        elseif m<=m4
    soundsc(wavread('test4.wav'),Fs)
        elseif m<=m5
    soundsc(wavread('test5.wav'),Fs)
        else % IF NOT ALREADY KNOWN WORD
soundsc(wavread('denied.wav'),Fs) 
end

No comments:

Post a Comment