Android Question Pause in TTS engine

AlpVir

Well-Known Member
Licensed User
Longtime User
You can add pauses in the output of the TTS Engine ?
For example it would be possible to insert a 1 second pause between the word "first" and "second"?
B4X:
Msg = "first second" 
TTS1.Speak (Msg, True)
With some symbols, such as "/" or "[1000]" or other.
Msg = "first / second"
Msg = "first [1000] second"
Thanks in advance.
 

AlpVir

Well-Known Member
Licensed User
Longtime User
Following the suggestion of Erel I created a sub that seems to do this job: a pause in a sentence.
For example, "one / two P1000" inserts a pause of 1000 ms between the word "one" and the word "two".
I used the parameter "False" in the method call speak TTS
B4X:
TTS1.Speak (Phrase, False)
I think it is essential for short sentences and short delays.

B4X:
Sub Speak (Msg As String)
    Dim ele()                     As String
    Dim i                        As Int
    Dim S                        As String
    Dim Posiz                    As Int
  
    ele = Regex.Split(" /P",Msg)
  
    For i=0 To ele.Length-1
        Posiz=ele(i).IndexOf2 (" ",0)
        If Posiz>-1 Then
            S=ele(i).SubString2 (0,Posiz)
            If IsNumber(S) Then
                ele(i)=ele(i).SubString(Posiz+1)
                Log ("wait " & S)
                Sleep (S)
                Log (ele(i) & " " & DateTime.Time (DateTime.Now))
                TTS1.Speak(ele(i), False )
            Else
                Log (ele(i) & " " & DateTime.Time (DateTime.Now))  
                TTS1.Speak(ele(i), False )
            End If   
        Else
            Log (ele(i) & " " & DateTime.Time (DateTime.Now))
            TTS1.Speak(ele(i), False )      
        End If
    Next
End Sub

You can also insert a pause between each word.
B4X:
Msg.replace(" ", " /P500 ")
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
No need to push such old Threads.The Thread is two years old.
 
Upvote 0
Top