Android Marshmallow 6.0.1 disrupted my continuous speech recognition

I am creating an application in which I use continuous speech recognition. It worked fine until I upgraded my phone to Android 6.0.1, so I guess this is what broke the code. Now, almost instantly, the speech recognizer throws an ERROR_NO_MATCH error and only listens for the input less than a second before the restart, when it should listen for 5 seconds. This causes a very complex reaction of the team to the application. Here is my code:

private void displaySpeechRecognizer() {
    if(sr != null) {
        sr.destroy();
    }
    sr = SpeechRecognizer.createSpeechRecognizer(this);
    sr.setRecognitionListener(this);
    intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);

    // Start the activity, the intent will be populated with the speech text
    sr.startListening(intent);
}

@Override
public void onReadyForSpeech(Bundle params) {
}

@Override
public void onBeginningOfSpeech() {
}

@Override
public void onRmsChanged(float rmsdB) {
}

@Override
public void onBufferReceived(byte[] buffer) {
}

@Override
public void onEndOfSpeech() {
}

@Override
public void onError(int error) {
    displaySpeechRecognizer();
}
+4
source share
1 answer

. , " " ", Google". SpeechRecognizer onError

0

All Articles