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