我正在使用SpeechRecognizer。問題是如果沒有活動的互聯網連接,SpeechRecognizer將發出錯誤SpeechRecognizer.ERROR_NETWORK
或SpeechRecognizer.ERROR_SERVER
。Android上的Offline SpeechRecognizer無法正常工作
這是我RecognizerIntent
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_BUSY
SpeechRecognizer.ERROR_NO_MATCH
請幫助我。