我正在開發Android,並使用SpeechRecognizer
來實現連續語音識別。爲什麼SpeechRecognizer在onEndOfSpeech被調用後啓動時很忙?
開始後通過下面的代碼語音識別:
private void startListening(){
recognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, "en");
recognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, getActivity().getPackageName());
recognizerIntent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS,Long.valueOf(3000L));
recognizerIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS,1);
}
並再次調用startListening()
當onEndOfSpeech
被調用。
但onError
將被調用,並顯示SpeechRecognizer.ERROR_RECOGNIZER_BUSY
。
Q1: 爲什麼SpeechRecognizer
忙,當我onEndOfSpeech
後開始已叫什麼名字?
Q2 如何實現連續語音識別的方式?
謝謝,我會試試! – Wun
爲什麼在幾次嘗試後停止工作?還是我用它錯了? – edwardffs