How to handle ERROR_RECOGNIZER_BUSY
Asked Answered
C

5

29

In my voice recognition based app, I sometimes receive ERROR_RECOGNIZER_BUSY. Intuitively, this calls for... retries, right?

The problem is that this error is very undocumented, so obviously I have questions that perhaps someone more experienced in the field is able to answer:

  1. What triggers such an error? Is it really only busy server (at Google)? or this could also hint at a bug in my app?
  2. Do I have to explicitly close/reopen a session before a retry?
  3. How often to retry? once every 1-second? every 5-seconds? Other?

Your experienced insights are most welcome. Thanks.

Conciseness answered 27/4, 2011 at 21:39 Comment(1)
Can you post the code you are using to interact with the SpeechRecognizer?Levulose
P
6

I'm not 100% sure of this, however since it's been so long since you posted, I may as well give it a shot. It seems that you are doing something wrong in the code. As the commenter said, it would be helpful if you actually posted the code that is returning this error. However, in the source code for the Android speech recognition service found here:

http://source-android.frandroid.com/frameworks/base/core/java/android/speech/RecognitionService.java we have a function called dispatchStopListening which seems to end the listening process. However, before it actually ends it, there are a few checks for illegal states, including this:

else if (mCurrentCallback.mListener.asBinder() != listener.asBinder()) {
            listener.onError(SpeechRecognizer.ERROR_RECOGNIZER_BUSY);
            Log.w(TAG, "stopListening called by other caller than startListening - ignoring");
        }

This seems to imply that you are trying to end the listening process by some other guy than you started it with, which raises this error. I hope this helps, but it would be extremely beneficial if you posted the code.

Pita answered 14/5, 2011 at 22:29 Comment(0)
M
1

ERROR_RECOGNIZER_BUSY is often thrown when you are already in use of the SpeechRecognizer object. (Or you didn't close one proprely).

Maltreat answered 20/6, 2014 at 12:31 Comment(1)
When a recognizer cancel() is invoked after recognizer has started listening, it appears that this will always result in RecognitionListener.onError(): https://mcmap.net/q/267240/-android-speech-recognizer-not-connected-to-the-recognition-serviceSnowmobile
L
1

Simply add the package to your recognizer intent and it should work. That is what I have done.

Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
...
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, "com.package.name");
Lowly answered 13/1, 2015 at 20:6 Comment(0)
B
1

The most likely cause for ERROR_RECOGNIZER_BUSY is that you have not stopped the recognition service from the main thread and the error thrown was ignored.

Brinkman answered 25/3, 2015 at 23:26 Comment(0)
C
1

This actually is a very simple error. It means the previous listening is not finished. Basically, you need to stop listening. In my App i have 2 button for different languages. calling stopListening() fixed the issue. The error does appear from time to time but the user experience is smooth now. It doesn't cause problems.

       speech.stopListening();

        USER_ID = 2;


        Intent recognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
        recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, TARGET_CODE);
        recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, TARGET_CODE);
        recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
        recognizerIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 1);
        recognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, Conversation.this.getPackageName());

        speech.startListening(recognizerIntent);
Concussion answered 2/6, 2022 at 15:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.