Android Question TTS not speaking. What's wrong with this code?

Beja

Expert
Licensed User
Longtime User
Thank you in advance.


<code>Sub VR_Result (Success As Boolean, Texts As List)
If Success = True Then
Dim advice As String
advice = Texts.Get(0)
Select advice
Case "advice one"
TTS1.Speak("love your enemies. Be kind to those who hate you and pray for your persecutors.",True)
Case "advice two"
TTS1.Speak("Focus your thoughts on the many wonderful blessings that God has bestowed upon you ",True)
Case Else
Return
End Select
End If
End Sub
</code>
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
I have an old old project that uses TTS.

Since I do not remember, I'm watching it.

In it I have:
B4X:
Sub Pronuncia(Testo As String)
    mTTS_Pronto = False
    InitTTS
    Do Until mTTS_Pronto
        DoEvents
    Loop

    mTTSFinished = False
    gTTS.Speak(Testo, True)
End Sub

Sub InitTTS
    If gTTS.IsInitialized = False Then
        gTTS.Initialize("gTTS")
    Else
        mTTS_Pronto = True
    End If
End Sub

Where:
Sub Pronuncia = Sub Say or Speak
mTTS_Pronto = mTTS_Ready - global module variable
gTTS = Process Global variable


P.S. log(advice) before Select
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Hi Beja,
two elements to check:
1. log(Success) just to be sure it is True otherwise the whole TTS block will be skipped
2. log(advice) so to see what the engine recognized
Anyway, since you are checking against lowercase strings you should modify advice accordingly.

Umberto
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
Umberto ,
Thanks and as you pointed, the problem is with the "advice!! I don't why or how.. but I worked around it by eliminating the For-Next loop
altogether and used different logic.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Umberto ,
Thanks and as you pointed, the problem is with the "advice!! I don't why or how.. but I worked around it by eliminating the For-Next loop
altogether and used different logic.

We also don't know why or how ... since there is not FOR-NEXT loop in the code you posted ;)

Lesson one - drill one (italian):
Nemmeno noi sappiamo perché o come... dato che non c'è un ciclo For Next nel codice che hai pubblicato :D
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
LM,
The meaning was SELECT - END SELECT...
I told you I am getting old but you don't believe me.

In 1987 I visited Italy.. I stayed the whole night in the train station of Roma because I couldn't afford to pay 100,000 a night in a hotel!!!
The next day morning I was shopping for shoes and the displayed prices were astronomical.. so I changed my mind.
I took the train to Perugia, a small university town in the heights of Northern Italy.. so beautiful. I stayed in Ostelo (Youth Hostel).
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
You're getting old ... I'm already old and I have senile dementia, otherwise I would have realized that you were referring to SELECT :D

But you're lucky: Italy is becoming a poor country.
Now you can go back (but it is best to buy shoes elsewhere, anyway :))
 
Upvote 0
Top