I am improving an Android application that uses the RecognitionListener class to listen to the user's voice, here I get below results:
1-) If the user clicks on the microphone icon and says something is OK 2-) If the user clicks on the microphone icon and clicks the microphone icon again or says nothing, I get onerror , and the error type is: ERROR_RECOGNIZER_BUSY
@Override public void onError(int error) { if ((error == SpeechRecognizer.ERROR_NO_MATCH) || (error == SpeechRecognizer.ERROR_SPEECH_TIMEOUT)){ } else if(ERROR_RECOGNIZER_BUSY){ } }
Here is my code to start listening:
public void recognizeSpeechDirectly() { recognizer = SpeechRecognizer.createSpeechRecognizer(this.context); recognizer.setRecognitionListener(this); recognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); recognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, "org.twodee.andytest"); recognizerIntent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, true); recognizer.startListening(recognizerIntent); }
I want to restart listening when ERROR_RECOGNIZER_BUSY appears
Another guy talked about this error in stackoverflow, but for me this is incomprehensible and cannot implement it.
How to handle ERROR_RECOGNIZER_BUSY
Thank you in advance
source share