I put together a simple speech recognizer. It works fine, but when I click the X to close it, it takes forever to unload... can I do anything about it?
Dim WithEvents RecoContext As SpInProcRecoContext 'RC
Dim Grammar As ISpeechRecoGrammar
Dim Recognizer As SpInprocRecognizer
Private Sub Form_Unload(Cancel As Integer)
Set RecoContext = Nothing 'these did not work =(
Set Grammar = Nothing ' =(
Set Recognizer = Nothing ' =(
End Sub
Private Sub RecoContext_Recognition(ByVal StreamNumber As Long, ByVal StreamPosition As Variant, ByVal RecognitionType As SpeechRecognitionType, ByVal Result As ISpeechRecoResult)
Dim strText As String
strText = Result.PhraseInfo.GetText(0, -1, True)
Select Case strText
Case "calculator"
MsgBox "calc.exe"
End Select
End Sub
Private Sub Form_Load()
Dim Category As SpObjectTokenCategory
Dim Token As SpObjectToken
Set RecoContext = New SpInProcRecoContext
Set Recognizer = RecoContext.Recognizer
Set Grammar = RecoContext.CreateGrammar(1)
Grammar.CmdLoadFromFile App.Path & "\grammar.xml", SLOStatic
Grammar.DictationSetState SGDSInactive
Grammar.CmdSetRuleIdState 1, SGDSActive
Set Category = New SpObjectTokenCategory
Category.SetId SpeechCategoryAudioIn
Set Token = New SpObjectToken
Token.SetId Category.Default()
Set Recognizer.AudioInput = Token
End Sub
thanks =)