我想将SpeechRecognizer添加到我的片段页面,但是,我得到的是cannot resolve method createSpeechRecognizer()
,这是我的代码,也许任何人都可以帮助我。
final SpeechRecognizer mSpeechRecognizer = (SpeechRecognizer) SpeechRecognizer.createSpeechRecognizer(context);
final SpeechRecognizer mSpeechRecognizer =
(SpeechRecognizer) SpeechRecognizer.createSpeechRecognizer();
final EditText editText = view.findViewById(R.id.editText);
final Intent mSpeechRecognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault());
最佳答案
检查doc:
您可以使用:SpeechRecognizer.createSpeechRecognizer (Context context)
SpeechRecognizer.createSpeechRecognizer (Context context, ComponentName serviceComponent)
在代码中删除第二行:
final SpeechRecognizer mSpeechRecognizer =
(SpeechRecognizer) SpeechRecognizer.createSpeechRecognizer();
关于android - 无法解析方法createSpeechRecognizer(),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57643485/