Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get to know programmatically whether any TTS engine installed in my device or not?

Tags:

android

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

like image 353
piks Avatar asked Jun 06 '12 09:06

piks


2 Answers

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 :)

like image 54
Mohammad Areeb Siddiqui Avatar answered Oct 23 '22 03:10

Mohammad Areeb Siddiqui


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());
}
like image 42
Yasin Yaqoobi Avatar answered Oct 23 '22 02:10

Yasin Yaqoobi