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?

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

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.
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
The code is error-free. It displays 'closest recording is:161, second closest recording is:162,third closest recording is:163, fourth closest recording is:164, fifth closest recording is:165 vowel is a'
The expected results are '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' .I modified my post according to your observations. Thank you for your time and I would appreciate if you can tell me how to modify the code in order to get the expected results.
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.
About what the block is meant to do: j is the index of the sorted euclidean distances. You'll have the same number of j as the number of distances therefore the same number of recordings/pronunciations. As I have 40 recordings for each vowel you will understand the intervals in the if structures. I uploaded a zip with a recording for each vowel. However ,if you want to use that subset you should modify the ifs as there aren't 40 recordings/vowel anymore . After replacing the block above with what you suggested,I obtain another result but still not the expected one . The obtained result now is:'closest recording is:161, second closest recording is:162,third closest recording is:163, fourth closest recording is:164, fifth closest recording is:165 vowel is u'
Nicoleta - with the small subset, I won't be able to reproduce your results...
I uploaded these temporarily . Once you downloaded them please tell me so I can delete them and upload the rest of them as this message appeared to me from mathworks "Cannot attach this file because:
You are limited to 10 daily uploads. If you need to upload additional files, delete one or more files now or wait 24 hours to upload more files."
Also do you know what could be the utility of such a code which classifies vowels? This code was given as a homework in a laboratory to me but no theory was given about it and I think that in everything we do we should know the utility. I looked on the internet but wasn't able to find anything useful about a possible purpose of detecting which vowel is pronounced when using pronunciations of vowels not of words which contain vowels. Please answer if you know. Many thanks.
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?

Connectez-vous pour commenter.

Réponses (0)

Catégories

Tags

Aucun tag saisi pour le moment.

Question posée :

le 13 Mai 2016

Commenté :

le 14 Mai 2016

Community Treasure Hunt

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

Start Hunting!

Translated by