mygrammar.CmdLoadFromFile 出错
Option ExplicitPublic WithEvents RC As SpSharedRecoContextPublic myGrammar As ISpeechRecoGrammar, b As ISpeechRecoGrammar
Private Sub Form_Load()
Set RC = New SpSharedRecoContextSet myGrammar = RC.CreateGrammar
myGrammar.CmdLoadFromFile "s:\Grammar.xml", SLODynamicmyGrammar.CmdSetRuleIdState 0, SGDSActive
End SubPrivate Sub RC_FalseRecognition(ByVal StreamNumber As Long, ByVal StreamPosition As Variant, ByVal Result As SpeechLib.ISpeechRecoResult)
Label1.Caption = "(不可识别信息)"
End Sub
Private Sub RC_Recognition(ByVal StreamNumber As Long, ByVal StreamPosition As Variant, ByVal RecognitionType As SpeechLib.SpeechRecognitionType, ByVal Result As SpeechLib.ISpeechRecoResult)Label1.Caption = Result.PhraseInfo.GetText
End Sub
grammar.xml 文件如下
<GRAMMAR LANGID="409">
<DEFINE>
<ID NAME="RID_NewGame" VAL="101"/>
</DEFINE> <RULE NAME="newgame" ID="RID_NewGame" TOPLEVEL="ACTIVE">
<L>
<P>start</P>
<P>net</P>
<P>end</P>
<P>stop</P>
<P> </P>
</L>
</RULE>
</GRAMMAR>
补充:VB , 多媒体