Object: SpVoice (Events)
Bookmark Event
The Bookmark event occurs when the text-to-speech (TTS) engine detects a bookmark while speaking a stream for the SpVoice object.
It should be noted that Bookmark events may not be synchronized with the actual speaking of the words in text streams containing bookmarks. In some circumstances, TTS buffering considerations may cause a Bookmark event to be received sooner than the voice speaks the word preceding the bookmark in the text stream.
SpVoice.Bookmark(
StreamNumber As Long,
StreamPosition As Variant,
Bookmark As String,
BookmarkId As Long
)
Parameters
- StreamNumber
- The stream number which generated the event. When a voice enqueues more than one stream by speaking asynchronously, the stream number is necessary to associate an event with the appropriate stream.
- StreamPosition
- The character position in the output stream at which the bookmark occurs.
- Bookmark
- The string value of the Mark attribute within the bookmark.
- BookmarkId
- The string value of the leading (left-most) numeric characters in the Mark attribute within the bookmark.
Example
The following Visual Basic form code demonstrates the use of the Bookmark event. To run this code, create a form with the following controls:
- A command button called Command1
- A text box called Text1
Paste this code into the Declarations section of the form.
The Form_Load code creates an SpVoice object. The Command1_Click procedure enqueues a short sentence containing a bookmark. The Bookmark event code displays the values of the BookmarkId and Bookmark parameters in Text1.
Option Explicit
Public WithEvents vox As SpeechLib.SpVoice
Private Sub Command1_Click()
Dim strTemp As String
strTemp = "this is text <BOOKMARK mark='123456.789 abcdefg' /> with a bookmark."
vox.Speak strTemp, SVSFlagsAsync + SVSFIsXML
End Sub
Private Sub Form_Load()
Set vox = New SpVoice
End Sub
Private Sub vox_Bookmark(ByVal StreamNumber As Long, ByVal StreamPosition As Variant, _
ByVal Bookmark As String, ByVal BookmarkId As Long)
Text1.Text = "BookmarkId: """ & BookmarkId & """, Bookmark: """ & Bookmark & """"
End Sub