How to set language in speech recognition on Android?

I am working on a Recognition API program in android and found out that the speech results change when the language settings are changed, is there any way to install it programmatically? or is there an intention to dine on the speech language settings screen? or what else? Note: I tried to use this intent additionally:

intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, "en-US"); 

but it was ineffective

+13
android speech-recognition
May 10 '12 at 16:54
source share
7 answers

As pargat says, this will do this:

 intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en-US"); 

In addition, your application can request a list of supported languages ​​by sending an ordered broadcast of RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS like this:

  Intent detailsIntent = new Intent(RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS); sendOrderedBroadcast( detailsIntent, null, new LanguageDetailsChecker(), null, Activity.RESULT_OK, null, null); 

where LanguageDetailsChecker looks something like this:

 public class LanguageDetailsChecker extends BroadcastReceiver { private List<String> supportedLanguages; private String languagePreference; @Override public void onReceive(Context context, Intent intent) { Bundle results = getResultExtras(true); if (results.containsKey(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE)) { languagePreference = results.getString(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE); } if (results.containsKey(RecognizerIntent.EXTRA_SUPPORTED_LANGUAGES)) { supportedLanguages = results.getStringArrayList( RecognizerIntent.EXTRA_SUPPORTED_LANGUAGES); } } } 

For complete code check this github project: https://github.com/gast-lib

+38
May 11 '12 at 9:17
source share

there is no solution but deception ...

 intent.putExtra("android.speech.extra.EXTRA_ADDITIONAL_LANGUAGES", new String[]{"en"}); 

Check here for the full story.

+11
Nov 01. '14 at 10:48
source share

Have you tried this:

 intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en-US"); 
+8
May 10 '12 at 17:45
source share

This will work:

 intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en_US"); 

You should use "en_US" instead of "en-US". The first is the correct Java locale tag format.

That you are using

 intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.US.toString()); 

to avoid remembering such details.

+6
Mar 16 '13 at 9:49 on
source share

Finally, I got my application to limit the voice recognition results to the specified input language (transmitting it, for example, “ja” for Japanese or “fr” for French), adding all 3 of the following additional functions:

 String languagePref = "de";//or, whatever iso code... intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, languagePref); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, languagePref); intent.putExtra(RecognizerIntent.EXTRA_ONLY_RETURN_LANGUAGE_PREFERENCE, languagePref); 

Hope this helps someone.

+5
Jul 21 '13 at 4:25
source share

I tried to use

 intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault()); 

but this did not work for me (did not accept the system language). Helped here like this:

 intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault().toString()); 
0
Nov 08 '17 at 19:18
source share

I used this code:

 intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, "en-US"); 

Hope you can now run your application.

-one
Aug 28 '15 at 18:15
source share



All Articles