Same old guy...
Same old guy...

Reputation: 305

What is right way to use TextToSpeech.Engine.ACTION_CHECK_TTS_DATA in 2.1 for non default language?

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

@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();
}
}
}

Guys, Above code works only if OS Default language == TTS installed language. If they are different, it branches to ACTION_INSTALL_TTS_DATA. Obviously, it should be additional data for TextToSpeech.Engine.ACTION_CHECK_TTS_DATA to specify which language data need to be checked but I cannot find it.

Following scenario come to play when user run something like a French – German dictionary on with English as default OS language.

Scenario: SVOX + German, French languages are installed. Default language set to English or something other language. The key it’s not German or French It looks like TextToSpeech.Engine.ACTION_CHECK_TTS_DATA check for English language presence in SVOX and come back with CHECK_VOICE_DATA_FAIL. If language set to German the result will be CHECK_VOICE_DATA_PASS

There are similar questions, but it looks like people trying to answer doesn’t understand question completely. how to get to know programmatically whether any TTS engine installed in my device or not?

Upvotes: 4

Views: 2142

Answers (1)

brandall
brandall

Reputation: 6144

Have you tried putting getting the extra TextToSpeech.Engine.EXTRA_CHECK_VOICE_DATA_FOR

According to the source code in this link, it will enable you to pass the parameter of the voice locale that you'd specifically like to check.

Upvotes: 1

Related Questions