'Android webkitSpeechRecognition .isFinal variable not showing correct value

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.



Solution 1:[1]

I could NOT find the direct solution.

But in my case, it solves the bug when I disable all intermediate results:

var recognition = new webkitSpeechRecognition();

recognition.continuous = false
// or
recognition.interimResults = false

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Andre Goulart