Google Speech Recognition timeout Google Speech Recognition timeout android android

Google Speech Recognition timeout


EDIT - Has apparently been fixed in the August 2016 coming release You can test the beta to confirm.

This is a bug with the release of Google 'Now' V6.0.23.* and persists in the latest V6.1.28.*

Since the release of V5.11.34.* Google's implementation of the SpeechRecognizer has been plagued with bugs.

You can use this gist to replicate many of them.

You can use this BugRecognitionListener to work around some of them.

I have reported these directly to the Now team, so they are aware, but as yet, nothing has been fixed. There is no external bug tracker for Google Now, as it's not part of AOSP, so nothing you can star I'm afraid.

The most recent bug you detail pretty much makes their implementation unusable, as you correctly point out, the parameters to control the speech input timings are ignored. Which according to the documentation:

Additionally, depending on the recognizer implementation, these values may have no effect.

is something we should expect......

The recognition will continue indefinitely if you don't speak or make any detectable sound.

I'm currently creating a project to replicate this new bug and all of the others, which I'll forward on and link here shortly.

EDIT - I was hoping I could create a workaround that used the detection of partial or unstable results as the trigger to know that the user was still speaking. Once they stopped, I could manually call recognizer.stopListening() after a set period of time.

Unfortunately, stopListening() is broken too and doesn't actually stop the recognition, therefore there is no workaround to this.

Attempts around the above, of destroying the recognizer and relying only on the partial results up until that point (when destroying the recognizer onResults() is not called) failed to produce a reliable implementation, unless you're simply keyword spotting.

There is nothing we can do until Google fix this. Your only outlet is to email apps-help@google.com reporting the problem and hope that the volume they receive gives them a nudge.....


NOTE! this works only in online mode.Enable dictation mode and disable partial results:

intent.putExtra("android.speech.extra.DICTATION_MODE", true);intent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, false);

In dictation mode speechRecognizer would still call onPartialResults() however you should treat the partials as final results.


UPDATE:

Just in case if anyone is having trouble in setting up the speech recognition, you can use Droid Speech library which I built to overcome the speech time out issue in android.


My app was entirely dependent upon the voice recognition feature and Google hasdropped a bomb. Going by the look of things, I believe this wouldn't be fixed at least in the near future.

For the time being, I did find a solution to have the google voice recognition deliver the speech results as intended.

Note: This approach slightly varies from the above mentioned solutions.

The main purpose of this method is to make sure the entire words uttered by the user is caught at onPartialResults().

In normal cases if a user speaks more than a single word at a given instance the response time is too quick and partial results will more often than not get only the first word and not the complete result.

So to make sure every single word is caught at onPartialResults() a handler is introduced to check the user pause delay and then filter the results. Also note the result array from onPartialResults() will more often than not have only a single item.

SpeechRecognizer userSpeech = SpeechRecognizer.createSpeechRecognizer(this);Intent speechIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);speechIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);speechIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, this.getPackageName());speechIntent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, true);speechIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, ModelData.MAX_VOICE_RESULTS);Handler checkForUserPauseAndSpeak = new Handler(); Boolean speechResultsFound = false;userSpeech.setRecognitionListener(new RecognitionListener(){    @Override    public void onRmsChanged(float rmsdB)    {        // NA    }    @Override    public void onResults(Bundle results)    {        if(speechResultsFound) return;        speechResultsFound = true;        // Speech engine full results (Do whatever you would want with the full results)    }    @Override    public void onReadyForSpeech(Bundle params)    {        // NA    }    @Override    public void onPartialResults(Bundle partialResults)    {        if(partialResults.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION).size() > 0 &&                partialResults.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION).get(0) != null &&                !partialResults.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION).get(0).trim().isEmpty())        {            checkForUserPauseAndSpeak.removeCallbacksAndMessages(null);            checkForUserPauseAndSpeak.postDelayed(new Runnable()            {                @Override                public void run()                {                    if(speechResultsFound) return;                    speechResultsFound = true;                    // Stop the speech operations                    userSpeech.destroy();                    // Speech engine partial results (Do whatever you would want with the partial results)                }            }, 1000);        }    }    @Override    public void onEvent(int eventType, Bundle params)    {        // NA    }    @Override    public void onError(int error)    {        // Error related code    }    @Override    public void onEndOfSpeech()    {        // NA    }    @Override    public void onBufferReceived(byte[] buffer)    {        // NA    }    @Override    public void onBeginningOfSpeech()    {        // NA    }});userSpeech.startListening(speechIntent);