TTS in Service Module

beowulf6

Member
Licensed User
Longtime User
Hello.

After i got my first real Android Device i experimented a bit with Basic4Android and most of it is working how i want it. ;)

But now i am trying to start
TTS1.Speak(modifiedText, True)

inside an ServiceModule that is called in aregular interval. But it always failing when i put it inside the Service Module. Inside of the Main Module everything is working nice.

The error message inside the debugger is:
LastException java.lang.RuntimeException: Error speaking text

Might it be possible that using TTS inside a Service Module is not possible or am i doing something wrong?

TTS1.Initialize("TTS1")

seems to be executed and even
TTS1.SetLanguage("de", "")
gives no error.

Thanks for every idea and help.
 

beowulf6

Member
Licensed User
Longtime User
Hi. And Thank you a lot.

That was exactly my issue.

since the Main Module is started when the application starts and so TTS is ready long before the timer starts the speech.
But the Service Module is just started when it needs to speak and so it wanted to speak when the tts engine was not ready.

Now i have put the speak method right into the ready event and it seems to work. (crashed the first time, but not sure why because now it works how it should.)

Thanks again and thank you for Basic4android. ;)
 
Upvote 0
Top