Android Question Pause in TTS engine

Discussion in 'Android Questions' started by AlpVir, Jul 5, 2015.

  1. AlpVir

    AlpVir Well-Known Member Licensed 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"?
    Code:
    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.
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    There is no simple way to do it. You will need to use a timer to implement a pause.
     
  3. AlpVir

    AlpVir Well-Known Member Licensed 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
    Code:
    TTS1.Speak (Phrase, False)
    I think it is essential for short sentences and short delays.

    Code:
    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.
    Code:
    Msg.replace(" "" /P500 ")
     
    Last edited: Jul 6, 2015
    Phayao and Erel like this.
  4. clydebamford

    clydebamford Member Licensed User

    , , , , , , , the more comer spaces the longer the pause
     
  5. DonManfred

    DonManfred Expert Licensed User

    No need to push such old Threads.The Thread is two years old.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice