Share via


SpeechRecognizer CreateRecoContext Method (SAPI 5.3)

Microsoft Speech API 5.3

Interface: ISpeechRecognizer

CreateRecoContext Method

The CreateRecoContext method creates a recognition context object from the recognizer.

  
    SpeechRecognizer.CreateRecoContext() As ISpeechRecoContext

Parameters

None.

Return Value

The CreateRecoContext method returns an ISpeechRecoContext object.

Example

The following Visual Basic form code demonstrates the use of CreateRecoContext.

To run this code, create a form without any controls. Copy this code and paste it into the Declarations section of the form.

  
Option Explicit

Private Sub Form_Load()
    On Error GoTo EH

    Dim myContext As ISpeechRecoContext
    Dim SharedRecognizer As SpSharedRecognizer

    Set SharedRecognizer = New SpSharedRecognizer
    Set myContext = SharedRecognizer.CreateRecoContext
    MsgBox myContext.State, 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