I’m playing with text to speech to make my testapp a little more fun. It works in the emulator but not on my phone since my default locale isn’t english.
However, the texts are english so the tts should of course use english. As far as I know I can implement an autoninstall, something like
public void onInit(int status) {
if (status == TextToSpeech.SUCCESS) {
// Set preferred language to US english.
int result = mtts.setLanguage(Locale.US);
if (result == TextToSpeech.LANG_MISSING_DATA ||
result == TextToSpeech.LANG_NOT_SUPPORTED) {
// Lanuage data is missing or the language is not supported.
Log.e(TAG, "Language is not available.");
} else {
// The TTS engine has been successfully initialized.
speak();
}
} else {
// missing data, install it
Intent installIntent = new Intent();
installIntent.setAction(
TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
startActivity(installIntent);
}
}
But, do I want to? Does installing locales take a lot of space? Does it mess up something else?
regards
You should execute this:
when you get LANG_MISSING_DATA