0

我使用 android 的内置语音识别类编写了一个语音识别应用程序。

当在使用 function 获得的语音识别器对象上调用Exception该函数时,偶尔会在我的开发人员控制台中显示以下内容。我正在使用安卓一加一设备。我已经像这样初始化语音识别startListening()createSpeechRecognizer(context)

mSpeechRecognizer = peechRecognizer.createSpeechRecognizer(getActivity());
mSpeechRecognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, true);
mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS, 4000);
// mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS, 4000);
mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
                RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);        

mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE,
                "en");
mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,
                getActivity().getPackageName());
mSpeechRecognizer.setRecognitionListener(this);
mSpeechRecognizer.startListening(mSpeechRecognizerIntent);

并且在 startlistening 方法之后什么也没有发生。

4

0 回答 0