I'm attempting to do some voice recognition stuff on mobile. Here's some code..
var recognition = new webkitSpeechRecognition();
recognition.onresult = function (e) {
//This is called every time the Speech Recognition hears you speak.
//You may say "How's it going today", the recognition will try to
//interpret what you're saying while you're speaking. For example, while
//you're speaking it may go.. "house" "how's it going" "how's it going today"
//as it interprets it returns an object that contains properties, one of
//which is "e.results[i].isFinal" where "i" is an array of returned objects.
//In this case the object with a transcript of "house" would have a
//"e.results[i].isFinal" value of false. Where as the object with a transcript
//of "how's it going today" would have a "e.results[i].isFinal" value of
//true.. Because this is the FINAL INTERPRETATION of this particular transcript.
//HOWEVER.. The problem I'm having is that when using a mobile device, the "e.results[i].isFinal" always
//has a value of true, even when it's not the final interpretation. It works correctly on desktop however. Both are using Chrome.
if(e.results[e.results.length-1].isFinal){
var finalTranscript = '';
for(i=0;i<e.results.length;i++){
finalTranscript += e.results[i][0].transcript;
}
console.log(finalTranscript);
document.getElementById('output').innerHTML = finalTranscript;
}
}
I'm just wondering if someone else has had this problem, as well as any insight on how to get around this problem. I have an example on my website.
https://jaymartmedia.com/example/speech.html
I added some debug info onto the page (so that i could "see" the console while on mobile. On desktop you'll notice "2: Final: false" and sometimes "2: Final: true". This is the value of "e.results[i].isFinal". On mobile it will always (or at least every time I've tried it on my phone) be "2: Final: true".
It's causing major problems, any insight will be greatly appreciated.
I also found that there is this issue with isFinal always being set to true on a mobile device. The workaround to for this, and to have interimResults is to use the confidence level. interimResults have a confidence level of 0. So something like this could work
if(e.results[e.results.length-1].isFinal && e.results[e.resultIndex][0].confidence > 0.1) {
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With