I am creating an application that I am using continuous speech recognition on. It was working great until the other day when I updated my phone to Android 6.0.1, so I am assuming this is what broke the code. Now, almost instantly the speech recognizer throws an ERROR_NO_MATCH error and is only listening for input for less than a second before restarting when it is supposed to listen for 5 seconds. It is causing it to be very hard to say a command 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();
}