【发布时间】:2017-03-23 09:36:45
【问题描述】:
我正在使用 SpeechRecognizer。问题是如果没有活动的 Internet 连接 SpeechRecognizer 将抛出错误 SpeechRecognizer.ERROR_NETWORK 或 SpeechRecognizer.ERROR_SERVER。
这是我的识别器意图
final Intent recognizerIntent;
recognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, "en");
recognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, this.getPackageName());
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 5);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, true);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_PREFER_OFFLINE, true);
我把recognizerIntent.putExtra(RecognizerIntent.EXTRA_PREFER_OFFLINE, true);
但没有运气。再次它会抛出同样的错误。
我经常遇到这两个错误。
SpeechRecognizer.ERROR_RECOGNIZER_BUSYSpeechRecognizer.ERROR_NO_MATCH
请帮帮我。
【问题讨论】:
标签: java android speech-recognition offline