How do I set the Dutch language in a text expression?
I want to set Dutch to my TTS object. Below is the code,
@Override
public void onInit(int status)
{
if ( status == TextToSpeech.SUCCESS )
{
int result = tts.setLanguage(Locale.getDefault());
System.out.println ( "Result : " + result + " " + Locale.getDefault().getLanguage() );
if (result == TextToSpeech.LANG_MISSING_DATA
|| result == TextToSpeech.LANG_NOT_SUPPORTED)
{
Toast.makeText( this , "Please Set your Language to English US.", Toast.LENGTH_LONG ).show();
}
else
{
tts.speak( "Hoe gaat het",TextToSpeech.QUEUE_FLUSH, null );
}
}
}
The next line sets the language to TTS
int result = tts.setLanguage(Locale.getDefault());
The available locale in the locale.
Now if my phone language is Dutch, I can set TTS language as Dutch, but if my phone language is not Dutch (for example if it is English) then there is no way to set TTS language as Dutch.
Can anyone help me install Dutch in TTS?
source to share
You set the default locale to setLocale
. Reason for this question: Now if my phone language is Dutch, I can set the TTS language as Dutch, but if my phone language is not Dutch (for example, if it is English) then there is no way to set TTS language as Dutch.
You should use Locale instead. So replace
int result = tts.setLanguage(Locale.getDefault());
from
int result = tts.setLanguage(Locale.XYZ); //XYZ is Locale you want.
Example:
int result = tts.setLanguage(Locale.GERMAN);
Consult the documentation that includes the available Locales that you can install. DUTCH is not available there.
Although this article mentions that DUTCH is available Locale. Maybe it is not for android but for java as suggested here
Hope it helps.
source to share