Android Question [Solved] wait TTS

giannimaione

Well-Known Member
Licensed User
Longtime User
hi all,
where is my mistake ?
B4X:
For i = 1 to 10
      dim Voice as string
     Voice = "Hello world this is number " & i
    Wait For (OraParla(Voice)) Complete (Dummy as int)
next
B4X:
private Sub OraParla (voice As String) As ResumableSub
    Dim jo As JavaObject = tts1
    Log("Start")
    Do While jo.RunMethod("isSpeaking",Null) = True
        Sleep(200)
    Loop
    tts1.Speak(voice, False)
    Do While jo.RunMethod("isSpeaking",Null) = True
        Sleep(300)
    Loop
    Log("Finish")
    Return 0
End Sub
but in Logs i have this sequence:
Start
Start
Start
Finish
Finish
Start
Start
....
...
..
Finish
Finish

i not listen sequence as:
Hello world this is number 1
Hello world this is number 2
Hello world this is number 3
Hello world this is number 4

but always in no particular order
 

Hamied Abou Hulaikah

Well-Known Member
Licensed User
Longtime User
Your example is working ...
You missed to add SpeechRate after tts1 initializing:
activity_create:
tts1.SpeechRate = 0.8
also you can adjust pitch value of tts1.
 
Upvote 0

giannimaione

Well-Known Member
Licensed User
Longtime User
@HAH you are right,
my app is different from the example
i will post my real app
 
Upvote 0

giannimaione

Well-Known Member
Licensed User
Longtime User
[solved]
B4X:
For i = 1 to 10
      dim Voice as string
     Voice = "Hello world this is number " & i
    'Wait For (OraParla(Voice)) Complete (Dummy as int)
     OraParla(Voice)
next

B4X:
'private Sub OraParla (voice As String) As ResumableSub
Private Sub OraParla (voice as String)
    'Dim jo As JavaObject = tts1
    Log("Start")
    'Do While jo.RunMethod("isSpeaking",Null) = True
    '    Sleep(200)
    'Loop
    tts1.Speak(voice, False)
    'Do While jo.RunMethod("isSpeaking",Null) = True
    '    Sleep(300)
   ' Loop
    Log("Finish")
    'Return 0
End Sub
 
Upvote 0

Similar Threads

Top