Interface: ISpeechVoiceStatus
ISpeechVoiceStatus
Example
The following code snippet demonstrates the use of all ISpeechVoiceStatus properties. To run this code, create a form with the following controls:
- A command button called Command1
- A list box called List1
Paste this code into the Declarations section of the form.
The Form_Load procedure creates a voice object. The Command1_Click procedure speaks two streams asynchronously, and adds status information into the list box every one-half second until both streams have been spoken.
Option Explicit
Private V As SpeechLib.SpVoice
Private Sub Command1_Click()
On Error GoTo EH
List1.Clear
'Enqueue two streams containing bookmarks:
V.Speak "this is stream number<bookmark mark='1one'/> one.", SVSFlagsAsync + SVSFIsXML
List1.AddItem "LastStreamNumberQueued is " & V.Status.LastStreamNumberQueued
DoEvents
V.Speak "this is stream number<bookmark mark='2two'/> two.", SVSFlagsAsync + SVSFIsXML
List1.AddItem "LastStreamNumberQueued is " & V.Status.LastStreamNumberQueued
DoEvents
Do
V.WaitUntilDone (500) 'Wait for 0.5 second so we won't get too many outputs
List1.AddItem ""
List1.AddItem "LastStreamNumberQueued is " & V.Status.LastStreamNumberQueued
List1.AddItem "CurrentStreamNumber is " & V.Status.CurrentStreamNumber
List1.AddItem "InputSentenceLength is " & V.Status.InputSentenceLength
List1.AddItem "InputSentencePosition is " & V.Status.InputSentencePosition
List1.AddItem "InputWordLength is " & V.Status.InputWordLength
List1.AddItem "InputWordPosition is " & V.Status.InputWordPosition
List1.AddItem "RunningState is " & V.Status.RunningState
List1.AddItem "LastBookmark is " & V.Status.LastBookmark
List1.AddItem "LastBookmarkId is " & V.Status.LastBookmarkId
List1.AddItem "VisemeId is " & V.Status.VisemeId
List1.AddItem "PhonemeId is " & V.Status.PhonemeId
List1.AddItem "LastHResult is " & V.Status.LastHResult
DoEvents
Loop Until V.Status.RunningState = SRSEDone 'Exit when voice stops
EH:
If Err.Number Then ShowErrMsg
End Sub
Private Sub Form_Load()
Set V = New SpVoice
End Sub
Private Sub ShowErrMsg()
' Declare identifiers:
Dim T As String
T = "Desc: " & Err.Description & vbNewLine
T = T & "Err #: " & Err.Number
MsgBox T, vbExclamation, "Run-Time Error"
End
End Sub