问题
I've been working on speech Recognition API in android and found out that the speech results vary allot when the language settings are changed , is there a way to set it programmatically ? or is there an intent to lunch the speech language settings screen ? or what else ? note: I tried to use this intent extra:
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, "en-US");
and
Intent detailsIntent = new Intent(RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS);
sendOrderedBroadcast(detailsIntent, null, new LanguageDetailsChecker(), null, Activity.RESULT_OK, null, null);
回答1:
Yes hanifs, that method didn't work for me also.
My default device language is English US, but I needed Italian for SR. Only applying all these three extras I succeded forcing Google Engine (used as default speech engine from my device) to use Italian.
String myLanguage = "it"; //or, Locale.Italian.toString()
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, myLanguage);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, myLanguage);
intent.putExtra(RecognizerIntent.EXTRA_ONLY_RETURN_LANGUAGE_PREFERENCE, myLanguage);
Try this way customizing your "myLanguage" variable, it should be ok!
回答2:
The only thing you can do for now is
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, Locale.getDefault());
It may not work if the recognizer engine does not support this language.
来源:https://stackoverflow.com/questions/16296947/how-to-pass-language-in-speech-recognition-on-android-apps