Reputation: 4128
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:
Are there any patterns for it?
Upvotes: 2
Views: 1012
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