Java – Android marshmallow 6.0.1 breaks my continuous speech recognition

I'm creating an application that I'm using continuous speech recognition. It worked well until one day when I updated my phone to Android 6.0.1, so I assumed that this was the reason for breaking the code. Now, the speech recognizer threw an error almost immediately_ NO_ Match error, and it only listens for input for less than one second before restarting. It should listen for 5 seconds. It makes it difficult to say commands to the application. This 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 one rror(int error) {
    displaySpeechRecognizer();
}

resolvent:

I just encountered the same problem. It seems that the problem may be related to changing the "always online" behavior to the "OK, Google" function

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>