Code created by me does not display the right answer. What needs to be changed in order for the code to provide the good answers?
Afficher commentaires plus anciens
Ok,so I wanted to create a code which recognizes which vowel is pronounced in a recording. I created a database consisting in 40 recordings per each vowel. Here you can find the database: https://we.tl/GB4fZzmhwC Q is the vector which contains the recording I select to compare with the others using k-nn classifier.
Unfortunately I am not getting the expected results which would be: 'closest recording is:41, second closest recording is:42,third closest recording is:43, fourth closest recording is:44, fifth closest recording is:45 vowel is e' as I chose Q(the recording I compare with all others in the database) to be the first recording from the e pronunciations folder in this line of code:"Q=wavread(sprintf('e/1.wav'));"
Note that I attached the database with the pronunciations in this link https://we.tl/GB4fZzmhwC as it was bigger than 5 MB.The main program was attached with paperclip and it's named main2_english.m
9 commentaires
Geoff Hayes
le 14 Mai 2016
Modifié(e) : Geoff Hayes
le 14 Mai 2016
Nicoleta - rather than pasting code into your question, please attach the m file (and database) using the paperclip button. A first glance at the code suggests that it may not run (see all the repeated end statements after each if/elseif block). Perhaps this is just the way that it was formatted.
Also, you mention that you don't get the expected results. What results do you get? Do you observe any errors, and if so, what are they? What do you expect to happen?
Please comment your code as well since it is difficult to follow what you are attempting.
Image Analyst
le 14 Mai 2016
Difficult to follow? I didn't even try because of the lack of comments and data. I'm not going to go to some web site and haul down some data file, which may or may not be one she had trouble with - just attach one - make it easy for us to help you not hard. Plus "does not display the right answer" does not make it clear what the expected results or "right answer" is. How should I know what you expect? See this: http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer
Nicoleta
le 14 Mai 2016
Geoff Hayes
le 14 Mai 2016
Nicoleta - thanks for attaching your code. The problem will still be getting to your data which you have posted as some link to something. You must understand the reluctance of us visiting some random site which may (or may not) have any of your data. Can you just attach a subset of the data?
Also it is unclear what the blocks similar to
if j(1)<=40
n_a+1;
else if j(1)>40 && j(1)<=80
n_e+1;
else if j(1)>80 && j(1)<=120
n_i+1;
else if j(1)>120 && j(1)<=160
n_o+1;
else if j(1)>160 && j(1)<=200
n_u+1;
end
end
end
end
end
are supposed to do. It looks like you are trying to increment (C-style) some counters for each vowel. If that is the case, then you would need to replace each with
for k=1:5
if j(k)<=40
n_a = n_a + 1;
elseif j(k)>40 && j(k)<=80
n_e = n_e + 1;
elseif j(k)>80 && j(k)<=120
n_i = n_i + 1;
elseif j(k)>120 && j(k)<=160
n_o = n_o + 1;
elseif j(k)>160 && j(k)<=200
n_u = n_u + 1;
end
end
Note the use of the elseif and how it simplifies the code. Since you repeat this block five times, we can use a for loop to do the same.
Nicoleta
le 14 Mai 2016
Geoff Hayes
le 14 Mai 2016
Nicoleta - with the small subset, I won't be able to reproduce your results...
Nicoleta
le 14 Mai 2016
Geoff Hayes
le 14 Mai 2016
Nicoleta - I wasn't suggesting that you upload all of your data files, only that without your data we won't be able to reproduce the problem that you are observing. As for why you are doing this homework, wouldn't that be a question for your professor? What class are you attending?
Réponses (0)
Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!