In the Android 5 I faced with strange problem. The first call to the startListening
of SpeechRecognizer results to the onError with error code 7 (ERROR_NO_MATCH).
I made test app with the following code:
if (speechRecognizer == null) {
speechRecognizer = SpeechRecognizer.createSpeechRecognizer(this);
speechRecognizer.setRecognitionListener(new RecognitionListener() {
@Override
public void onReadyForSpeech(Bundle bundle) {
Log.d(TAG, "onReadyForSpeech");
}
@Override
public void onBeginningOfSpeech() {
Log.d(TAG, "onBeginningOfSpeech");
}
@Override
public void onRmsChanged(float v) {
Log.d(TAG, "onRmsChanged");
}
@Override
public void onBufferReceived(byte[] bytes) {
Log.d(TAG, "onBufferReceived");
}
@Override
public void onEndOfSpeech() {
Log.d(TAG, "onEndOfSpeech");
}
@Override
public void onError(int i) {
Log.d(TAG, "onError " + i);
}
@Override
public void onResults(Bundle bundle) {
Log.d(TAG, "onResults");
}
@Override
public void onPartialResults(Bundle bundle) {
Log.d(TAG, "onPartialResults");
}
@Override
public void onEvent(int i, Bundle bundle) {
Log.d(TAG, "onEvent");
}
});
}
final Intent sttIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
sttIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
sttIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en");
sttIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, "en");
speechRecognizer.startListening(sttIntent);
And have this log messages after first startListening
call:
onError 7
onReadyForSpeech
onBeginningOfSpeech
onEndOfSpeech
onResults
And following messages after another startListening
calls:
onRmsChanged
...
onRmsChanged
onReadyForSpeech
onRmsChanged
...
onRmsChanged
onBeginningOfSpeech
onRmsChanged
...
onRmsChanged
onEndOfSpeech
onRmsChanged
onRmsChanged
onRmsChanged
onResults
So, what is the reason of this error and how do I fix it?
As soon as you configure the "Okay Google" function to every screen the error appears.
So this seems to be the reason!
Deactivate the function and the problem should be solved
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With