You are reading help file online using chmlib.com
|
Object: SpVoice
The EventInterests property gets and sets the types of events received by the SpVoice object.
When a text-to-speech (TTS) engine speaks a stream of text, it is constantly detecting certain conditions in the stream, such as the completion of phonemes, words and sentences. When it detects one of these conditions, the engine is able to generate a component object model (COM) event that will be received by the voice object that enqueued the stream.
When the engine detects a potential event condition in a stream, it checks the EventInterests property of the voice that enqueued the stream. If that event type is included in the voice object's event interests, the engine will generate an event of that type.
In Visual Basic, it is necessary to use the WithEvents keyword when dimensioning an SpVoice object intended to receive events. The default setting of the EventInterests property is 33278, or 0x081FE, which represents the sum of all SpeechVoiceEvents constants except SVEAudioLevel (a change in audio level).
Set: | SpVoice.EventInterests = SpeechVoiceEvents |
Get: | SpeechVoiceEvents = SpVoice.EventInterests |
The values assigned to SpeechVoiceEvents constants are single-bit values, like 1, 2, 4, 8, 16, etc. Use a logical Or function to add them to EventInterests, and a logical XOr function to remove them. It should be noted that a logical Xor function does not zero a bit value, but toggles the value. Because of this, it is necessary to ensure that the bit value is set before attempting to zero it with an Xor.
Recognition contexts support an EventInterests property, which uses a similar syntax to specify interest in speech recognition events.
The following code snippet demonstrates the syntax of the EventInterests property. Interest in individual events is set and reset using logical Or and Xor statements.
Option Explicit
Dim WithEvents objVoice As SpeechLib.SpVoice
Private Sub Form_Load()
Set objVoice = New SpVoice
Call EventInterests
End Sub
Private Sub EventInterests()
'Add the SVEPhoneme constant to Event Interests
'Setting bit with logical 'Or' doesn't require testing.
objVoice.EventInterests = objVoice.EventInterests Or SVEPhoneme
'Remove the SVEViseme constant from Event Interests
'Zeroing bit with logical 'Xor' requires testing!
If (objVoice.EventInterests And SVEViseme) = SVEViseme Then
objVoice.EventInterests = objVoice.EventInterests Xor SVEViseme
End If
End Sub
You are reading help file online using chmlib.com
|