error in speech recogniion

2 次查看(过去 30 天)
I am working on speech recognition. I have completed the training session and created the database. Now for the testing session my code is giving the error
??? Index exceeds matrix dimensions.
Error in ==> readnewfile at 28
display(words(index,:))*
The code is as follows
clc
clear all
close all
load ('Database.mat')
% load ('AudioList.mat')
Datasize=size(Dataset);
[s1,fs] = wavread('wh1.wav'); % Reading new file x1.wav
B = [1 -0.95];
s1 = filter(B,1,s1);
[c]=melcepst(s1,fs);
n=corrcoef(c) ;% Finds the correlation coefficients
n=n(:);
n=n';
distance=zeros(1,5);
word1='Transmit';
word2='What ';
word3='Colour ';
word4='Computer';
words=vertcat(word1,word2,word3,word4);
for i=1:Datasize(1)
distance(1,i)=sqrt(sum((Dataset(i,:)-n(1,:)).^2));
end
[mindistance,index]=min(distance);
display('Detected word is ')
display(words(index,:))
Can someone plz guide me?
  2 个评论
Geoff Hayes
Geoff Hayes 2016-7-3
aliha - the error seems to suggest that index is greater than the number of rows in your matrix. What are the dimensions for words and for Dataset?
aliha wasim
aliha wasim 2016-7-3
my database has 4 words and size of Dataset is 4 X 169

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2016-7-3
You initialize
distance=zeros(1,5);
so distance will be at least of length 5 and will start out containing zeros. You then loop over i=1:Datasize(1) setting distance(i) . If Datasize(1) is less than 5 then you would be leaving a 0 untouched at index 5, and it is not possible that any distance is less than 0 so that 0 would be the minimum distance. If Datasize(1) is 5 or higher than you would be removing all of the 0 that you assigned but you run the risk that the minima is from 5 onwards. You use the index of the minima to index the 4 rows of words so if the index came back 5 or more that is going to fail.
  3 个评论
Walter Roberson
Walter Roberson 2016-7-3
Create a box with 5 drawers. Put objects in 4 of the drawers. Which drawer in the box has the fewest number of objects in it? Answer: the one you did not put any objects into.
Just change your
distance=zeros(1,5);
to
distance=zeros(1,4);
and try again.
aliha wasim
aliha wasim 2016-7-3
thanks a lot its working.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Speech Recognition 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by