Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Dutch Language in Text-To-Speech?

I want to set Dutch Language in my TTS object. Following 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 );
        }
    }
}

Following line sets the language in TTS

int result = tts.setLanguage(Locale.getDefault());

Available Locale's in Locale.

enter image description here

Now if my Phone's Language's is Dutch then I am able to set TTS's language as Dutch Language, but if My Phone's Language is not dutch ( for e.g. if it is English ) then there is no option to set the TTS's language as Dutch.

Can anybody help me to set the Dutch language in TTS?

like image 756
user2060383 Avatar asked Oct 30 '14 08:10

user2060383


1 Answers

This should work

int result = tts.setLanguage(new Locale("nl_NL"));
like image 155
Hoan Nguyen Avatar answered Oct 25 '22 17:10

Hoan Nguyen