Info
This question is closed. Reopen it to edit or answer.
Can some one tell me whats wrong with this code. Its very urgent. Thank you.
1 view (last 30 days)
Show older comments
Speech Recognition from file
if chos==3,
clc;
[namefile,pathname]=uigetfile('*.wav;*.au','Select a new sound');
if namefile~=0
pos = strfind(namefile,'.');
ext = namefile(pos+1:end);
if strcmp(ext,'au')
[y,Fs,bits] = auread(strcat(pathname,namefile));
end
if strcmp(ext,'wav')
[y,Fs,bits] = wavread(strcat(pathname,namefile));
end
% if the input sound is not mono
if size(y,2)==2
y=y(:,1);
end
disp('Sound selected for recognition:');
message=strcat('File:',namefile);
disp(message);
message=strcat('Location:',pathname);
disp(message);
else
warndlg('Input sound must be selected.',' Warning ')
end
if (exist('sound_database.dat')==2)
load('sound_database.dat','-mat');
if (Fs ~= samplingfrequency) || (bits ~= samplingbits)
warndlg('Sampling parameters do not match with parameters already present in database',' Warning ')
else
%----- code for speech recognition -------
vettore_pesi = zeros(sound_number,1);
D1 = specgram(y,512,Fs,512,384);
disp('Database scanning...');
for ii=1:sound_number
D2 = specgram(data{ii,1},512,Fs,512,384);
SM = syms(abs(D1),abs(D2));
%[p,q,C] = dp(1-SM);
[p,q,C] = dpfast(1-SM);
peso = C(size(C,1),size(C,2));
vettore_pesi(ii) = peso;
message=strcat('Sound #',num2str(ii));
disp(message);
end
[min_value,min_index] = min(vettore_pesi);
speech_id = data{min_index,2};
%-----------------------------------------
disp('Matching sound:');
message=strcat('File:',data{min_index,4});
disp(message);
message=strcat('Location:',data{min_index,3});
disp(message);
message = strcat('Recognized speech ID: ',num2str(speech_id));
disp(message);
msgbox(message,'Matching result','help');
end
else
warndlg('Database is empty. No matching is possible.',' Warning ')
end
end
2 Comments
Image Analyst
on 25 Apr 2014
Well just off the top of my head I'd say it's "wrong" because it doesn't work - it doesn't do what you want. That's about all we can say considering what you've given us to work with. Please read this before you respond again: http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer
Answers (2)
Walter Roberson
on 25 Apr 2014
Your code does not contain that line. Your code contains a call to syms() not a call to simmx().
syms() does not return any values, and must be passed names, not values.
Your code should probably use
SM = sym([abs(D1),abs(D2)]);
Note that this requires the Symbolic Toolkit.
dpfast() does not appear to be a Mathworks supplied routine, so I have no idea why it wants a symbolic array.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!