问题描述
我有一个code,它用于工作,但由于某种原因,它突然刚刚停止工作,我尝试使用语音识别在希伯来文,但它似乎是因为前几天它只是开始语音识别英文
I have a code that used to worked but for some reason it suddenly just stopped working, I'm trying to use voice recognition in Hebrew but it seems like since a few days ago it just starts voice recognition in English.
下面是我的code
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类名的名称。
test_voice_recognitiona is the name of my RecognitionListener class name.
在code运行良好,但由于某些原因,它一直在英语听力。
The code runs well but for some reason it keeps listening in English.
我在做什么错了?
这是我尝试了简单的code。与谷歌的对话的方式,它的工作。
By the way I tried the simpler code with the google dialog and it's working.
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);
也许它的谷歌现在更新故障
Perhaps it's the Google now update fault
推荐答案
虽然我迟到了,
下面的技巧对我的作品:
Although I'm late to the party,The following hack works for me:
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));
这篇关于如何使用语音识别与其他语言的Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!