SpVoice Pause method

Microsoft Speech SDK

Intelligent Interface Technologies Home Page Microsoft Speech SDK

Speech Automation 5.1

Object: SpVoice

Pause Method

The Pause method pauses the voice at the nearest alert boundary and closes the output device, allowing it to be used by other voices.


SpVoice.Pause()

Parameters

None.

Return Value

None.


Example

The following Visual Basic form code demonstrates the use of the Pause and Resume methods. To run this code, create a form with the following control:

  • A command button called Command1
  • Paste this code into the Declarations section of the form.

    The Form_Load procedure creates a voice object. The first call of the Command1_Click procedure causes the voice to begin speaking a text stream. Subsequent Command1 clicks alternately pause and resume the voice. When the voice has finished speaking the stream, the EndStream causes the voice to speak it again.

    The voice's AlertBoundary setting of SVEPhoneme means that the Pause method can interrupt the voice within word boundaries. The text stream spoken contains a number of long words in order to show this interruption of words more clearly.


    Option Explicit
    
    Private WithEvents V As SpeechLib.SpVoice
    
    Private Sub Command1_Click()
    
        Select Case Command1.Caption
        
        Case "Start"
            Call SpeakAgain
            Command1.Caption = "Pause"
            
        Case "Pause"
            V.Pause
            Command1.Caption = "Resume"
            
        Case "Resume"
            V.Resume
            Command1.Caption = "Pause"
            
        End Select
        
    End Sub
    
    Private Sub Form_Load()
    
        Set V = New SpVoice
        V.AlertBoundary = SVEPhoneme    'Let words be interrupted
        Command1.Caption = "Start"
        
    End Sub
    
    Private Sub V_EndStream(ByVal StreamNumber As Long, ByVal StreamPosition As Variant)
        Call SpeakAgain
    End Sub
    
    Private Sub SpeakAgain()
        V.Speak "this phenomenal asynchronous stream contains multisyllabic " _
                & "pronunciations and circumlocutions.", SVSFlagsAsync
    End Sub