How to set the language in speech recognition on android?
up vote
17
down vote
favorite
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");
but it was ineffective
android speech-recognition
add a comment |
up vote
17
down vote
favorite
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");
but it was ineffective
android speech-recognition
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, Locale.getDefault()); ..it will run if gooogle support that language..
– Xar E Ahmer
May 29 '14 at 10:27
The extra that is supposed to serve that purpose is EXTRA_LANGUAGE, not EXTRA_LANGUAGE_PREFERENCE. However, LANGUAGE_EXTRA for some reason only works until 4.3. Starting from 4.4, Android allows multiple languages to be selected in Settings, and will always try to "guess" the language according to system settings and completely ignores the EXTRA_LANGUAGE extra. So, anybody?
– matteo
Sep 5 '14 at 16:38
add a comment |
up vote
17
down vote
favorite
up vote
17
down vote
favorite
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");
but it was ineffective
android speech-recognition
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");
but it was ineffective
android speech-recognition
android speech-recognition
asked May 10 '12 at 16:54
Mr.Me
7,57652949
7,57652949
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, Locale.getDefault()); ..it will run if gooogle support that language..
– Xar E Ahmer
May 29 '14 at 10:27
The extra that is supposed to serve that purpose is EXTRA_LANGUAGE, not EXTRA_LANGUAGE_PREFERENCE. However, LANGUAGE_EXTRA for some reason only works until 4.3. Starting from 4.4, Android allows multiple languages to be selected in Settings, and will always try to "guess" the language according to system settings and completely ignores the EXTRA_LANGUAGE extra. So, anybody?
– matteo
Sep 5 '14 at 16:38
add a comment |
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, Locale.getDefault()); ..it will run if gooogle support that language..
– Xar E Ahmer
May 29 '14 at 10:27
The extra that is supposed to serve that purpose is EXTRA_LANGUAGE, not EXTRA_LANGUAGE_PREFERENCE. However, LANGUAGE_EXTRA for some reason only works until 4.3. Starting from 4.4, Android allows multiple languages to be selected in Settings, and will always try to "guess" the language according to system settings and completely ignores the EXTRA_LANGUAGE extra. So, anybody?
– matteo
Sep 5 '14 at 16:38
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, Locale.getDefault()); ..it will run if gooogle support that language..
– Xar E Ahmer
May 29 '14 at 10:27
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, Locale.getDefault()); ..it will run if gooogle support that language..
– Xar E Ahmer
May 29 '14 at 10:27
The extra that is supposed to serve that purpose is EXTRA_LANGUAGE, not EXTRA_LANGUAGE_PREFERENCE. However, LANGUAGE_EXTRA for some reason only works until 4.3. Starting from 4.4, Android allows multiple languages to be selected in Settings, and will always try to "guess" the language according to system settings and completely ignores the EXTRA_LANGUAGE extra. So, anybody?
– matteo
Sep 5 '14 at 16:38
The extra that is supposed to serve that purpose is EXTRA_LANGUAGE, not EXTRA_LANGUAGE_PREFERENCE. However, LANGUAGE_EXTRA for some reason only works until 4.3. Starting from 4.4, Android allows multiple languages to be selected in Settings, and will always try to "guess" the language according to system settings and completely ignores the EXTRA_LANGUAGE extra. So, anybody?
– matteo
Sep 5 '14 at 16:38
add a comment |
8 Answers
8
active
oldest
votes
up vote
43
down vote
accepted
As pargat says, this will do it:
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en-US");
Also, your app can query for the list of supported languages by sending a RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS
ordered broadcast like so:
Intent detailsIntent = new Intent(RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS);
sendOrderedBroadcast(
detailsIntent, null, new LanguageDetailsChecker(), null, Activity.RESULT_OK, null, null);
where LanguageDetailsChecker is 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 the complete code check out this github project:
https://github.com/gast-lib
Thanks for the full package
– Mr.Me
May 12 '12 at 18:42
2
I think it easier to use RecognizerIntent method for creating the intent: ` val detailsIntent = RecognizerIntent.getVoiceDetailsIntent(context) activity.sendOrderedBroadcast(detailsIntent, null, LanguageDetailsChecker({ languages.accept(it) }), null, Activity.RESULT_OK, null, null)` Intent from the sample above didn't work for me :( getVoiceDetailsIntent() did :)
– Aetherna
Nov 20 '17 at 15:04
Putting "en-US" doesn't work for me. Useintent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.US.toString());
as suggested in the answer by @orina1123
– M3RS
Jul 16 at 13:20
add a comment |
up vote
12
down vote
there is no solution but a hackaround...
intent.putExtra("android.speech.extra.EXTRA_ADDITIONAL_LANGUAGES", new String{"en"});
check here the complete story.
2
Dude I don't know why you had only 1 point but this is definitely a correct answer. Thanks a lot.
– TacB0sS
Dec 14 '14 at 15:11
1
@TacB0sS people like long answers...well i am glad it helped you.
– Arnav M.
Dec 15 '14 at 4:18
1
most useful answer i ever get ! really.
– Behnam Esmaili
Dec 12 '16 at 10:20
add a comment |
up vote
9
down vote
This will work:
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en_US");
You have to use "en_US" instead of "en-US". The former is the right format of Java locale tag.
It is suggested that you use
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.US.toString());
to avoid remembering such detail.
Thanks, man. This saved hours of the time of mine!!! The problem was similar but little difference. Can find it here stackoverflow.com/questions/51048466/…
– Varun A M
Jun 27 at 7:05
add a comment |
up vote
8
down vote
Have you tried this:
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en-US");
add a comment |
up vote
6
down vote
I finally got my app to restrict voice recognition results to a specified language input (handing it, e.g., "ja" for Japanese or "fr" for French) by adding all 3 of the following extras:
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.
3
Did you REALLY put all those into the intent that you pass to startListening?? Did it really work? And didn't it with EXTRA_LANGUAGE alone? What Android versions did you test? EXTRA_LANGUAGE is the only one that is supposed to be relevant here. The other two, according to documentation, are meant for querying the system for supported language, NOT for recognition. So they should be totally meaningless here. For me, it works with EXTRA_LANGUAGE alone until 4.3, then the extra is completely ignored starting from 4.4.
– matteo
Sep 5 '14 at 16:42
1
@matteo right...not working on 4.4...
– Arnav M.
Nov 1 '14 at 10:31
add a comment |
up vote
1
down vote
I tried to use
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault());
but it did not work for me (did not take the system language).
Helped here like this:
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault().toString());
add a comment |
up vote
0
down vote
this code is to set the language in speech recognization
String languagePref = "te-IN";//this is for telugu
//kannada ---> "kn-IN"
//tamil---> "ta-IN".....
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, languagePref);
add a comment |
up vote
-1
down vote
I used this code:
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, "en-US");
Hope you can run your app now.
add a comment |
8 Answers
8
active
oldest
votes
8 Answers
8
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
43
down vote
accepted
As pargat says, this will do it:
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en-US");
Also, your app can query for the list of supported languages by sending a RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS
ordered broadcast like so:
Intent detailsIntent = new Intent(RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS);
sendOrderedBroadcast(
detailsIntent, null, new LanguageDetailsChecker(), null, Activity.RESULT_OK, null, null);
where LanguageDetailsChecker is 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 the complete code check out this github project:
https://github.com/gast-lib
Thanks for the full package
– Mr.Me
May 12 '12 at 18:42
2
I think it easier to use RecognizerIntent method for creating the intent: ` val detailsIntent = RecognizerIntent.getVoiceDetailsIntent(context) activity.sendOrderedBroadcast(detailsIntent, null, LanguageDetailsChecker({ languages.accept(it) }), null, Activity.RESULT_OK, null, null)` Intent from the sample above didn't work for me :( getVoiceDetailsIntent() did :)
– Aetherna
Nov 20 '17 at 15:04
Putting "en-US" doesn't work for me. Useintent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.US.toString());
as suggested in the answer by @orina1123
– M3RS
Jul 16 at 13:20
add a comment |
up vote
43
down vote
accepted
As pargat says, this will do it:
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en-US");
Also, your app can query for the list of supported languages by sending a RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS
ordered broadcast like so:
Intent detailsIntent = new Intent(RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS);
sendOrderedBroadcast(
detailsIntent, null, new LanguageDetailsChecker(), null, Activity.RESULT_OK, null, null);
where LanguageDetailsChecker is 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 the complete code check out this github project:
https://github.com/gast-lib
Thanks for the full package
– Mr.Me
May 12 '12 at 18:42
2
I think it easier to use RecognizerIntent method for creating the intent: ` val detailsIntent = RecognizerIntent.getVoiceDetailsIntent(context) activity.sendOrderedBroadcast(detailsIntent, null, LanguageDetailsChecker({ languages.accept(it) }), null, Activity.RESULT_OK, null, null)` Intent from the sample above didn't work for me :( getVoiceDetailsIntent() did :)
– Aetherna
Nov 20 '17 at 15:04
Putting "en-US" doesn't work for me. Useintent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.US.toString());
as suggested in the answer by @orina1123
– M3RS
Jul 16 at 13:20
add a comment |
up vote
43
down vote
accepted
up vote
43
down vote
accepted
As pargat says, this will do it:
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en-US");
Also, your app can query for the list of supported languages by sending a RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS
ordered broadcast like so:
Intent detailsIntent = new Intent(RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS);
sendOrderedBroadcast(
detailsIntent, null, new LanguageDetailsChecker(), null, Activity.RESULT_OK, null, null);
where LanguageDetailsChecker is 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 the complete code check out this github project:
https://github.com/gast-lib
As pargat says, this will do it:
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en-US");
Also, your app can query for the list of supported languages by sending a RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS
ordered broadcast like so:
Intent detailsIntent = new Intent(RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS);
sendOrderedBroadcast(
detailsIntent, null, new LanguageDetailsChecker(), null, Activity.RESULT_OK, null, null);
where LanguageDetailsChecker is 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 the complete code check out this github project:
https://github.com/gast-lib
edited Sep 12 '14 at 16:32
Confuse
3,04442550
3,04442550
answered May 11 '12 at 9:17
gregm
8,29544868
8,29544868
Thanks for the full package
– Mr.Me
May 12 '12 at 18:42
2
I think it easier to use RecognizerIntent method for creating the intent: ` val detailsIntent = RecognizerIntent.getVoiceDetailsIntent(context) activity.sendOrderedBroadcast(detailsIntent, null, LanguageDetailsChecker({ languages.accept(it) }), null, Activity.RESULT_OK, null, null)` Intent from the sample above didn't work for me :( getVoiceDetailsIntent() did :)
– Aetherna
Nov 20 '17 at 15:04
Putting "en-US" doesn't work for me. Useintent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.US.toString());
as suggested in the answer by @orina1123
– M3RS
Jul 16 at 13:20
add a comment |
Thanks for the full package
– Mr.Me
May 12 '12 at 18:42
2
I think it easier to use RecognizerIntent method for creating the intent: ` val detailsIntent = RecognizerIntent.getVoiceDetailsIntent(context) activity.sendOrderedBroadcast(detailsIntent, null, LanguageDetailsChecker({ languages.accept(it) }), null, Activity.RESULT_OK, null, null)` Intent from the sample above didn't work for me :( getVoiceDetailsIntent() did :)
– Aetherna
Nov 20 '17 at 15:04
Putting "en-US" doesn't work for me. Useintent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.US.toString());
as suggested in the answer by @orina1123
– M3RS
Jul 16 at 13:20
Thanks for the full package
– Mr.Me
May 12 '12 at 18:42
Thanks for the full package
– Mr.Me
May 12 '12 at 18:42
2
2
I think it easier to use RecognizerIntent method for creating the intent: ` val detailsIntent = RecognizerIntent.getVoiceDetailsIntent(context) activity.sendOrderedBroadcast(detailsIntent, null, LanguageDetailsChecker({ languages.accept(it) }), null, Activity.RESULT_OK, null, null)` Intent from the sample above didn't work for me :( getVoiceDetailsIntent() did :)
– Aetherna
Nov 20 '17 at 15:04
I think it easier to use RecognizerIntent method for creating the intent: ` val detailsIntent = RecognizerIntent.getVoiceDetailsIntent(context) activity.sendOrderedBroadcast(detailsIntent, null, LanguageDetailsChecker({ languages.accept(it) }), null, Activity.RESULT_OK, null, null)` Intent from the sample above didn't work for me :( getVoiceDetailsIntent() did :)
– Aetherna
Nov 20 '17 at 15:04
Putting "en-US" doesn't work for me. Use
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.US.toString());
as suggested in the answer by @orina1123– M3RS
Jul 16 at 13:20
Putting "en-US" doesn't work for me. Use
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.US.toString());
as suggested in the answer by @orina1123– M3RS
Jul 16 at 13:20
add a comment |
up vote
12
down vote
there is no solution but a hackaround...
intent.putExtra("android.speech.extra.EXTRA_ADDITIONAL_LANGUAGES", new String{"en"});
check here the complete story.
2
Dude I don't know why you had only 1 point but this is definitely a correct answer. Thanks a lot.
– TacB0sS
Dec 14 '14 at 15:11
1
@TacB0sS people like long answers...well i am glad it helped you.
– Arnav M.
Dec 15 '14 at 4:18
1
most useful answer i ever get ! really.
– Behnam Esmaili
Dec 12 '16 at 10:20
add a comment |
up vote
12
down vote
there is no solution but a hackaround...
intent.putExtra("android.speech.extra.EXTRA_ADDITIONAL_LANGUAGES", new String{"en"});
check here the complete story.
2
Dude I don't know why you had only 1 point but this is definitely a correct answer. Thanks a lot.
– TacB0sS
Dec 14 '14 at 15:11
1
@TacB0sS people like long answers...well i am glad it helped you.
– Arnav M.
Dec 15 '14 at 4:18
1
most useful answer i ever get ! really.
– Behnam Esmaili
Dec 12 '16 at 10:20
add a comment |
up vote
12
down vote
up vote
12
down vote
there is no solution but a hackaround...
intent.putExtra("android.speech.extra.EXTRA_ADDITIONAL_LANGUAGES", new String{"en"});
check here the complete story.
there is no solution but a hackaround...
intent.putExtra("android.speech.extra.EXTRA_ADDITIONAL_LANGUAGES", new String{"en"});
check here the complete story.
answered Nov 1 '14 at 10:48
Arnav M.
1,90611835
1,90611835
2
Dude I don't know why you had only 1 point but this is definitely a correct answer. Thanks a lot.
– TacB0sS
Dec 14 '14 at 15:11
1
@TacB0sS people like long answers...well i am glad it helped you.
– Arnav M.
Dec 15 '14 at 4:18
1
most useful answer i ever get ! really.
– Behnam Esmaili
Dec 12 '16 at 10:20
add a comment |
2
Dude I don't know why you had only 1 point but this is definitely a correct answer. Thanks a lot.
– TacB0sS
Dec 14 '14 at 15:11
1
@TacB0sS people like long answers...well i am glad it helped you.
– Arnav M.
Dec 15 '14 at 4:18
1
most useful answer i ever get ! really.
– Behnam Esmaili
Dec 12 '16 at 10:20
2
2
Dude I don't know why you had only 1 point but this is definitely a correct answer. Thanks a lot.
– TacB0sS
Dec 14 '14 at 15:11
Dude I don't know why you had only 1 point but this is definitely a correct answer. Thanks a lot.
– TacB0sS
Dec 14 '14 at 15:11
1
1
@TacB0sS people like long answers...well i am glad it helped you.
– Arnav M.
Dec 15 '14 at 4:18
@TacB0sS people like long answers...well i am glad it helped you.
– Arnav M.
Dec 15 '14 at 4:18
1
1
most useful answer i ever get ! really.
– Behnam Esmaili
Dec 12 '16 at 10:20
most useful answer i ever get ! really.
– Behnam Esmaili
Dec 12 '16 at 10:20
add a comment |
up vote
9
down vote
This will work:
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en_US");
You have to use "en_US" instead of "en-US". The former is the right format of Java locale tag.
It is suggested that you use
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.US.toString());
to avoid remembering such detail.
Thanks, man. This saved hours of the time of mine!!! The problem was similar but little difference. Can find it here stackoverflow.com/questions/51048466/…
– Varun A M
Jun 27 at 7:05
add a comment |
up vote
9
down vote
This will work:
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en_US");
You have to use "en_US" instead of "en-US". The former is the right format of Java locale tag.
It is suggested that you use
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.US.toString());
to avoid remembering such detail.
Thanks, man. This saved hours of the time of mine!!! The problem was similar but little difference. Can find it here stackoverflow.com/questions/51048466/…
– Varun A M
Jun 27 at 7:05
add a comment |
up vote
9
down vote
up vote
9
down vote
This will work:
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en_US");
You have to use "en_US" instead of "en-US". The former is the right format of Java locale tag.
It is suggested that you use
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.US.toString());
to avoid remembering such detail.
This will work:
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en_US");
You have to use "en_US" instead of "en-US". The former is the right format of Java locale tag.
It is suggested that you use
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.US.toString());
to avoid remembering such detail.
answered Mar 16 '13 at 9:49
orina1123
9111
9111
Thanks, man. This saved hours of the time of mine!!! The problem was similar but little difference. Can find it here stackoverflow.com/questions/51048466/…
– Varun A M
Jun 27 at 7:05
add a comment |
Thanks, man. This saved hours of the time of mine!!! The problem was similar but little difference. Can find it here stackoverflow.com/questions/51048466/…
– Varun A M
Jun 27 at 7:05
Thanks, man. This saved hours of the time of mine!!! The problem was similar but little difference. Can find it here stackoverflow.com/questions/51048466/…
– Varun A M
Jun 27 at 7:05
Thanks, man. This saved hours of the time of mine!!! The problem was similar but little difference. Can find it here stackoverflow.com/questions/51048466/…
– Varun A M
Jun 27 at 7:05
add a comment |
up vote
8
down vote
Have you tried this:
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en-US");
add a comment |
up vote
8
down vote
Have you tried this:
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en-US");
add a comment |
up vote
8
down vote
up vote
8
down vote
Have you tried this:
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en-US");
Have you tried this:
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en-US");
answered May 10 '12 at 17:45
Pargat
574720
574720
add a comment |
add a comment |
up vote
6
down vote
I finally got my app to restrict voice recognition results to a specified language input (handing it, e.g., "ja" for Japanese or "fr" for French) by adding all 3 of the following extras:
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.
3
Did you REALLY put all those into the intent that you pass to startListening?? Did it really work? And didn't it with EXTRA_LANGUAGE alone? What Android versions did you test? EXTRA_LANGUAGE is the only one that is supposed to be relevant here. The other two, according to documentation, are meant for querying the system for supported language, NOT for recognition. So they should be totally meaningless here. For me, it works with EXTRA_LANGUAGE alone until 4.3, then the extra is completely ignored starting from 4.4.
– matteo
Sep 5 '14 at 16:42
1
@matteo right...not working on 4.4...
– Arnav M.
Nov 1 '14 at 10:31
add a comment |
up vote
6
down vote
I finally got my app to restrict voice recognition results to a specified language input (handing it, e.g., "ja" for Japanese or "fr" for French) by adding all 3 of the following extras:
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.
3
Did you REALLY put all those into the intent that you pass to startListening?? Did it really work? And didn't it with EXTRA_LANGUAGE alone? What Android versions did you test? EXTRA_LANGUAGE is the only one that is supposed to be relevant here. The other two, according to documentation, are meant for querying the system for supported language, NOT for recognition. So they should be totally meaningless here. For me, it works with EXTRA_LANGUAGE alone until 4.3, then the extra is completely ignored starting from 4.4.
– matteo
Sep 5 '14 at 16:42
1
@matteo right...not working on 4.4...
– Arnav M.
Nov 1 '14 at 10:31
add a comment |
up vote
6
down vote
up vote
6
down vote
I finally got my app to restrict voice recognition results to a specified language input (handing it, e.g., "ja" for Japanese or "fr" for French) by adding all 3 of the following extras:
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.
I finally got my app to restrict voice recognition results to a specified language input (handing it, e.g., "ja" for Japanese or "fr" for French) by adding all 3 of the following extras:
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.
answered Jul 21 '13 at 4:25
kwishnu
1,2961215
1,2961215
3
Did you REALLY put all those into the intent that you pass to startListening?? Did it really work? And didn't it with EXTRA_LANGUAGE alone? What Android versions did you test? EXTRA_LANGUAGE is the only one that is supposed to be relevant here. The other two, according to documentation, are meant for querying the system for supported language, NOT for recognition. So they should be totally meaningless here. For me, it works with EXTRA_LANGUAGE alone until 4.3, then the extra is completely ignored starting from 4.4.
– matteo
Sep 5 '14 at 16:42
1
@matteo right...not working on 4.4...
– Arnav M.
Nov 1 '14 at 10:31
add a comment |
3
Did you REALLY put all those into the intent that you pass to startListening?? Did it really work? And didn't it with EXTRA_LANGUAGE alone? What Android versions did you test? EXTRA_LANGUAGE is the only one that is supposed to be relevant here. The other two, according to documentation, are meant for querying the system for supported language, NOT for recognition. So they should be totally meaningless here. For me, it works with EXTRA_LANGUAGE alone until 4.3, then the extra is completely ignored starting from 4.4.
– matteo
Sep 5 '14 at 16:42
1
@matteo right...not working on 4.4...
– Arnav M.
Nov 1 '14 at 10:31
3
3
Did you REALLY put all those into the intent that you pass to startListening?? Did it really work? And didn't it with EXTRA_LANGUAGE alone? What Android versions did you test? EXTRA_LANGUAGE is the only one that is supposed to be relevant here. The other two, according to documentation, are meant for querying the system for supported language, NOT for recognition. So they should be totally meaningless here. For me, it works with EXTRA_LANGUAGE alone until 4.3, then the extra is completely ignored starting from 4.4.
– matteo
Sep 5 '14 at 16:42
Did you REALLY put all those into the intent that you pass to startListening?? Did it really work? And didn't it with EXTRA_LANGUAGE alone? What Android versions did you test? EXTRA_LANGUAGE is the only one that is supposed to be relevant here. The other two, according to documentation, are meant for querying the system for supported language, NOT for recognition. So they should be totally meaningless here. For me, it works with EXTRA_LANGUAGE alone until 4.3, then the extra is completely ignored starting from 4.4.
– matteo
Sep 5 '14 at 16:42
1
1
@matteo right...not working on 4.4...
– Arnav M.
Nov 1 '14 at 10:31
@matteo right...not working on 4.4...
– Arnav M.
Nov 1 '14 at 10:31
add a comment |
up vote
1
down vote
I tried to use
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault());
but it did not work for me (did not take the system language).
Helped here like this:
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault().toString());
add a comment |
up vote
1
down vote
I tried to use
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault());
but it did not work for me (did not take the system language).
Helped here like this:
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault().toString());
add a comment |
up vote
1
down vote
up vote
1
down vote
I tried to use
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault());
but it did not work for me (did not take the system language).
Helped here like this:
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault().toString());
I tried to use
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault());
but it did not work for me (did not take the system language).
Helped here like this:
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault().toString());
answered Nov 8 '17 at 19:18
Oleg SH
19916
19916
add a comment |
add a comment |
up vote
0
down vote
this code is to set the language in speech recognization
String languagePref = "te-IN";//this is for telugu
//kannada ---> "kn-IN"
//tamil---> "ta-IN".....
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, languagePref);
add a comment |
up vote
0
down vote
this code is to set the language in speech recognization
String languagePref = "te-IN";//this is for telugu
//kannada ---> "kn-IN"
//tamil---> "ta-IN".....
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, languagePref);
add a comment |
up vote
0
down vote
up vote
0
down vote
this code is to set the language in speech recognization
String languagePref = "te-IN";//this is for telugu
//kannada ---> "kn-IN"
//tamil---> "ta-IN".....
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, languagePref);
this code is to set the language in speech recognization
String languagePref = "te-IN";//this is for telugu
//kannada ---> "kn-IN"
//tamil---> "ta-IN".....
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, languagePref);
answered Sep 29 at 10:36
dileep krishnan
1175
1175
add a comment |
add a comment |
up vote
-1
down vote
I used this code:
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, "en-US");
Hope you can run your app now.
add a comment |
up vote
-1
down vote
I used this code:
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, "en-US");
Hope you can run your app now.
add a comment |
up vote
-1
down vote
up vote
-1
down vote
I used this code:
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, "en-US");
Hope you can run your app now.
I used this code:
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, "en-US");
Hope you can run your app now.
edited Aug 28 '15 at 19:14
user5173426
3,58621034
3,58621034
answered Aug 28 '15 at 18:15
user5278060
1
1
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f10538791%2fhow-to-set-the-language-in-speech-recognition-on-android%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, Locale.getDefault()); ..it will run if gooogle support that language..
– Xar E Ahmer
May 29 '14 at 10:27
The extra that is supposed to serve that purpose is EXTRA_LANGUAGE, not EXTRA_LANGUAGE_PREFERENCE. However, LANGUAGE_EXTRA for some reason only works until 4.3. Starting from 4.4, Android allows multiple languages to be selected in Settings, and will always try to "guess" the language according to system settings and completely ignores the EXTRA_LANGUAGE extra. So, anybody?
– matteo
Sep 5 '14 at 16:38