Option Explicit
Public WithEvents RC As SpSharedRecoContext
Public myGrammar As ISpeechRecoGrammar
Private Sub Form_Load()
Set RC = New SpSharedRecoContext
Set myGrammar = RC.CreateGrammar
'RC.Voice.GetVoices
myGrammar.CmdLoadFromFile App.Path & "/command.xml", SLODynamic
myGrammar.DictationSetState SGDSActive
End Sub
Private Sub RC_Recognition(ByVal StreamNumber As Long, ByVal StreamPosition As Variant, ByVal RecognitionType As SpeechLib.SpeechRecognitionType, ByVal Result As SpeechLib.ISpeechRecoResult)
Select Case Result.PhraseInfo.GetText
Case "上网"
Shell "C:/Program Files/Internet Explorer/IEXPLORE.EXE"
Case "开始"
Shell "D:/Program Files/Tencent/QQ/QQ.exe"
Case "音乐"
Shell "D:/Program Files/TTPlayer/TTPlayer.exe"
Case "下载"
Shell "D:/Program Files/Thunder Network/Thunder/Thunder.exe"
Case "BT下载"
Shell "D:/Program Files/BitComet/BitComet.exe"
'Case "重启"
'Case "关机"
Case Else
MsgBox "听不懂你说什么" & Result.PhraseInfo.GetText & ",再说一遍!"
End Select
End Sub