SpeechRecoContext Recognizer Property (SAPI 5.3)
The Recognizer property identifies the recognizer associated with the recognition context.
|Set:||(This property is read-only)|
|Get:||ISpeechRecognizer = SpeechRecoContext.Recognizer|
- The owning object.
Set: (This property is read-only)
Get: A SpeechRecognizer object that gets the value of the property.
RemarksThough it is usually acceptable to declare an object with the exact class name, ISpeechRecognizer is most often implemented as either SpSharedRecognizer or SpInprocRecognizer. Because it is not always known ahead of time which type of recognizer will be used, it is often safer to declare the object as Object.
The following Visual Basic form code demonstrates retrieving the recognizer associated with recognition context, both for a Shared and an InProc recognizer. To run this code, paste it into the Declarations section of a form that contains no controls.
Option Explicit Private Sub Form_Load() Dim RecoContext1 As SpInProcRecoContext Dim RecoContext2 As SpSharedRecoContext Dim Recognizer1 As SpInprocRecognizer Dim Recognizer2 As SpSharedRecognizer On Error GoTo EH Set RecoContext1 = New SpSharedRecoContext Set Recognizer1 = New SpSharedRecognizer Set Recognizer1 = RecoContext1.Recognizer MsgBox "Shared: " & Recognizer1.IsShared, vbInformation Set RecoContext2 = New SpInProcRecoContext Set Recognizer2 = New SpInprocRecognizer Set Recognizer2 = RecoContext2.Recognizer MsgBox "Shared: " & Recognizer2.IsShared, 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