Error ERROR_RECOGNIZER_BUSY with offline speech recognition

前端 未结 2 1785
Happy的楠姐
Happy的楠姐 2020-12-01 21:19

I have made research on google offline speech recognition. but it works fine in google nexus 5(OS:-4.4) but same build if I implement in Samsung galaxy s5(OS:-5.0) it is not

相关标签:
2条回答
  • 2020-12-01 22:11

    ERROR_RECOGNIZER_BUSY get thrown when you start your speech recognizer again when its already running. As in your code

    case SpeechRecognizer.ERROR_RECOGNIZER_BUSY:
            message = "RecognitionService busy";
    
            Log.v("LOG_TAG", message);
            speech.stopListening();
            speech.destroy();
    
            createSpeechAgain(VoiceRecognitionActivity.this);
    
            break;
    

    Simply edit your above code with

    case SpeechRecognizer.ERROR_RECOGNIZER_BUSY:
    
                break;
    

    As there is no need to start it again it is already running. If you will start recognition again it will keep throwing same error. and it will go in loop.

    0 讨论(0)
  • 2020-12-01 22:23

    ERROR_RECOGNIZER_BUSY is often thrown when you didn't close the SpeechRecognizer proprely. Yo probably are already using one instance of the SpeechRecognizer.

    See this http://developer.android.com/reference/android/speech/SpeechRecognizer.html

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