Android, Speak Failed: Tts Engine Connection Not Fully Set Up
I'm trying to get my TextToSpeech working, but I got a 'speak failed: TTS engine connection not fully set up', but got in green : Connected to ComponentInfo{...GoogleTTSService}. I
Solution 1:
The question is old, but I had a similar problem recently. In my case, the first sentence passed to the speak
method was never spoken and LogCat is showing this warning.
I deal with it by placing the TextToSpeech
object as static and created a static
setup
method. Works as a singleton design pattern. I'm calling this method on the first onCreate
of my app. It's working fine 'til now. See below.
publicclassSpeakerManager {
privatestatic TextToSpeech speaker;
publicstaticvoidsetup() {
if(speaker == null) {
speaker = newTextToSpeech(MyAppUtils.getApplicationContext(), newTextToSpeech.OnInitListener() {
@OverridepublicvoidonInit(int status) {
if (status == TextToSpeech.SUCCESS)
speaker.setLanguage(Locale.getDefault());
}
});
}
}
publicstaticvoidspeak(String toBeSpoken) {
speaker.speak(toBeSpoken, TextToSpeech.QUEUE_FLUSH, null, "0000000");
}
publicstaticvoidpause() {
speaker.stop();
speaker.shutdown();
}
}
This MyAppUtils
comes from this question.
Any improvement will be welcome.
I hope it helps someone.
Solution 2:
It seems the method onInit is never executed due to the call to the AsyncTask code. I moved the connect call in the onInit() method instead of the onCreate() and it now works.
Hope it will help someone.
Post a Comment for "Android, Speak Failed: Tts Engine Connection Not Fully Set Up"