How to handle ERROR_RECOGNIZER_BUSY

前端 未结 4 1050
-上瘾入骨i
-上瘾入骨i 2020-12-17 08:35

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

The problem is that thi

相关标签:
4条回答
  • 2020-12-17 08:52

    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");
    
    0 讨论(0)
  • 2020-12-17 08:56

    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.

    0 讨论(0)
  • 2020-12-17 08:59

    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.

    0 讨论(0)
  • 2020-12-17 09:03

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

    0 讨论(0)
提交回复
热议问题