Zohar Posted February 12, 2012 Share Posted February 12, 2012 (edited) Hi I am trying to start with the simplest code for speech recognition, so later I can start improving it and making it more useful. I am trying this code: $RecoContext=ObjCreate("SAPI.SpSharedRecoContext") $SinkObject=ObjEvent($RecoContext,"MYEvent_") $Grammar = $RecoContext.CreateGrammar(1) $Grammar.DictationLoad $Grammar.DictationSetState(1) sleep(5000) $Grammar.DictationSetState(0) Func MYEvent_Recognition($StreamNumber,$StreamPosition,$RecognitionType,$Result) MsgBox(0,"",$Result.PhraseInfo.GetText) EndFunc My goal, is to have a simple program, that hears a word, and then outputs it with MsgBox.. When running it, I am getting: speechrecognition.au3 (3) : ==> Variable must be of type "Object".: $Grammar = $RecoContext.CreateGrammar(1) $Grammar = $RecoContext^ ERROR >Exit code: 1 Time: 0.340 What do I need to do to make it work? Edited February 13, 2012 by Zohar Link to comment Share on other sites More sharing options...
kylomas Posted February 12, 2012 Share Posted February 12, 2012 Zohar, I think that you are using a "class" as an "object" (see this MSDN link http://msdn.microsoft.com/en-us/library/ms723627(v=vs.85).aspx). Also, you should ALWAYS check return codes... Good Luck, kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Zohar Posted February 13, 2012 Author Share Posted February 13, 2012 (edited) Hi kylomasThank you for your reply.Actually I am using it right.. that waas not the problem.The problem was that I needed to install Microsoft Speech SDK 5.1:http://www.microsoft.com/downloads/detai...0ee-6583171b4530&displaylang=eAfter installed, that solved the problem.My program is now working, and what it does is it hears a word, and then outputs it via a MsgBox.Local $RecoContext =ObjCreate("SAPI.SpSharedRecoContext") If @Error Then Msgbox(0,"","Error Creating $RecoContext: "&@Error) Exit EndIf Local $SinkObject =ObjEvent($RecoContext,"MyEvent_") Local $Grammar =$RecoContext.CreateGrammar(1) $Grammar.DictationLoad $Grammar.DictationSetState(1) ;Start Listening Sleep(5000) $Grammar.DictationSetState(0) ;Stop Listening Func MyEvent_Recognition($StreamNumber,$StreamPosition,$RecognitionType,$Result) MsgBox(0,"",$Result.PhraseInfo.GetText) EndFunc Note that it needs training, via ControlPanel, Speech tab.This is the simplest implementation for Speech Recognition. For anyone who's starting, and succeeded with this one, and wants to advance,please see CyberZeroCool's article, for continuing: Edited February 13, 2012 by Zohar Link to comment Share on other sites More sharing options...
kylomas Posted February 13, 2012 Share Posted February 13, 2012 Zohar, Glad you got it working...I'll look forward to learning something from this thread, if it takes off kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Zohar Posted February 14, 2012 Author Share Posted February 14, 2012 "if it takes off"? So you mean the fact that it's working now is not taking off enough? Link to comment Share on other sites More sharing options...
Xandy Posted February 14, 2012 Share Posted February 14, 2012 I'm so busy finalizing my md5 license keys on Vista and probably Win7 too. I will defiantly look into this speech recognition. I just want to add once again and clarify that my gmail email account and my cricket carrier cell phone can communicate without my cell phone having internet (I do not paid for any internet feature on my phone). Speech recognition is awesome though, and if your only testing two tone button presses should be fool proof. I'm glad you have it working sounds really fun. Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) Link to comment Share on other sites More sharing options...
Zohar Posted February 17, 2012 Author Share Posted February 17, 2012 (edited) Hi Xandy Yes the method you mentioned in my other thread, that you send SMS, indeed does not require a Data Plan. Tho please remember that SMSes do cost money Edited February 17, 2012 by Zohar Link to comment Share on other sites More sharing options...
coffeeturtle Posted March 19, 2012 Share Posted March 19, 2012 I just wanted to say thank you for getting this to work! I can't wait to try it! I've been looking for a simple way to do this for a long time and my personal efforts weren't fruitful. Thank you. Hi kylomas Thank you for your reply. Actually I am using it right.. that waas not the problem. The problem was that I needed to install Microsoft Speech SDK 5.1: http://www.microsoft.com/downloads/detai...0ee-6583171b4530&displaylang=e After installed, that solved the problem. My program is now working, and what it does is it hears a word, and then outputs it via a MsgBox. Local $RecoContext =ObjCreate("SAPI.SpSharedRecoContext") If @Error Then Msgbox(0,"","Error Creating $RecoContext: "&@Error) Exit EndIf Local $SinkObject =ObjEvent($RecoContext,"MyEvent_") Local $Grammar =$RecoContext.CreateGrammar(1) $Grammar.DictationLoad $Grammar.DictationSetState(1) ;Start Listening Sleep(5000) $Grammar.DictationSetState(0) ;Stop Listening Func MyEvent_Recognition($StreamNumber,$StreamPosition,$RecognitionType,$Result) MsgBox(0,"",$Result.PhraseInfo.GetText) EndFunc Note that it needs training, via ControlPanel, Speech tab. This is the simplest implementation for Speech Recognition. For anyone who's starting, and succeeded with this one, and wants to advance, please see CyberZeroCool's article, for continuing: Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now