Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The only solution that will for sure get around this issue is to use a 3rd party service. <strong>4.1.1 and 4.2 both</strong> rely on a version of the speech recognition service that does not adhere to the documented behavior in that the service running it dies silently. </p> <p>If you do not wish to use a 3rd party API, and you need to account for this service death in some manner, it <em>is</em> possible but it's not pretty or ideal. </p> <p>Once the service dies, none of the following methods will ever be called :</p> <ul> <li>onBeginningOfSpeech </li> <li>onError </li> <li>onResults </li> <li>onEndOfSpeech</li> </ul> <p><em>But</em> if onBeginningOfSpeech is called before the service dies, you can be assured that either onError or onEndOfSpeech will eventually be called. </p> <p>Therefore, <strong>if all you want is to be sure you are made aware of the life and death of the service in Jellybean</strong> the workaround for this problem in the built-in SpeechRecognizer is to do the following:</p> <ul> <li>Create a boolean flag like isSpeechRecognizerAlive. </li> <li>Any time you start up the SpeechRecognizer, set the above flag to false.</li> <li>In onBeginningOfSpeech, if it is called, set isSpeechRecognizerAlive to true.</li> <li>Maintain a Handler that, on a 4 second delay will check the status of isSpeechRecognizerAlive. If it is false, manually kill the SpeechRecognizer instance. If is is true, do nothing. The normal flow will take care of things for you.</li> </ul> <p><strong>Why this is not an ideal solution to maintain a continuous speech recognition setup</strong></p> <p>It wasn't directly stated in your question but a few people want to do this so they can have continuous speech recognition. <em>This is not really a good way to do that in 4.1.1 and 4.2</em> because Google's SpeechRecognition service now kicks off with a non-optional "bloop" sound effect. There appears to be no way to turn this sound off. Nothing is listed in the API to control it. Your users WILL NOT appreciate being "blooped" at on a 4 second repeating loop. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload