ConsultingJoe Posted February 24, 2006 Posted February 24, 2006 (edited) OK, I took one I found in the support forum and shrunk it way down and made it easier.If you get a error about how it can't create object then goto control panel setup microphone and train it really quick, If you don't have Speech Recognition download it from microsofts site:http://www.microsoft.com/speech/download/sdk51/This should be the exact file:http://download.microsoft.com/download/spe...speechsdk51.exe (68MB)Compiled write.exeIts 2 scripts one compiled and you need to pause a second to speak againThe first script will be compiled to write.exe and the second script can be anything. make sure you have to write.exe in the same dirgive it a trycurrent commands:Change VoiceHelloExitwrite.exe#NoTrayIcon $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) $file = FileOpen ( "heard.txt", 2) FileWrite ( $file, $Result.PhraseInfo.GetText ) FileClose ( $file ) exit EndFuncmain scriptCODEAutoItSetOption ( "TrayAutoPause", 0)Local $o_speech = ObjCreate ("SAPI.SpVoice")$voice = $o_speech.GetVoices().Item(1)$o_speech.Voice = $voiceGlobal $textWhile 1 gettext() TrayTip ( "Heard:", $text, 5, 1 ) Select Case $text = "exit" $o_speech.Speak ('<rate speed="4">' & 'goodbye' & '</rate>', 8) Exit Case $text = "hello" TrayTip ( "Respond", "Hi There", 5, 1 ) $o_speech.Speak ('<rate speed="4">' & $text & '</rate>', 8) Sleep(300) Case $text = "change voice" $o_speech.Speak ('<rate speed="4">' & 'Mary, Mike, or Sam' & '</rate>', 8) gettext() Select case $text = "mary" $voice = $o_speech.GetVoices().Item(1) $o_speech.Voice = $voice $o_speech.Speak ('<rate speed="4">' & 'Mary' & '</rate>', 8) case $text = "mike" $voice = $o_speech.GetVoices().Item(2) $o_speech.Voice = $voice $o_speech.Speak ('<rate speed="4">' & 'mike' & '</rate>', 8) case $text = "sam" $voice = $o_speech.GetVoices().Item(3) $o_speech.Voice = $voice $o_speech.Speak ('<rate speed="4">' & 'sam' & '</rate>', 8) case Else $o_speech.Speak ('<rate speed="4">' & 'The Voice Was Not changed' & '</rate>', 8) EndSelect case else TrayTip ( $voice.GetAttribute("Name"), $text, 5, 1 ) $o_speech.Speak ('<rate speed="4">' & $text & '</rate>', 8) EndSelect WEndFunc OnAutoItExit ( )FileDelete ( @ScriptDir & "\heard.txt" )EndFuncFunc gettext()RunWait(@ScriptDir & "\write.exe") $file = FileOpen ( "heard.txt", 0 ) $text = FileRead ($file ) FileClose ( $file ) $file = FileOpen ( "heard.txt", 2 ) FileWrite ($file, "") FileClose ( $file ) EndFuncAnd here's the original code:CODEGlobal $recog = "PLEASE SPEAK NOW" ;SET GLOBAL$RecoContext=ObjCreate("SAPI.SpSharedRecoContext")if @error then Msgbox(0,"","Error opening $RecoContext: " & @error);ERROR CHECK exitendif$SinkObject=ObjEvent($RecoContext,"MYEvent_") $SPRS_INACTIVE = 0 $SPRS_ACTIVE = 1 $SGDSActive=$SPRS_ACTIVE $SGDSInactive=$SPRS_INACTIVE $Grammar = $RecoContext.CreateGrammar(1) $Grammar.Dictationload $Grammar.DictationSetState($SGDSActive);LISTENwhile 1 Sleep(100)if $recog <> "" ThenSelectCase $recog = "exit" exit;HEAR EXITCase $recog = "hello" MsgBox(0,"hi","HI",1);HEAR HELLOCase $recog = "I love you" MsgBox(0,"","I love you too",1)Case $recog = "test" MsgBox(0,"","What are you testing LOSER",1)EndSelect ;_talkOBJ($recog, 3); TALKS AFTER IT HEARS SOMETHING, The mic hears the pc and affects the recognition _talkOBJ($recog, 3, "dont talk"); JUST POP-UPEndif $recog = "";SET TO NULL FOR REPEATED COMMANDS WEnd ;$Grammar.DictationSetState($SGDSInactive);STOP LITENING Func MYEvent_Recognition($StreamNumber,$StreamPosition,$RecognitionType,$Result) $recog = $Result.PhraseInfo.GetText;SET $recog VAREndFuncFunc _TalkOBJ($s_text, $s_voice = 3, $s_dont = "")Local $quite = 0 Local $o_speech = ObjCreate ("SAPI.SpVoice") Select Case $s_voice == 1 $o_speech.Voice = $o_speech.GetVoices("Name=Microsoft Mary", "Language=409").Item(0) TrayTip("Female Reader",$s_text,1) Case $s_voice == 2 $o_speech.Voice = $o_speech.GetVoices("Name=Microsoft Mike", "Language=409").Item(0) TrayTip("Male Reader",$s_text,1) Case $s_voice == 3 $o_speech.Voice = $o_speech.GetVoices("Name=Microsoft Sam", "Language=409").Item(0) TrayTip("OldMan Reader",$s_text,1) EndSelectif $s_dont <> "dont talk" then $o_speech.Speak ($s_text) $o_speech = ""ENDif Sleep(1000) TrayTip("","",1)EndFunc ;==>_TalkOBJ Edited March 12, 2006 by zerocool60544 Check out ConsultingJoe.com
ConsultingJoe Posted February 25, 2006 Author Posted February 25, 2006 Thats so ODD no one is interested in SR WHY IT IS SO GREAT Check out ConsultingJoe.com
theguy0000 Posted February 26, 2006 Posted February 26, 2006 no. The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN
Pa Callender Posted March 5, 2006 Posted March 5, 2006 I would like to create an AI-SR-TTS system for my computer without spending any money. I could combine this script with a self-created MS Agent script, and also the "AIML Bot!" script by theguy0000, with slight additions (variables and learning). Hey, I could entertain my friends with this! [size="4"]YOU SHALL NOT PARSE!![/size]
ConsultingJoe Posted March 5, 2006 Author Posted March 5, 2006 I would like to create an AI-SR-TTS system for my computer without spending any money. I could combine this script with a self-created MS Agent script, and also the "AIML Bot!" script by theguy0000, with slight additions (variables and learning). Hey, I could entertain my friends with this!That sounds cool, Could you please help us figure out why it stops listening after a while Check out ConsultingJoe.com
theguy0000 Posted March 5, 2006 Posted March 5, 2006 hey, now that would be a great idea to put SR into my "AIML Bot"...and I could make it talk too. The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN
ConsultingJoe Posted March 5, 2006 Author Posted March 5, 2006 hey, now that would be a great idea to put SR into my "AIML Bot"...and I could make it talk too.hey, by the way, i was just checking out yout bot script very nice, do you know if there is a very big full brain file i can play with??? Check out ConsultingJoe.com
theguy0000 Posted March 5, 2006 Posted March 5, 2006 well, there's always ALICE, but it is very, very, very big, and it takes a really long time to load...but I can get it for you if you want. The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN
ConsultingJoe Posted March 5, 2006 Author Posted March 5, 2006 well, there's always ALICE, but it is very, very, very big, and it takes a really long time to load...but I can get it for you if you want.Yeah that would be cool thanks, and do you know about sr. because i have change and messed with everything to get it to continue listening. would you know what to doheres and exampleYou can say Sam, Mary, Mike, and ExitCODE$RecoContext=ObjCreate("SAPI.SpSharedRecoContext")if @error then Msgbox(0,"","Error opening $RecoContext: " & @error) exitendif$SinkObject=ObjEvent($RecoContext,"MYEvent_") $SPRS_INACTIVE = 0 $SPRS_ACTIVE = 1 $SGDSActive=$SPRS_ACTIVE $SGDSInactive=$SPRS_INACTIVE $Grammar = $RecoContext.CreateGrammar(1) $Grammar.Dictationload $Grammar.DictationSetState($SGDSActive) Global $recog, $s_voice = 3While 1Sleep(1000)WEndFunc MYEvent_Recognition($StreamNumber,$StreamPosition,$RecognitionType,$Result) $recog = $Result.PhraseInfo.GetText Select Case $Result.PhraseInfo.GetText = "exit" exit Case $Result.PhraseInfo.GetText = "Mary" $s_voice = 1 _TalkOBJ("Hello, Mary here", $s_voice) Case $Result.PhraseInfo.GetText = "Mike" $s_voice = 2 _TalkOBJ("Hello, Mike here", $s_voice) Case $Result.PhraseInfo.GetText = "Sam" $s_voice = 3 _TalkOBJ("Hello, Sam here", $s_voice) Case else _TalkOBJ($Result.PhraseInfo.GetText, $s_voice) EndSelect EndFunc Func _TalkOBJ($s_text, $s_voice = 3) $Grammar.DictationSetState($SGDSInactive)Local $quite = 0 Local $o_speech = ObjCreate ("SAPI.SpVoice") Select Case $s_voice == 0 Return Case $s_voice == 1 $o_speech.Voice = $o_speech.GetVoices("Name=Microsoft Mary", "Language=409").Item(0) TrayTip("MARY",$s_text,1) Case $s_voice == 2 $o_speech.Voice = $o_speech.GetVoices("Name=Microsoft Mike", "Language=409").Item(0) TrayTip("MIKE",$s_text,1) Case $s_voice == 3 $o_speech.Voice = $o_speech.GetVoices("Name=Microsoft Sam", "Language=409").Item(0) TrayTip("SAM",$s_text,1) EndSelect $o_speech.Speak ($s_text) $o_speech = "" Sleep(1000) TrayTip("","",1) $Grammar.DictationSetState($SGDSActive)EndFunc ;==>_TalkOBJ Check out ConsultingJoe.com
theguy0000 Posted March 5, 2006 Posted March 5, 2006 these SR scripts just aren't working for me...it never recognizes what I say. I have SR installed from the link you gave me, and I trained it. Microsoft's Dictation Pad program works great, but these scripts just arent doing anything. The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN
ConsultingJoe Posted March 5, 2006 Author Posted March 5, 2006 (edited) these SR scripts just aren't working for me...it never recognizes what I say.I have SR installed from the link you gave me, and I trained it.Microsoft's Dictation Pad program works great, but these scripts just arent doing anything.umm, if you have a mic in you task bar make sure it is on that gave me problemsyou didn't get an error though right???and make sure you have 5.1sdk, the link is at the top Edited March 5, 2006 by zerocool60544 Check out ConsultingJoe.com
theguy0000 Posted March 5, 2006 Posted March 5, 2006 hmm, no mic in the task bar... The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN
ConsultingJoe Posted March 5, 2006 Author Posted March 5, 2006 (edited) hmm, no mic in the task bar...And you have 5.1 sdktry this scriptCODE; AutoItCOM 3.1.1.x beta;; COM Test file;; Test usage of Events with SAPI;; NOTE: To be able to run this example, you must first; download and install the Microsoft SAPI SDK 5.1; http://www.microsoft.com/speech/download/sdk51/;; See also: http://www.microsoft.com/speech/techinfo/apioverview/;; And..READ the documentation carefully! Speech recognition is very complex stuff !#include "GUIConstants.au3"; Create a simple GUI for our outputGUICreate ( "Event Speech API Test", 640, 480 )$GUIEdit=GUICtrlCreateEdit ( "Debug Log:" & @CRLF, 10, 10 , 600 , 400 )GUISetState () ;Show GUI$RecoContext=ObjCreate("SAPI.SpSharedRecoContext")if @error then Msgbox(0,"","Error opening $RecoContext: " & @error) exitendif; Initialize our Event Handler; Note: The default outgoing event interface will be: _ISpeechRecoContextEvents$SinkObject=ObjEvent($RecoContext,"MYEvent_")if @error then GUICtrlSetData ( $GUIEdit, "ObjEvent error: " & @error & @CRLF , "append" )else GUICtrlSetData ( $GUIEdit, "ObjEvent created Successfully!" & @CRLF , "append" );Imported from: SAPI.H $SPRS_INACTIVE = 0 $SPRS_ACTIVE = 1 $SGDSActive=$SPRS_ACTIVE $SGDSInactive=$SPRS_INACTIVE $Grammar = $RecoContext.CreateGrammar(1) $Grammar.Dictationload $Grammar.DictationSetState($SGDSActive); Dictation starts here...you may speak now ! GUICtrlSetData ( $GUIEdit, "You have 10 seconds speaking time now...open your microphone and say something !" & @CRLF , "append" ) sleep(10000) ; Stop dictation $Grammar.DictationSetState($SGDSInactive)endif sleep (5000); Some events arrive late... GUICtrlSetData ( $GUIEdit, @CRLF & "End of dictation time." & @CRLF , "append" ) GUICtrlSetData ( $GUIEdit, "You may close this window now !" & @CRLF , "append" ) ; Waiting for user to close the window While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend GUIDelete () exit;--------------------; SAPI Event functionsFunc MYEvent_StartStream($StreamNumber, $StreamPosition); StreamNumber As Long,; StreamPosition As VariantGUICtrlSetData ( $GUIEdit, "StartStream(): StreamNumber is:" & $StreamNumber & @CRLF , "append" )EndFuncFunc MYEvent_Hypothesis($StreamNumber,$StreamPosition,$Result ); StreamNumber As Long,; StreamPosition As Variant,; Result As ISpeechRecoResultGUICtrlSetData ( $GUIEdit, "Hypothesis(): Hypothized text is: " & $Result.PhraseInfo.GetText & @CRLF , "append" )EndFuncFunc MYEvent_Interference($StreamNumber,$StreamPosition,$Interference); StreamNumber As Long,; StreamPosition As Variant,; Interference As SpeechInterferenceGUICtrlSetData ( $GUIEdit, "Interference(): StreamNumber is:" & $StreamNumber & @CRLF , "append" )EndFuncFunc MYEvent_Recognition($StreamNumber,$StreamPosition,$RecognitionType,$Result)GUICtrlSetData ( $GUIEdit, "Recognition(): Recognized text is: " & $Result.PhraseInfo.GetText & @CRLF , "append" )_TalkOBJ($Result.PhraseInfo.GetText, 3)sleep(2000)EndFuncFunc MYEvent_SoundEnd($StreamNumber,$StreamPosition)EndFuncFunc MYEvent_EndStream($StreamNumber,$StreamPosition,$StreamReleased)EndFuncFunc MYEvent_SoundStart($StreamNumber,$StreamPosition)EndFuncFunc MYEvent_PhraseStart($StreamNumber,$StreamPosition)EndFuncFunc _TalkOBJ($s_text, $s_voice = 3)Local $quite = 0 Local $o_speech = ObjCreate ("SAPI.SpVoice") Select Case $s_voice == 0 Return Case $s_voice == 1 $o_speech.Voice = $o_speech.GetVoices("Name=Microsoft Mary", "Language=409").Item(0) TrayTip("Female Reader",$s_text,1) Case $s_voice == 2 $o_speech.Voice = $o_speech.GetVoices("Name=Microsoft Mike", "Language=409").Item(0) TrayTip("Male Reader",$s_text,1) Case $s_voice == 3 $o_speech.Voice = $o_speech.GetVoices("Name=Microsoft Sam", "Language=409").Item(0) TrayTip("OldMan Reader",$s_text,1) EndSelect $o_speech.Speak ($s_text) $o_speech = "" Sleep(1000) TrayTip("","",1)EndFunc ;==>_TalkOBJ Edited March 5, 2006 by zerocool60544 Check out ConsultingJoe.com
theguy0000 Posted March 5, 2006 Posted March 5, 2006 Debug Log: ObjEvent created Successfully! You have 10 seconds speaking time now...open your microphone and say something ! StartStream(): StreamNumber is:1 End of dictation time. You may close this window now ! It didn't recognize anything... but, like I said, still no mic in the taskbar The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN
ConsultingJoe Posted March 5, 2006 Author Posted March 5, 2006 Debug Log: ObjEvent created Successfully! You have 10 seconds speaking time now...open your microphone and say something ! StartStream(): StreamNumber is:1 End of dictation time. You may close this window now ! It didn't recognize anything... but, like I said, still no mic in the taskbarwow I don't know then, you don't have to have a mic in the task but it happens. um what I would say is make sure the SR engine is set to 5.1sdk and shutoff any other SR programs and tell me what that script said when you ran it Check out ConsultingJoe.com
theguy0000 Posted March 5, 2006 Posted March 5, 2006 hmm, it turned out to be a music program I had running...which is really wierd considering that program doesn't even use SR... anyway, the test script you just gave me works, but none of the other scripts do... The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN
ConsultingJoe Posted March 5, 2006 Author Posted March 5, 2006 hmm, it turned out to be a music program I had running...which is really wierd considering that program doesn't even use SR...anyway, the test script you just gave me works, but none of the other scripts do...I don't know man, sorry Check out ConsultingJoe.com
theguy0000 Posted March 5, 2006 Posted March 5, 2006 I got it to work...I guess I wasn't talking clearly enough or something. but I have a queestion... ase $recog = "exit" exit;HEAR EXIT Case $recog = "hello" MsgBox(0,"hi","HI",1);HEAR HELLO Case $recog = "I love you" MsgBox(0,"","I love you too",1) Case $recog = "test" MsgBox(0,"","What are you testing LOSER",1) where on earth is $recog defined? I see [[Global $recog = "PLEASE SPEAK NOW" ;SET GLOBAL]] but nothing else...how does it know what the user says? The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN
ConsultingJoe Posted March 5, 2006 Author Posted March 5, 2006 Func MYEvent_Recognition($StreamNumber,$StreamPosition,$RecognitionType,$Result) $recog = $Result.PhraseInfo.GetText Right there, when the script recognizes a word or phrase the MYEvent_Recognition func is call which then sets the $recog var Check out ConsultingJoe.com
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