SpVoice Skip method (Microsoft Speech Platform)

Microsoft Speech Platform SDK 11

Microsoft Speech Platform

Object: SpVoice

Skip Method

The Skip method skips the voice forward or backward by the specified number of items within the current input text stream.

SpVoice.Skip(
     Type As String,
     NumItems As Long
) As Long

Parameters

Type
The type of items to be skipped. Currently, Sentence is the only type supported.
NumItems
The number of items to be skipped forward in the voice input stream. A negative value specifies skipping backward.

Return Value

A Long variable containing the number of items skipped.


Example

The following Visual Basic form code demonstrates the use of the Skip method. To run this code, create a form with the following controls:

  • A text box called Text1
  • Two command buttons called Command1 and Command2
  • An HScrollbar control called HScroll1

Paste this code into the Declarations section of the form.

The Form_Load procedure creates a voice, sets up the HScrollbar with a value of -2 in a range from -5 to 5, and puts a string of numbers in the textbox. Because the numbers are followed by periods and separated by spaces, SAPI considers each number to be a sentence. The scrollbar specifies the number of sentences that the voice object will skip.

Click Command1 to start the voice speaking the sentences in the textbox. Click Command2 to skip the voice forward or backward, depending on the value of the scrollbar control. Click the left side or the right side of the scrollbar to increase or decrease the number of sentences to be skipped by the Command2 button.


Option Explicit

Private WithEvents V As SpeechLib.SpVoice

Private Sub Command1_Click()
    V.Speak Text1.Text, SVSFlagsAsync
End Sub

Private Sub Command2_Click()
    V.Skip "Sentence", HScroll1.Value
End Sub

Private Sub Form_Load()

    Set V = New SpVoice

    HScroll1.Min = -5
    HScroll1.Max = 5
    HScroll1.Value = -2

    Text1.Text = "1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20."

End Sub

Private Sub HScroll1_Change()
    If HScroll1.Value > 0 Then
        Command2.Caption = " Skip forward " & HScroll1.Value & " sentences"
    Else
        Command2.Caption = " Skip backward " & Abs(HScroll1.Value) & " sentences"
    End If
End Sub

Private Sub V_Word(ByVal StreamNumber As Long, ByVal StreamPosition As Variant, _
                   ByVal CharacterPosition As Long, ByVal Length As Long)
    Text1.SetFocus
    Text1.SelStart = CharacterPosition
    Text1.SelLength = Length
End Sub