Interface: ISpeechRecoGrammar
DictationLoad Method
The DictationLoad method loads a dictation topic into the grammar.
ISpeechRecoGrammar.DictationLoad(
[TopicName As String = ""],
[LoadOption As SpeechLoadOption = SLOStatic]
)
Parameters
- TopicName
- [Optional] Specifies a dictation topic. The default value is the empty string.
- LoadOption
- [Optional] Specifies whether the grammar is to be loaded for static or dynamic use. The default is static.
Return Value
None.
Remarks
SAPI currently defines one specialized dictation topic: SPTOPIC_SPELLING. SR engines are not required to support specialized dictation topics (including spelling). When using another manufacturer's SR engine, consult its documentation for details.
Example
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 a command button called Command1 and 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 inactivates 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