我有一个曾经有效的代码,但由于某种原因它突然停止工作,我正在尝试使用希伯来语语音识别,但似乎从几天前开始它才开始英语语音识别。
这是我的代码
sr = SpeechRecognizer.createSpeechRecognizer(getApplicationContext());
test_voice_recognitiona listener = new test_voice_recognitiona();
sr.setRecognitionListener(listener);
Intent fl = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
fl.putExtra("android.speech.extra.LANGUAGE", "he");
fl.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "he");
fl.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,
this.getPackageName());
sr.startListening(fl);
test_voice_recognitiona 是我的 RecognitionListener 类名。
该代码运行良好,但由于某种原因它一直以英语收听。
我究竟做错了什么?
顺便说一句,我用谷歌对话框尝试了更简单的代码,它正在工作。
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "he");
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Talk to Me " + user_name);
startActivityForResult(intent,REQUEST_CODE);
也许这是谷歌现在更新的错误
虽然我迟到了聚会
以下黑客对我有用:
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "he");
intent.putExtra("android.speech.extra.EXTRA_ADDITIONAL_LANGUAGES", new String[]{"he"});
intent.putExtra(RecognizerIntent.EXTRA_PROMPT,
getString(R.string.speech_prompt));
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)