Bert Posted June 23, 2006 Share Posted June 23, 2006 (edited) I made a script to mess with a coworker. I was wondering if I could get some help with one small thing, and it would be perfect. I want to get the beeps and the cdtray command to happen at the same time. (Make it look like the PC is having a "moment".) Here is the script.. expandcollapse popup_talk("Ronald?") _talk("You hot man!") _talk("You couldn't wait to touch my keyboard, you naughty boy") _talk("You know how to make my harddrive spin!") _talk("Oh!") _talk("My CD rom drive feels funny.") _talk("Oh!") _talk("JUST LIKE THAT!") _talk("YES") _talk("YES") _talk("I think") _talk("I'm going") _talk("to") CDtray("D:", "open") beep(300, 200) beep(500, 700) beep(150, 2000) CDtray("D:", "close") beep(300, 200) beep(500, 700) beep(250, 800) beep(600, 200) CDtray("D:", "open") beep(500, 700) beep(600, 200) CDtray("D:", "close") _talk("ah") _talk("that was good") _talk("do you have a cigarette?") Func _Talk($sText) $tempFile = @TempDir & '\talktemp.vbs' ; Set the temp file FileWriteLine($tempFile, 'Dim Talk' & @CRLF & _ 'Set Talk = WScript.CreateObject("SAPI.SpVoice")' & _ @CRLF & 'Talk.Speak "' & $sText & '"'); Add contents to the temp file RunWait('Wscript.exe talktemp.vbs', @TempDir); Run the VBScript FileDelete($tempFile) EndFunc Edited June 23, 2006 by vollyman The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
dirtymafia Posted June 23, 2006 Share Posted June 23, 2006 Beep(300,200) will wait 200ms before moving on to the next command. Beep(300,2000) would wait 2000ms before moving on. You could make the beep durations shorter? in order to make it seem like they are happening at the same time and then just put more of them. I'm not sure I understand what you are asking for exactly. Link to comment Share on other sites More sharing options...
Bert Posted June 23, 2006 Author Share Posted June 23, 2006 What happens is the beeps will run, then the CD rom will open. I want to have the beeps happen while the cdrom is opening, not one then the other. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Xenobiologist Posted June 23, 2006 Share Posted June 23, 2006 Hi, you could also increase the understandability of the speech with this speak func. #include <inet.au3> Dim $voice = ObjCreate("Sapi.SpVoice") Speak(@IPAddress1 , 0.75 , 100) MsgBox(0, "IP-Addresse", "Deine IP-Adresse lautet: " & @IPAddress1) Func Speak($Text, $Rate, $Vol) $voice.Rate = $Rate $voice.Volume = $Vol $voice.Speak($Text) EndFunc ;==>Speak So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Bert Posted June 23, 2006 Author Share Posted June 23, 2006 @mega: I like it! I put it in, but I needed to put in some sleep statements to make it more funny. Still like to figure out the beep thing. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
BigDaddyO Posted June 23, 2006 Share Posted June 23, 2006 You could also add this line into first line in Megas Function to make the voice Female. $voice.voice = $voice.GetVoices("Name=LH Michelle").Item(0) The Name= might be different on your pc. Microsoft Mary is in a lot of the online examples but I only had LH Michelle for female voices. Mike Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 23, 2006 Share Posted June 23, 2006 Hi, you could also increase the understandability of the speech with this speak func. #include <inet.au3> Dim $voice = ObjCreate("Sapi.SpVoice") Speak(@IPAddress1 , 0.75 , 100) MsgBox(0, "IP-Addresse", "Deine IP-Adresse lautet: " & @IPAddress1) Func Speak($Text, $Rate, $Vol) $voice.Rate = $Rate $voice.Volume = $Vol $voice.Speak($Text) EndFunc ;==>Speak So long, Mega Ooooh... that's interesting... I read up on SAPI at the Microsoft Scriptguy site, and tried this: expandcollapse popup_Speak("This is my speach test.", 0.9, 90, "Microsoft Mary") ; --------------------------- ; Function _Speak() ; Voice text reader using native SAPI ; Call with _Speak($sText, $iRate, $iVol, $sVoice) where: ; $sText = The text to read ; $iRate = (optional) the rate at which to read, 1=full speed (default), 0.5=slower ; $iVol = Volume percentage from 0 to 100 (default = 100, full) ; $sVoice = Name of the voice to use, by default only "Microsoft Sam" is loaded, ; optional voices like "Microsoft Mary" or "Microsoft Mike" may be present ; On success returns 1 ; On fail returns 0 and: ; @Error = 1, parameter error ; @Error = 2, object creation error ; @Error = 3, speaking error ; --------------------------- Func _Speak($sText, $iRate = 1, $iVol = 100, $sVoice = "Microsoft SAM") If IsString($sText) And IsNumber($iRate) And $iVol <= 100 And IsString($sVoice) Then Local $objSpeach = ObjCreate ("Sapi.SpVoice") If @error = 0 Then $objSpeach.GetVoices ("Name=" & $sVoice) $objSpeach.Rate = $iRate $objSpeach.Volume = $iVol $objSpeach.Speak ($sText) If @error = 0 Then Return 1 Else Return SetError(3, 0, 0) EndIf Else Return SetError(2, 0, 0) EndIf Else Return SetError(1, 0, 0) EndIf EndFunc ;==>_Speak But the selection of other voices doesn't work. Whichever voice is selected as default in the Speech control panel applet is used. Is my $objSpeach.GetVoices ("Name=" & $sVoice) call wrong? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
BigDaddyO Posted June 23, 2006 Share Posted June 23, 2006 But the selection of other voices doesn't work. Whichever voice is selected as default in the Speech control panel applet is used. Is my $objSpeach.GetVoices ("Name=" & $sVoice) call wrong? If you have windows XP go into Control panel, Speech, Text to Speech Tab. the Voice Selection Combo box is all the voices you have loaded. you should be able type into your ("Name=Voice From Combo")Mike. Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 23, 2006 Share Posted June 23, 2006 If you have windows XP go into Control panel, Speech, Text to Speech Tab. the Voice Selection Combo box is all the voices you have loaded. you should be able type into your ("Name=Voice From Combo")Mike.Huh? I'm on XP Pro SP2 with the SAPI5 SDK loaded. The control panel applet lists Microsoft Mary, Mike, and Sam. The issue is that the script function can't select them on the fly. Is it not possible with the object I used? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
BigDaddyO Posted June 23, 2006 Share Posted June 23, 2006 Huh? I'm on XP Pro SP2 with the SAPI5 SDK loaded. The control panel applet lists Microsoft Mary, Mike, and Sam. The issue is that the script function can't select them on the fly. Is it not possible with the object I used? This worked fine for me. it switches the voice to LH Michelle, which you may not have. you may need Microsoft Mary or whatever is listed in your Voice ComboBox. $voice = ObjCreate("Sapi.SpVoice") $voice.voice = $voice.GetVoices("Name=LH Michelle").Item(0) $voice.Rate = 1 $voice.Volume = 50 $voice.Speak("Hello, How are you doing?") Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 23, 2006 Share Posted June 23, 2006 This worked fine for me. it switches the voice to LH Michelle, which you may not have. you may need Microsoft Mary or whatever is listed in your Voice ComboBox. $voice = ObjCreate("Sapi.SpVoice") $voice.voice = $voice.GetVoices("Name=LH Michelle").Item(0) $voice.Rate = 1 $voice.Volume = 50 $voice.Speak("Hello, How are you doing?") Ahhh, so! I did screw it up! This is fixed as per your post, and the definition of rate is fixed per MSDN: expandcollapse popup_Speak("My name is Microsoft Mary. Rate is negative ten.", -10, 100, "Microsoft Mary") Sleep(1000) _Speak("My name is Microsoft Mike. Rate is zero.", 0, 100, "Microsoft Mike") Sleep(1000) _Speak("My name is Microsoft Sam. Rate is ten.", 10, 100, "Microsoft Sam") Sleep(1000) _Speak("My name is Microsoft Mary. Volume is thirty three.", 0, 33, "Microsoft Mary") Sleep(1000) _Speak("My name is Microsoft Mike. Volume is sixty six.", 0, 66, "Microsoft Mike") Sleep(1000) _Speak("My name is Microsoft Sam. Volume is one hundred.", 0, 100, "Microsoft Sam") ; --------------------------- ; Function _Speak() ; Voice text reader using native SAPI ; Call with _Speak($sText, $iRate, $iVol, $sVoice) where: ; $sText = The text to read ; $iRate = (optional) the rate at which to read, 10=fastest, 0=normal (default), -10=slowest ; $iVol = Volume from 0 to 100 (default = 100, full) ; $sVoice = Name of the voice to use, by default only "Microsoft Sam" is loaded, ; optional voices like "Microsoft Mary" or "Microsoft Mike" may be present ; On success returns 1 ; On fail returns 0 and: ; @Error = 1, parameter error ; @Error = 2, object creation error ; @Error = 3, speaking error ; --------------------------- Func _Speak($sText, $iRate = 1, $iVol = 100, $sVoice = "Microsoft SAM") If IsString($sText) And IsNumber($iRate) And $iVol <= 100 And IsString($sVoice) Then Local $objSpeech = ObjCreate ("Sapi.SpVoice") If @error = 0 Then $ObjSpeech.Voice = $objSpeech.GetVoices ("Name=" & $sVoice).Item (0) $objSpeech.Rate = $iRate $objSpeech.Volume = $iVol $objSpeech.Speak ($sText) If @error = 0 Then Return 1 Else Return SetError(3, 0, 0) EndIf Else Return SetError(2, 0, 0) EndIf Else Return SetError(1, 0, 0) EndIf EndFunc ;==>_Speak Thanks! Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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