I am trying to add to my app specific TTS engine - not system based, so each person will have another, but one for all.
In documentation there is method:setEngineByPackageName(), which looks like it will make what I want. However, looking on other similar problems earlier I've found something using this method: https://stackoverflow.com/questions/12549086/selecting-required-tts-programmatically-in-android.
It looks quite ok, but it is used after system checking if TTS engine is installed, and installing it if there isn't one (no defined which one).
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Fire off an intent to check if a TTS engine is installed
Intent checkIntent = new Intent();
checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
startActivityForResult(checkIntent, MY_DATA_CHECK_CODE);
}
public 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);
}
}
}
So, I would like to ask if there is any method to install specific tts engine during checking, because now those methods are called before creating TTS, so you can't call setEngineByPackageName(), or constructor with engine setting (depends on Android version).
I was thinking as an engine about Text-To-Speech Extended, so as I understand I should use package name: com.google.tts I assume it from Play store link.