bluszcz
bluszcz

Reputation: 4128

Implementation TTS with providing default language

I am developing few Android apps, and I would like to provide possibility (assuming that phone supports) to 'read' the text - in Spanish app it would be Spanish voice, in French - French, respectively.

Can I somehow made one of two things:

  1. Check if this particular language is available?
  2. If it is not available - download it or give user possibility to download it?

Are there any patterns for it?

Upvotes: 2

Views: 1012

Answers (1)

Tyrannoseanus
Tyrannoseanus

Reputation: 4314

1) You can easily check whether a requested language is available using built in methods.

TextToSpeech tts = new TextToSpeech(this, this);

//Use this to get the default locale
tts.isLanguageAvailable(Locale.getDefault());

//Otherwise hardcode the language you want to check for
tts.isLanguageAvailable(Locale.FRENCH());

2) You can also give the user the possibility to download it by firing off an Intent for download

Intent installIntent = new Intent();
            installIntent
                    .setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
            startActivity(installIntent);

Upvotes: 2

Related Questions