当设备离线时,SpeechRecognizer 在 onPartialResults() 回调中返回部分结果时在 onResults 中返回 ERROR_NO_MATCH。上次我玩 SpeechRecognizer 时它在离线状态下运行良好,我想知道是否有人找到了解决方案。
最佳答案
作为解决方法,我使用 onPartialResults() 中返回的 partialResults。 在返回的包中,“SpeechRecognizer.RESULTS_RECOGNITION”包含所有术语减去最后一个术语,“android.speech.extra.UNSTABLE_TEXT”包含最后一个缺失的识别术语。
@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);
}
关于android - SpeechRecognizer 离线 ERROR_NO_MATCH,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30654191/