SpVoice Skip method (SAPI 5.3)
Microsoft Speech API 5.3
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
The type of items to be skipped. Currently, Sentence is the only type supported.
The number of items to be skipped forward in the voice input stream. A negative value specifies skipping backward.
A Long variable containing the number of items skipped.
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