How To Set Arabic Language As Locale
I'm working on text to speech conversion. For this, I got the example from the internet. In this they set the English language by setLanguage(Locale.US);. So, now I'm trying to set
Solution 1:
In recent reference, Locale
has information of language/country code which are suitable in ISO 639-1/ISO 3166-1.
ISO 639-1 is two-letter lowercase language code. Arabic is defined ar in this format.
So, try this code:
Localeloc=newLocale("ar");
/* under API 20 */
tts.setLanguage(loc);
/* over API 21 */StringvoiceName= loc.toLanguageTag();
Voicevoice=newVoice(voiceName, loc, Voice.QUALITY_HIGH, Voice.LATENCY_HIGH, false, null);
tts.setVoice(voice);
Also, TextToSpeech
service that you used must support Arabic if you want to listen Arabic voice. Check it first.
Note:
Android Locale reference: https://developer.android.com/reference/java/util/Locale.html
ISO 639-1 code reference: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
Solution 2:
Localelocale=newLocale("ru");
Locale.setDefault(locale);
Configurationconfig=newConfiguration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config,
getBaseContext().getResources().getDisplayMetrics());
Reference :ref
Post a Comment for "How To Set Arabic Language As Locale"