I have developed an app based on TTS for Android 2.3. I am noticing that in recent version of Android (4.2.2) for example, no default TTS language where installed by default, you have to manually download them by going into: Settings --> Language and input --> Text to speech output --> Google Text-To-speech --> Install voice data
Is there a way to install a language automatically?
Is there a way to install a language automatically?
Yes, but that will not happen automatically (without user consent) as mentioned in the docs:
Since the installation of the data can be interrupted or declined by the user, the application shouldn't expect successful installation upon return from that intent...
Anyhow, you can trigger the installation with something like this:
/**
* Ask the current default engine to launch the matching INSTALL_TTS_DATA activity
* so the required TTS files are properly installed.
*/
private void installVoiceData() {
Intent intent = new Intent(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setPackage("com.google.android.tts"/*replace with the package name of the target TTS engine*/);
try {
Log.v(TAG, "Installing voice data: " + intent.toUri(0));
startActivity(intent);
} catch (ActivityNotFoundException ex) {
Log.e(TAG, "Failed to install TTS data, no acitivty found for " + intent + ")");
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With