Reputation: 2175
I'm currently working with the Google Web Speech API in my project. Everything is working fine on desktop, but whenever I try to use my webapp or Googles API Demo on mobile with Chrome, the recocnized words appear several times:
This is a test Thisthisthis isis a testtesttesttest
Is there any fix for that or are there any easy to use alternatives?
Upvotes: 0
Views: 1508
Reputation: 46
I had the same issue and searched the net but found no sollution. So I checked the code and this repeating the final results issue is caused by
final_transcript += event.results[i][0].transcript;
Just eliminate the '+'.
recognition.onresult = function(event) {
var interim_transcript = '';
if (typeof(event.results) == 'undefined') {
recognition.onend = null;
recognition.stop();
upgrade();
return;
}
for (var i = event.resultIndex; i < event.results.length; ++i) {
if (event.results[i].isFinal) {
final_transcript = event.results[i][0].transcript;
} else {
interim_transcript += event.results[i][0].transcript;
}
}
final_transcript = capitalize(final_transcript);
final_span.innerHTML = linebreak(final_transcript);
interim_span.innerHTML = linebreak(interim_transcript);
if (final_transcript || interim_transcript) {
showButtons('inline-block');
}
};
Maybe it's the same hack on the the interim results. I won't need them so I didn't checked that.
Upvotes: 3