There is no Complete event in the underlying API. There is a method that you can poll named isSpeaking.
It should be easy to call it with the Reflection library. If you need I can help you.
Hi Erel,
It's been a while since I posted to this thread.
You offered to help with the ispeaking example.
Can you do so now?
I need to know when a TTS is finished speaking (or know when it is speaking).
thanks in advance.
Wow, this is an old thread!
Sadly, the TextToSpeechFinish event is unreliable on the Samsung Galaxy S4 (it is raised twice) and it is raised immediately upon starting speaking the text on my Nexus 7 (which is stock Android, I believe). I'm still struggling to find a suitable solution for all devices. How would I go about using the IsSpeaking property with reflection? I'm hoping that might be the answer. Else it's pretty pointless combining TTS with VR on an Android device, using the built-in functionality.
I just tried the code above and get the error:
java.lang.RuntimeException: Method: isSpeaking not found in: java.lang.String
And I am using the Reflection library.
Sorry Erel, I am using both libraries Reflection and JavaObject, but still getting the same error. I've tried
Dim jTTS As JavaObject = TTS in both Process_Globals and Globals and
Log(jTTS.RunMethod("isSpeaking", null) in a part of my code after TTS1.Speak(lblStory.Text, True), which does speak the text. Could there be a conflict while using both libraries? I started using JavaObject to pad edittexts, and I'm using Reflection for various other things.
i m using this libs
-core
-java object
-dialogs
-clipboard
-TTS
-Admob
-Reflection
-Phone
java.lang.RuntimeException: Method: IsSpeaking not found in: android.speech.tts.TextToSpeech
my code
B4X:
Sub btnSpeak_Click
Dim jTTS As JavaObject = TTS1
If jTTS.RunMethod("IsSpeaking", Null) = True Then 'this line is the error *-*
ToastMessageShow("Leitor em uso, aguarde!", True)
Else If EditText1.Text = "" Then
ToastMessageShow("O campo texto está vazio",True)
Else
EditText1.SelectAll
TTS1.Speak(EditText1.Text, True)
End If
End Sub