When starting a Activity
I execute the following code in the function onCreate
:
tts = new TextToSpeech(this, new TextToSpeech.OnInitListener()
{
@Override
public void onInit(int status)
{
if (status == TextToSpeech.SUCCESS)
{
tts.setLanguage(singletonGame.locale);
tts.speak(instruction, TextToSpeech.QUEUE_ADD, null);
}
}
});
But there is a delay in when the audio starts to sound, because it is delayed.
Try to leave the object TextToSpeech
in a class Singleton
to have it pre-loaded before and not wait for the delay, but throw me an error, because I must destroy it in each scene that the object calls.
Does anyone know any solution?
Update 1:
I did a test and what is delayed is this line running, because it goes fast to IF
tts.speak(instruction, TextToSpeech.QUEUE_ADD, null);