Locale for Gujrati language for Text to Speech - android

I want to try speech Gujarati language for my application. I've tried this locale code for the Gujarati language:
result = tts.setLanguage(Locale("gu-IN"))
result = tts.setLanguage(Locale("gu"))
result = tts?.setLanguage(Locale("gu-IND"))!!
I've tried these locale codes for the Gujarati Language .. but none of them work.

The code gu-IN is correct you can confirm by here.
If it's not working in your program then you can try this code to confirm if the language is in the list or not.
If it's available then you need to re-check your code. You can also share your code for help.

Related

The application language doesn't change completely

In application the language doesn't change completely. I select English. It say English. But when I go to another activity. The language change to primitive language. After I go to the main activity. The language is primative language. But when I click English or French(again) not any problem at all.
I think I didn't tell well. I hope you can understand well with video :
https://drive.google.com/file/d/1-5QL_5kdzg8d7QDe8UF8cwVii_-1S4JR/view?usp=sharing
The code for changing language :
public void dilidegistir(String dil){
Resources activityRes = getResources();
Configuration activityConf = activityRes.getConfiguration();
Locale newLocale = new Locale(dil);
activityConf.setLocale(newLocale);
activityRes.updateConfiguration(activityConf, activityRes.getDisplayMetrics());
Resources applicationRes = getApplicationContext().getResources();
Configuration applicationConf = applicationRes.getConfiguration();
applicationConf.setLocale(newLocale);
applicationRes.updateConfiguration(applicationConf,
applicationRes.getDisplayMetrics());
finish();
startActivity(getIntent());
}
How can I solve this problem?
I need your help.
I don't know why you're trying to change the language at runtime (normally it should be handled on the system level based on device's settings), but if you really need it check out this article: https://proandroiddev.com/change-language-programmatically-at-runtime-on-android-5e6bc15c758
I hope it's helpful.

"getDisplayLanguage()" always returning "English"

I need to get the current language selected in the Android device. When I use below code:
Log.v("Language: ", Locale.getDefault().getDisplayLanguage());
Log.v("Language: ", getResources().getConfiguration().locale.getDisplayLanguage());
The output is always same:
V/Language:: English
Below picture from android emulator selected language:
When I change the language of emulator, I can get the logs in the picture on the Android console.(But getDisplayLanguage() function returning English)
String locale = context.getResources().getConfiguration().locale.getDisplayName();
String locale = java.util.Locale.getDefault().getDisplayName();
They are different. The first can change if the user switches the Locale.
The second is the one that is pre-installed on the phone. It never changes no matter what the user does.
Happy Coding :)

Phonemes in eSpeak TextToSpeech in Android

I am working on an application in which i would like to use TTS to read text. I want to support Indian Languages offline so i have installed eSpeak Text To Speech engine in my android device and have set it as default. After understanding Speech Synthesis Markup Language (SSML) i realized that i can give phonemes as an input to make the Speech Engine pronounce words correctly. So i created a sample application in which i am using TextToSpeech class of Android.
String text = "[[ D,Is Iz sVm f#n'EtIk t'Ekst 'InpUt ]]";// "This is some phonetic text input"
tts.speak(text, TextToSpeech.QUEUE_FLUSH, null);
I read in the documentation of espeak that to make the engine understand phonemes, simply put phonetic expression in double square brackets and it would accept it as phoneme and render it accordingly. But this doesn't work in Android. Is the syntax correct?
Thanks
I directly used following code with Punjabi language unicode text in my app and it works.
m_objTTS = new TextToSpeech(this, this, "com.googlecode.eyesfree.espeak");
m_strTexttoSpeak = "ਸਕਰੀਨ ਤੇ ਟੈਪ ਕਰੋ|"; // its punjabi translation for "Tap on Screen"
m_objTTS.speak(m_strTexttoSpeak,TextToSpeech.QUEUE_FLUSH, null, null);
You should have espeak TTS app installed on mobile device and set it as default TTS engine. Default system language set to language of your choice ( Punjabi is set in my case )

Android : unsupported language questions - Laos

I'm not sure what do do about this one. My app needs to have Loation support (Laos) - the locale is not in Android and not available in any locale packs. Although I did find a Laos Language Pack, but installing it didn't seem to change anything.
I am just trying to get a simple textview to display the correct text. When I use the Loation word like "ສະບາຍດີ", I get just boxes.
In the following - the setting of the locale works, and I have the strings.xml file in values-lo, values-en, etc. I tried this with chinese and english, and it seems to work fine for both languages - but this Laos thing is not cooperating.
Locale locale = new Locale("lo");
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
setContentView(R.layout.activity_main);
textView = (TextView)findViewById(R.id.editText);
Typeface myTypeface = Typeface.createFromAsset(getAssets(), "TAW107.TTF");
textView.setTextSize(40);
textView.setTypeface(myTypeface);
textView.setText(getString(R.string.hello_world)); /this gives boxes for "ສະບາຍດີ"
I figured this one out. The Font set I was using did not have Laos character support. Even the font set was a "Laotion Font" set. Go figure. There are a few font families with broad support - like DejaVuSans. I used that one in the above code and it worked fine.
problem solved. - always check your fonts in things like font-manager and check the character map.
the above code works now including the localization

Chinese locale values-zh_CN gives an error on Eclipse

I've created a values-zh_CN directory in my res folder for Simplified Chinese localization. Eclipse does not accept that folder name, it marks it as an error, the directory itself.
The problem is definitely with the directory name, if I change the directory name to values-nl for example the error comes off.
The only name Eclipse accepts is values-zh-rCN which compiles fine but the actual locale is not loaded (Default en is loaded instead).
If you named dir for example values-zh it will be loaded only when Chinese is chosen in system language settings. You should know about that.
Value zh-rCN is correct and everything should work correctly. Read my notice above.
Use following code its working for me for traditional and simplified chinese.
if(selectedLanguage.equals("zh_CN"))
locale = Locale.SIMPLIFIED_CHINESE;
else if(selectedLanguage.equals("zh_TW"))
locale = Locale.TRADITIONAL_CHINESE;
else
locale = new Locale(selectedLanguage);
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
baseContext.getResources().updateConfiguration(config, baseContext.getResources().getDisplayMetrics());
The correct locales are zh-rCN and zh-rTW,so then whatever Android software your using isn't correctly setting locale values.
Look into settings -> Language & Input to double check that Language is on Chinese, and if that fails look in the market for an application called MoreLocales2, it allows you to get around some of those stock Samsung softwares that prevent locale changing from working.

Categories

Resources