need help with TTS error

moreno911

Member
Licensed User
Longtime User
as far as i know i am doing everything correctly....
it even compiles with no errors and everything but once i run the code on the emulator and even on the real phone i get a message that says "error speaking text" on both my emulator and my real phone when i run it.

i will include a small snipit of the code i use but, on the app i am developing
if i push past the error and continue it does speak.....

I just dont understand why the error..... maybe i'm missing a step first...

anyway thanks for answering my question in advance....

p.s. it only happens when i first start or run the program after i push
past the original error then everything is good.:sign0163:


'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.

End Sub

Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim TTS1 As TTS
End Sub

Sub Activity_Create(FirstTime As Boolean)
TTS1.Initialize("TTS1")
TTS1.SetLanguage("en","US")
TTS1.Pitch=1.5
TTS1.SpeechRate=1

TTS1.Speak("testing testing 1 2 3 testing testing 1 2 3",False)
End Sub
 

NJDude

Expert
Licensed User
Longtime User
You have to make the following modifications:

1- Move "Dim TTS1 As TTS" to "Sub Process_Globals"
2- Move this line TTS1.Speak("testing testing 1 2 3 testing testing 1 2 3", False) to the following sub:
B4X:
Sub TTS1_Ready(Success As Boolean)

    If Sucess Then    

       TTS1.Speak("testing testing 1 2 3 testing testing 1 2 3", False)

    End If
   
End Sub
 
Last edited:
Upvote 0

moreno911

Member
Licensed User
Longtime User
thank you !! thank you !!

i was beating my head agenst the wall with that one....
just one more question, inside the TTS1_ready sub

can i tell it to goto another sub for it to speak?


thanks a million.... it did work !!

:BangHead:

to

:)

:sign0098: thanks !!
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
Well, the TTS1_Ready sub is to determine if the TTS engine is working, if successful then you can send to another routine, enable a "talk" buton etc etc, depending on how you're writing your app.
 
Upvote 0

moreno911

Member
Licensed User
Longtime User
this there another way

this there another way to know if the TTS1 or TTS is working
other then making a sub?

i think I saw somwhere the if TTS1.IsInitiatized=False then

or the True thing.....


thanks
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
You have to make sure the TTS engine is working after you initialize it, that's the purpose of TTS_Ready
B4X:
Sub TTS1_Ready(Success As Boolean)
   
    If Success Then

       'Ready to talk

    Else

       'Cannot talk now        
                  
    End If
   
End Sub
 
Upvote 0
Top