I have a problem in my Android application, this application uses voice recognition and Google TTS. It looks like a SIRI client. As you can see here when the user says a word in an array:
String[] g = { "hallo", "heey", "hoi", "hey", "he", "hee", "hay" }; for (String strings : g) { if (mostLikelyThingHeard.contains(strings)) { String[] array = { "leuk dat je er bent", "heeyy" }; String randomStr = array[new Random() .nextInt(array.length)]; tts.speak(randomStr, TextToSpeech.QUEUE_FLUSH, null); return; } } String[] f = { "haha", "hah", "ha" }; for (String strings : f) { if (mostLikelyThingHeard.contains(strings)) { String[] array = { "haha leuk grapje", "hiehaho" }; String randomStr = array[new Random() .nextInt(array.length)]; tts.speak(randomStr, TextToSpeech.QUEUE_FLUSH, null); return; } }
Everything works fine, but when the user says "hallo", he first discovers the first two characters "ha". What is mentioned in the String 'f' array. So itβs annoying, the whole word is not found, but only a part of it.
When I replace two arrays of strings as follows:
String[] f = { "haha", "hah", "ha" }; for (String strings : f) { if (mostLikelyThingHeard.contains(strings)) { String[] array = { "haha leuk grapje", "hiehaho" }; String randomStr = array[new Random() .nextInt(array.length)]; tts.speak(randomStr, TextToSpeech.QUEUE_FLUSH, null); return; } } String[] g = { "hallo", "heey", "hoi", "hey", "he", "hee", "hay" }; for (String strings : g) { if (mostLikelyThingHeard.contains(strings)) { String[] array = { "leuk dat je er bent", "heeyy" }; String randomStr = array[new Random() .nextInt(array.length)]; tts.speak(randomStr, TextToSpeech.QUEUE_FLUSH, null); return; } }
Then he discovers "hallo" first instead of "ha"
But if I create more than 100 arrays, it will be annoying, since I can let java use the best matching word from the array instead of the part?
I know this is hard to understand, but if you guys don't understand what you see my source here: http://github.com/gi097/PWS
EDIT:
When i change
contains
to
equals
I am fixing this problem, but now I have a new one:
If I create an array like:
"I am"
When the user says: βI am Giovanniβ, we have a problem that the βIβ is no longer detected due to peers ....
EDIT2
It can be fixed. I think that with mostLikelythingHeard "I Giovanni" splits into "I" "I" "Giovanni", but how?