Speech recognizer program closes very slow

Reply

Join Date: Jan 2008
Posts: 87
Reputation: VBNick is an unknown quantity at this point 
Solved Threads: 1
VBNick VBNick is offline Offline
Junior Poster in Training

Speech recognizer program closes very slow

 
0
  #1
Mar 29th, 2009
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?
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim WithEvents RecoContext As SpInProcRecoContext 'RC
  2. Dim Grammar As ISpeechRecoGrammar
  3. Dim Recognizer As SpInprocRecognizer
  4. Private Sub Form_Unload(Cancel As Integer)
  5. Set RecoContext = Nothing 'these did not work =(
  6. Set Grammar = Nothing ' =(
  7. Set Recognizer = Nothing ' =(
  8. End Sub
  9. Private Sub RecoContext_Recognition(ByVal StreamNumber As Long, ByVal StreamPosition As Variant, ByVal RecognitionType As SpeechRecognitionType, ByVal Result As ISpeechRecoResult)
  10. Dim strText As String
  11. strText = Result.PhraseInfo.GetText(0, -1, True)
  12.  
  13. Select Case strText
  14. Case "calculator"
  15. MsgBox "calc.exe"
  16. End Select
  17. End Sub
  18. Private Sub Form_Load()
  19. Dim Category As SpObjectTokenCategory
  20. Dim Token As SpObjectToken
  21.  
  22. Set RecoContext = New SpInProcRecoContext
  23. Set Recognizer = RecoContext.Recognizer
  24. Set Grammar = RecoContext.CreateGrammar(1)
  25.  
  26. Grammar.CmdLoadFromFile App.Path & "\grammar.xml", SLOStatic
  27. Grammar.DictationSetState SGDSInactive
  28. Grammar.CmdSetRuleIdState 1, SGDSActive
  29.  
  30. Set Category = New SpObjectTokenCategory
  31. Category.SetId SpeechCategoryAudioIn
  32. Set Token = New SpObjectToken
  33. Token.SetId Category.Default()
  34. Set Recognizer.AudioInput = Token
  35. End Sub

thanks =)
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 1,217
Reputation: vb5prgrmr will become famous soon enough vb5prgrmr will become famous soon enough 
Solved Threads: 220
vb5prgrmr vb5prgrmr is offline Offline
Nearly a Posting Virtuoso

Re: Speech recognizer program closes very slow

 
0
  #2
Mar 29th, 2009
Don't know if it will help... but do your object have a close method or other house keeping call you can make before you set them to nothing? Or if you are worried about your form staying up, just add a me.hide before you do your current code.

Good Luck
If anyone has helped you solve your problem, please mark your thread as solved.

Thanks
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 87
Reputation: VBNick is an unknown quantity at this point 
Solved Threads: 1
VBNick VBNick is offline Offline
Junior Poster in Training

Re: Speech recognizer program closes very slow

 
0
  #3
Mar 30th, 2009
strange....it only seems to happen sometimes...it will hang for like 3 or 4 seconds on closing..

this seems to help, if I stick it in Form_Unload, so thanks =) I think it may be that the recognition has a timeout or something...I tried snapping my fingers and making some noise before closing it and it froze for a few seconds...LoL forgot the doevents? =/

'SpInProcRecoContext
RecoContext.Pause
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 87
Reputation: VBNick is an unknown quantity at this point 
Solved Threads: 1
VBNick VBNick is offline Offline
Junior Poster in Training

Re: Speech recognizer program closes very slow

 
0
  #4
Mar 30th, 2009
I stuck one of these in there just to make sure too:
Grammar.CmdSetRuleIdState 1, SGDSInactive
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Visual Basic 4 / 5 / 6 Forum


Views: 520 | Replies: 3
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC