我使用Android的内置语音识别类编写了一个语音识别应用程序。
在使用Exception
函数获取的语音识别器对象上调用startListening()
函数时,我的开发人员控制台中会出现以下createSpeechRecognizer(context)
。
我正在使用Android一加一设备。
我已经像这样初始化语音识别
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方法之后没有任何事情发生。