Text to Speech

Rusty

Well-Known Member
Licensed User
Longtime User
Using Media Player, one can determine when the mediaplayer.isplaying and thus determine when the media has completed playing. I am trying to use the Text to speech, but would like to know when the TTS completes saying the text. Is there an event or method to determine when a TTS is playing or has completed playing (or saying) the text?
Thanks in advance.
 

Rusty

Well-Known Member
Licensed User
Longtime User
Thanks! This is what I need, but is there a way to have the S1 service raise an event in the main module so it can be detected when complete?
 
Upvote 0

ZJP

Active Member
Licensed User
Longtime User
Yes,

in the module ( Module name TTSModule)
B4X:
Sub Process_Globals

   Dim TTSFinish as Boolean
   TTSFinish  = False
End Sub

Sub PE_TextToSpeechFinish (Intent As Intent)
   Log("TextToSpeechFinish")
   If IsPaused(Main) = False Then '  call a function in the Main activity
      CallSub(Main, "SpeechIsFinish")
   End If
End Sub

in the main (name Main )

B4X:
Sub SpeechIsFinish
   ' Do something when PE_TextToSpeechFinish is called

End Sub

+++++++++++++++++++++++++++++++++++

Another solution

in the module

B4X:
Sub PE_TextToSpeechFinish (Intent As Intent)
   Log("TextToSpeechFinish")
   TTSFinish  = True
End Sub


in the main (name Main )

B4X:
If  TTSModule.TTSFinish  then
   ' do something
End If

JP
 
Last edited:
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
Thanks.
I also experimented with moving the TextToSpeechFinish into a sub in the main. There, when the speech is finished, the event raises there. Seems to work well. I appreciate your help. Merci mille fois!
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…