How to find out programmatically if any TTS engine is installed on my device or not?

I would like to know programmatically how to get information about the engine of a TTS device, for example. regardless of whether a TTS engine is installed or not, if installed, what are they and what languages ​​are supported by each TTS engine? For this, I have to use Android 2.1 (api level 7).

Please help me implement this feature.

Hi,

Peaks

+5
source share
4 answers

You can verify this by first sending the intent to the result

Intent intent = new Intent();
intent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
startActivityForResult(intent, 0);

Then you can verify that if you installed the TTS engine or not in the 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 :)

+11
source

Android , TTS Engine , .

+1

To save clicks:

Run this to check if TTS is installed or not:

Intent checkIntent = new Intent();
checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
startActivityForResult(checkIntent, MY_DATA_CHECK_CODE);

and then get the result:

private TextToSpeech mTts;
protected void onActivityResult(
    int requestCode, int resultCode, Intent data) {
if (requestCode == MY_DATA_CHECK_CODE) {
    if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {
        // success, create the TTS instance
        mTts = new TextToSpeech(this, this);
    } else {
        // missing data, install it
        Intent installIntent = new Intent();
        installIntent.setAction(
            TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
        startActivity(installIntent);
    }
}
}
+1
source

This gives you a 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());
}
+1
source

All Articles