I would like to know programmatically how to get TTS engine info of the device for e.g. whether any TTS engine is installed or not , if installed then what are those and what are the different languages supported by each TTS engine? I have to use Android version 2.1(api level 7) to achieve this.
Please help me to implement this feature.
Regards,
Piks
You can check it by first sending an intent for result
Intent intent = new Intent();
intent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
startActivityForResult(intent, 0);
Then you can check it that if you have installed TTS engine or not in onActivityResult method:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == 0){
if(resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS){
Toast.makeText(getApplicationContext(),"Already Installed", Toast.LENGTH_LONG).show();
} else {
Intent installIntent = new Intent();
installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
startActivity(installIntent);
Toast.makeText(getApplicationContext(),"Installed Now", Toast.LENGTH_LONG).show();
}
Hope it works :)
This gives you the list of TTS Engines installed on your Android.
tts = new TextToSpeech(this, this);
for (TextToSpeech.EngineInfo engines : tts.getEngines()) {
Log.d("Engine Info " , engines.toString());
}
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