Interface: ISpeechRecoContext
EventInterests Property
The EventInterests property specifies the types of events accepted by the SpeechRecoContext object.
An event interest is a filtering mechanism for each recognition context. By setting EventInterests, the recognition context allows or denies speech recognition engine events to reach the application. All, none or selected types of events my be filtered. By default, speech recognition allows all events except SREAudioLevel (a change in audio level).
Syntax
Set: | SpeechRecoContext.EventInterests = SpeechRecoEvents |
Get: | SpeechRecoEvents = SpeechRecoContext.EventInterests |
Parts
- SpeechRecoContext
- The owning object.
- SpeechRecoEvents
-
Set: One or more SpeechRecoEvents constants which set the property.
Get: A SpeechRecoEvents variable which gets the value of the property.
Remarks
href="VB_Enum_SpeechRecoEvents.htm">SpeechRecoEvents enumeration list. Each type of event is represented by its own enumerated value. The default value is 327,679 (all SpeechRecoEvents values except SREAudioLevel). The value passed in to EventInterests is the total of each of the events required for the application. For example:
SRESoundStart + SRERecognition
could be passed as the value. Alternatively the same two interests could be passed as the single value of 18; SRESoundStart (value 2) plus SRERecognition (value 16). Conversely, if the application retrieved the current event setting and the value was 1064, it indicates that three events are active. Only SREPhraseStart (value 8), SREHypothesis (value 32), and SREInterference (value 1024) add up to that 1064 value.
See SpVoice.EventInterests for additional details. SpVoice.EventInterests is a similar function but affects text-to-speech events.
Example
The following Visual Basic form code demonstrates reading and setting the event interest. To run this code, paste it into the Declarations section of a form that contains no controls.
Option Explicit
Private Sub Form_Load()
Dim EvtInterests As SpeechRecoEvents
Dim RecoContext As SpInProcRecoContext
Dim Recognizer As SpInprocRecognizer
On Error GoTo EH
Set Recognizer = New SpInprocRecognizer
Set RecoContext = Recognizer.CreateRecoContext
' Read default value of EventInterests:
EvtInterests = RecoContext.EventInterests
MsgBox "Default: " & EvtInterests, vbInformation
' Set EventInterests to combination of three values:
RecoContext.EventInterests = SRESoundStart + SREBookmark + SREFalseRecognition
EvtInterests = RecoContext.EventInterests
MsgBox EvtInterests, vbInformation
End
EH:
If Err.Number Then ShowErrMsg
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