RecognizerIntent更改默认语言

时间:2013-08-20 07:18:04

标签: java speech-recognition android-4.2-jelly-bean

我使用以下代码启动RecognizerIntent:

Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,"us-US");
startActivityForResult(intent, RESULT_SPEECH_GUEST);

但我的手机是用意大利语配置的,当我发言时,例如“等一下”,它会让我回复“uait a minut”(意大利语发音)。 为什么? 最诚挚的问候

1 个答案:

答案 0 :(得分:11)

我解决了这个问题:

String language =  "us-US";
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,language);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, language);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, language); 
intent.putExtra(RecognizerIntent.EXTRA_ONLY_RETURN_LANGUAGE_PREFERENCE, language);
startActivityForResult(intent, RESULT_SPEECH_GUEST);