SpeechRecognizer Status Property (SAPI 5.3)
The Status property returns an object representing the status of the recognizer.
This method provides information for static features about the speech recognition (SR) engine such as the languages it supports. It also provides information for dynamic features such as current stream position the engine has recognized up to, and if the stream is actively being sent to the engine.
|Set:||(This property is read-only)|
|Get:||ISpeechRecognizerStatus = SpeechRecognizer.Status|
- The owning object.
Set: (This property is read-only)
Get: An ISpeechRecognizerStatus that gets the property.
This code example demonstrates the Status property. After creating an instance for a recognizer, the code retrieves information about the recognizer's status: the class ID that created the engine, the supported languages, (in decimal format), and the current device position.
To run this code, create a form with no controls. Paste this code into the Declarations section of the form.
Option Explicit Private Sub Form_Load() On Error GoTo EH Const NL = vbNewLine Dim i As Integer Dim myGrammar As ISpeechRecoGrammar Dim RC As SpSharedRecoContext Dim recoStatus As ISpeechRecognizerStatus Dim T As String Set RC = New SpSharedRecoContext Set myGrammar = RC.CreateGrammar myGrammar.DictationSetState SGDSActive Set recoStatus = RC.Recognizer.Status T = "Engine ID: " & recoStatus.ClsidEngine & NL ' Display supported languages-- For i = 0 To UBound(recoStatus.SupportedLanguages) T = T & "Supported Language ID: " T = T & recoStatus.SupportedLanguages(i) & NL Next i ' Display audio position. T = T & "Audio Position: " T = T & recoStatus.AudioStatus.CurrentDevicePosition MsgBox T, vbInformation 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