SpeechRecognizer State Property (Microsoft Speech Platform)

Microsoft Speech Platform SDK 11

Microsoft Speech Platform

Interface: ISpeechRecognizer

State Property

The State property returns the current state of the recognition engine.

The recognition engine may be in one of several states of audio processing. If active, the engine receives audio data and processes it. Likewise, if inactive, neither audio data nor additional processing takes place. See the enumeration SpeechRecognizerState for complete details of the states.


Syntax

Set: SpeechRecognizer.State = SpeechRecognizerState
Get: SpeechRecognizerState = SpeechRecognizer.State

Parts

SpeechRecognizer
The owning object.
SpeechRecognizerState
Set: A SpeechRecognizerState variable that sets the property.
Get: A SpeechRecognizerState variable that gets the property.

Example

This code example demonstrates the State property. After creating an instance for a recognizer, the code retrieves and then changes the processing state of the recognizer.

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

    Dim RC As SpSharedRecoContext
    Dim T As String

    Set RC = New SpSharedRecoContext

    With RC.Recognizer
        If .State = SRSActive Then
            .State = SRSInactive
            T = "Recognition engine's state has been" & vbNewLine
            T = T & "changed from SRSActive to SRSInactive."
        End If
    End With

    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