Share via


SpVoice SpeakCompleteEvent method (SAPI 5.4)

Microsoft Speech API 5.4

Object: SpVoice
Type: Hidden

SpeakCompleteEvent Method

The SpeakCompleteEvent method gets an event handle from the voice that will be signaled when the voice finishes speaking.

The SpeakCompleteEvent method is similar to the WaitUntilDone method, but supports more sophisticated ways of waiting for the voice to finish speaking.

The WaitUntilDone method explicitly blocks program execution until the voice finishes. The SpeakCompleteEvent method does not block execution, but returns an event handle that can be used with API wait functions such as WaitForSingleObject.

Because these functions can wait for short periods of time, applications may be able to perform useful tasks while polling the event handle.

  
    SpVoice.SpeakCompleteEvent() As Long

Parameters

None.

Return Value

A Long variable containing the event handle.

Example

The following code snippet demonstrates the use of the SpeakCompleteEvent method. The asynchronous Speak call returns immediately, and causes the voice to begin speaking as a background process. The SpeakCompleteEvent method returns the event handle of the speaking process. This handle is passed to WaitForSingleObject, which waits for a completion signal from the process. When the background speaking process signals its completion, the call to WaitForSingleObject returns, and the program continues.

  Dim objVoice As SpeechLib.SpVoice
Dim lngHandle As Long
Dim lngRtn As Long
Const INFINITE = -1&

Set objVoice = New SpVoice
objVoice.Speak "please wait until this text has been spoken", SVSFlagsAsync

lngHandle = objVoice.SpeakCompleteEvent             'Get a handle on this stream
lngRtn = WaitForSingleObject(lngHandle, INFINITE)   'Wait for completion