| You are reading help file online using chmlib.com | 
Interface: ISpeechRecoGrammar
The DictationSetState method sets the dictation topic state.
ISpeechRecoGrammar.DictationSetState(
     State As SpeechRuleState
)
None.
The following Visual Basic form code demonstrates the use of the DictationLoad, DictationSetState, and DictationUnload methods. It creates a grammar, configures the grammar to perform both dictation and command and control (C and C) recognition, and toggles between the two types of recognition.
To run this code, create a form with the following control:
Paste this code into the Declarations section of the form.
The Form_Load procedure creates a grammar object, associates it with the system dictation lexicon and the Solitaire C and C grammar, and begins recognition in dictation mode. The Command1_Click procedure toggles the recognition mode between dictation and C and C. The Form_Unload procedure unloads the dictation grammar and deactivates the C and C grammar.
Option Explicit
Dim C As SpeechLib.SpSharedRecoContext
Dim G As SpeechLib.ISpeechRecoGrammar
Private Sub Command1_Click()
    If Command1.Caption = "&Dictation" Then
        G.CmdSetRuleIdState 0, SGDSInactive     'C&C off
        G.DictationSetState SGDSActive          'Dictation on
        Command1.Caption = "&C and C"
    Else
        G.DictationSetState SGDSInactive        'Dictation off
        G.CmdSetRuleIdState 0, SGDSInactive     'C&C on
        Command1.Caption = "&Dictation"
    End If
End Sub
Private Sub Form_Load()
    'Create a RecoContext and its Grammar
    Set C = New SpSharedRecoContext
    Set G = C.CreateGrammar
    
    'Get dictation grammar and set it inactive
    G.DictationLoad "", SLOStatic
    G.DictationSetState SGDSInactive
    
    'Get Command & Control grammar, and set it inactive
    G.CmdLoadFromFile "C:\SOL.XML", SLOStatic
    G.CmdSetRuleIdState 0, SGDSInactive
    
    'Set dictation active and set up Command1.Caption
    G.DictationSetState SGDSActive
    Command1.Caption = "&C and C"
End Sub
Private Sub Form_Unload(Cancel As Integer)
    G.DictationUnload
    G.CmdSetRuleIdState 0, SGDSInactive
End Sub| You are reading help file online using chmlib.com |