I have found an Autohotkey script that I would like convert to use in MS and need a little help. It is a standard vbscript script inside and only a couple of lines. I have looked at the script for Merlin on the forum and have played with that, but it requires SAPI 4 and and the TTS speach engine which Microsoft has decided not to support. This uses SAPI 5 and it looks quite simple
TXT := "Something I want to say"
Speak:
TEMPFILE = %TEMP%\TALK.vbs
IfExist, %TEMPFILE%
FileDelete, %TEMPFILE%
FileAppend, Dim Talk`nSet Talk = WScript.CreateObject("SAPI.SpVoice")`nTalk.Speak "%TXT%", %TEMPFILE%
RunWait, %TEMPFILE%
FileDelete, %TEMPFILE%
Return
I just don't know how to covert it to MS so I can compile it.
Any help would be appriecated
Speaking Script
Moderators: Dorian (MJT support), JRL
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Temp files just to run VBScript? Try this:
Code: Select all
VBSTART
Sub Speak(text)
Dim Talk
Set Talk = CreateObject("SAPI.SpVoice")
Talk.Speak text
End Sub
VBEND
VBRun>Speak,Hello Keith
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Fun with MS - Joke Reader
Frist off,
Thanks Marcus,
I though I would contribute a working script (haven't done much of that in a while) so I used the speaking part that you helped me with.
This script will go out to Comedy Central's website using MS's HTTPRequest to randomly grab a page with a joke on it. At that point it will parse the text until only the joke is captured. The joke will be displayed in a window where it can be read or listened to.
It can be addictive
VBSTART
Sub Speak(text)
Dim Talk
Set Talk = CreateObject("SAPI.SpVoice")
Talk.Speak text
End Sub
VBEND
Let>JText=
Dialog>Dialog1
Caption=Read Text
Width=445
Height=250
Top=CENTER
Left=CENTER
Max=0
Min=0
Close=1
Resize=0
Memo=msMemo1,16,16,401,153,%JText%
Button=Get a Joke,16,184,75,25,1
Button=Listen to Text,90,184,75,25,3
Button=Exit,165,184,75,25,2
EndDialog>Dialog1
Show>Dialog1
Label>mainloop
GetDialogAction>Dialog1,dresult
IF>dresult=1,getjoke
IF>dresult=2,EOF
IF>dresult=3,Speakit
Wait>.1
Goto>mainloop
SRT>Speakit
VBRun>Speak,%Dialog1.msMemo1%
ResetDialogAction>Dialog1
End>Speakit
SRT>getjoke
Label>Runagain
Random>12000,rnumber
//Let>rnumber=1%DiceResult1%
Let>file=
DeleteFile>%TEMP_DIR%\test.txt
Let>HTTP_TIMEOUT=10
HTTPRequest>http://jokes.comedycentral.com/random_j ... MLResponse
IF>HTMLResponse=404 Error connecting to host
MDL>Unable to get a Joke - Will try again in 10 minutes
Wait>6000
Goto>Runagain
Else
WriteLn>%TEMP_DIR%\test.txt,result,HTMLResponse
Endif
Let>k=1
Label>start
ReadLn>%TEMP_DIR%\test.txt,k,line
If>line=##EOF##,finish
Position>,line,1,StartPos
If>StartPos>0
Let>z=k+1
Label>startreadjoke
ReadLn>%TEMP_DIR%\test.txt,z,line
If>line=##EOF##,finish
Position>,line,1,StartPos
If>StartPos>0,finish
Let>file=%file%%line%%CRLF%
Let>z=z+1
Goto>startreadjoke
Goto>finish
Endif
Let>k=k+1
Goto>start
Label>finish
If>%file%=
Goto>Runagain
Endif
StringReplace>file, ,,file
StringReplace>file,,%CRLF%,file
StringReplace>file,,,file
StringReplace>file,,,file
StringReplace>file,,,file
StringReplace>file,,,file
//StringReplace>file,. ,.%CRLF%,file
StringReplace>file,,,file
StringReplace>file,,,file
StringReplace>file,,,file
StringReplace>file,,,file
StringReplace>file, ,,file
StringReplace>file,",",file
StringReplace>file,,",file
StringReplace>file,,",file
StringReplace>file,Â,",file
StringReplace>file,?,%CRLF%,file
StringReplace>file,!,%CRLF%,file
StringReplace>file,“,,file
StringReplace>file,”,,file
StringReplace>file,,,file
StringReplace>file,,,file
StringReplace>file,,,file
StringReplace>file,Ã,,file
StringReplace>file,¢,,file
StringReplace>file,â,,file
StringReplace>file,¢,,file
StringReplace>file,",,file
DeleteFile>%TEMP_DIR%\joke.txt
WriteLn>%TEMP_DIR%\joke.txt,result,%file%
Readfile>%TEMP_DIR%\joke.txt,sayit
Let>Dialog1.msMemo1=%sayit%
ResetDialogAction>Dialog1
End>getjoke
Label>EOF
Exit>0
Thanks Marcus,
I though I would contribute a working script (haven't done much of that in a while) so I used the speaking part that you helped me with.
This script will go out to Comedy Central's website using MS's HTTPRequest to randomly grab a page with a joke on it. At that point it will parse the text until only the joke is captured. The joke will be displayed in a window where it can be read or listened to.
It can be addictive
VBSTART
Sub Speak(text)
Dim Talk
Set Talk = CreateObject("SAPI.SpVoice")
Talk.Speak text
End Sub
VBEND
Let>JText=
Dialog>Dialog1
Caption=Read Text
Width=445
Height=250
Top=CENTER
Left=CENTER
Max=0
Min=0
Close=1
Resize=0
Memo=msMemo1,16,16,401,153,%JText%
Button=Get a Joke,16,184,75,25,1
Button=Listen to Text,90,184,75,25,3
Button=Exit,165,184,75,25,2
EndDialog>Dialog1
Show>Dialog1
Label>mainloop
GetDialogAction>Dialog1,dresult
IF>dresult=1,getjoke
IF>dresult=2,EOF
IF>dresult=3,Speakit
Wait>.1
Goto>mainloop
SRT>Speakit
VBRun>Speak,%Dialog1.msMemo1%
ResetDialogAction>Dialog1
End>Speakit
SRT>getjoke
Label>Runagain
Random>12000,rnumber
//Let>rnumber=1%DiceResult1%
Let>file=
DeleteFile>%TEMP_DIR%\test.txt
Let>HTTP_TIMEOUT=10
HTTPRequest>http://jokes.comedycentral.com/random_j ... MLResponse
IF>HTMLResponse=404 Error connecting to host
MDL>Unable to get a Joke - Will try again in 10 minutes
Wait>6000
Goto>Runagain
Else
WriteLn>%TEMP_DIR%\test.txt,result,HTMLResponse
Endif
Let>k=1
Label>start
ReadLn>%TEMP_DIR%\test.txt,k,line
If>line=##EOF##,finish
Position>,line,1,StartPos
If>StartPos>0
Let>z=k+1
Label>startreadjoke
ReadLn>%TEMP_DIR%\test.txt,z,line
If>line=##EOF##,finish
Position>,line,1,StartPos
If>StartPos>0,finish
Let>file=%file%%line%%CRLF%
Let>z=z+1
Goto>startreadjoke
Goto>finish
Endif
Let>k=k+1
Goto>start
Label>finish
If>%file%=
Goto>Runagain
Endif
StringReplace>file, ,,file
StringReplace>file,,%CRLF%,file
StringReplace>file,,,file
StringReplace>file,,,file
StringReplace>file,,,file
StringReplace>file,,,file
//StringReplace>file,. ,.%CRLF%,file
StringReplace>file,,,file
StringReplace>file,,,file
StringReplace>file,,,file
StringReplace>file,,,file
StringReplace>file, ,,file
StringReplace>file,",",file
StringReplace>file,,",file
StringReplace>file,,",file
StringReplace>file,Â,",file
StringReplace>file,?,%CRLF%,file
StringReplace>file,!,%CRLF%,file
StringReplace>file,“,,file
StringReplace>file,”,,file
StringReplace>file,,,file
StringReplace>file,,,file
StringReplace>file,,,file
StringReplace>file,Ã,,file
StringReplace>file,¢,,file
StringReplace>file,â,,file
StringReplace>file,¢,,file
StringReplace>file,",,file
DeleteFile>%TEMP_DIR%\joke.txt
WriteLn>%TEMP_DIR%\joke.txt,result,%file%
Readfile>%TEMP_DIR%\joke.txt,sayit
Let>Dialog1.msMemo1=%sayit%
ResetDialogAction>Dialog1
End>getjoke
Label>EOF
Exit>0
I get the following error when I run Marcus' example.mtettmar wrote:Temp files just to run VBScript? Try this:
Code: Select all
VBSTART Sub Speak(text) Dim Talk Set Talk = CreateObject("SAPI.SpVoice") Talk.Speak text End Sub VBEND VBRun>Speak,Hello Keith
I've searched for several hours and installed several programs including Microsoft's Speech API but no luck.Microsoft VBScript runtime error: 429
ActiveX Component can't create object: 'SAPI.SpVoice'
Line 4, column 1
OS Name: Microsoft Windows7
Version: 6.1.7600 Service Pack 3 Build 7600
Any help or suggestions are appreciated.