SpeechRecognizer offline ERROR_NO_MATCH

SpeechRecognizer returns ERROR_NO_MATCH in onResults when the device is offline while it returns partial results to onPartialResults (). The last time I played with SpeechRecognizer, it worked fine offline, I wonder if anyone found a solution for it.

+4
source share
2 answers

As a job, I use partialResults returned in onPartialResults (). In the returned package, “SpeechRecognizer.RESULTS_RECOGNITION” has all terms minus the last term, and “android.speech.extra.UNSTABLE_TEXT” has the last missing recognized term.

    @Override
public void onPartialResults(Bundle partialResults) {
    ArrayList<String> data = partialResults.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
    ArrayList<String> unstableData = partialResults.getStringArrayList("android.speech.extra.UNSTABLE_TEXT");
    mResult = data.get(0) + unstableData.get(0);
}
+4
source

, UNSTABLE_TEXT :

// When creating the intent, set the partial flag to true
intent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS,true); 

// When requesting results in onPartialResults(), the UNSTABLE_TEXT parameter to getSTtringArrayList() must be in quotes
ArrayList<String> unstableMatches = partialResults.getStringArrayList("android.speech.extra.UNSTABLE_TEXT");

onPartialResults() , onError() ERROR_NO_MATCH. , : https://github.com/nenick/QuAcc/blob/master/app/src/main/java/de/nenick/quacc/speechrecognition/speech/RecognizerListenerWithOfflineWorkaround.java

:

  • .
  • Reset onBeginningOfSpeech()
  • onPartialResults()
  • onError(), , ERROR_NO_MATCH SpeechRecognizer.RESULTS_RECOGNITION "android.speech.extra.UNSTABLE_TEXT" .
  • onResults()
+1

All Articles