Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html>
- <head>
- <meta charset=utf-8 />
- <meta http-equiv="x-ua-compatible" content="IE=9" />
- <!--
- This is an HTML Application.
- While it's in HTML format, it's not meant to be opened under a web browser.
- But it does require Internet Explorer 7+, and Windows XP or later.
- Windows already handles HTA files out of the box.
- Simply double-click the file to run it.
- -->
- <style>
- body {margin:0;box-sizing:border-box;padding:.5em;height:100%;font-size:16pt}
- #tts {display:none}
- input {margin:0 2em;width:5em}
- #out {
- position:absolute;left:.5em;top:2.5em;right:.5em;bottom:.5em;
- box-sizing:border-box;border:.1em solid #bbb;padding:.1em .3em;
- overflow:auto;
- }
- </style>
- </head>
- <body>
- <hta:application id=hta></hta:application>
- <object id=tts classid="clsid:96749377-3391-11d2-9ee3-00c04f797396"></object>
- <center>
- <input id=ifile type=file style="display:none" />
- <input id=bload value=Load... type=button />
- <input id=bspeak value=Speak type=button disabled />
- <input id=bpause value=Pause type=button disabled />
- </center>
- <div id=out></div>
- <script language=vbscript>
- sub load(fname)
- on error resume next
- set fs = createobject("scripting.filesystemobject")
- set f = fs.opentextfile(fname)
- if err.number <> 0 then
- msgbox "Error opening file: " & fname & vblf & err.description & ".", _
- 16, document.title
- if withcmdline then close
- end if
- on error goto 0
- lines = f.readall
- if instr(lines, vbcrlf) > 0 then
- lines = split(lines, vbcrlf)
- else
- lines = split(lines, vblf)
- end if
- f.close
- set f = fs.getfile(fname)
- filepath = fname
- document.title = apptitle & " - " & f.name
- bspeak.disabled = false
- end sub
- sub ifile_onchange
- load ifile.value
- end sub
- sub bload_onclick
- ifile.click
- end sub
- sub nextline
- lineindex = lineindex + 1
- if lineindex <= ubound(lines) then
- speakline
- else
- donespeak
- end if
- end sub
- sub donespeak
- speaking = false
- bspeak.value = "Speak"
- bpause.value = "Pause"
- bpause.disabled = true
- end sub
- sub chk
- if speaking then
- if tts.status.runningstate = 1 then
- clearinterval tchk
- nextline
- end if
- end if
- end sub
- sub speakline
- if out.innerhtml <> "" then
- out.innertext = out.innertext & vblf & lines(lineindex)
- else
- out.innertext = lines(lineindex)
- end if
- out.scrolltop = out.scrollheight
- tts.speak lines(lineindex), 1
- end sub
- sub bspeak_onclick
- if speaking then
- clearinterval tchk
- tts.pause
- donespeak
- set a = tts.clonenode(false)
- document.body.removechild document.getelementbyid("tts")
- document.body.appendchild a
- else
- speaking = true
- bspeak.value = "Stop"
- bpause.value = "Pause"
- bpause.disabled = false
- lineindex = 0
- out.innerhtml = ""
- speakline
- tchk = setinterval(getref("chk"), 50)
- end if
- end sub
- sub bpause_onclick
- if paused then
- paused = false
- bpause.value = "Pause"
- tts.resume
- else
- paused = true
- bpause.value = "Resume"
- tts.pause
- end if
- end sub
- sub init
- bload.focus
- if filepath <> "" then load filepath
- end sub
- apptitle = "Speak"
- document.title = apptitle
- filepath = ""
- set x = new regexp
- x.pattern = "(?:""[^""]+""|\S+)\s+(""[^""]+""|\S+)"
- set m = x.execute(hta.commandline)
- if m.count > 0 then filepath = m(0).submatches(0)
- lines = ""
- lineindex = 0
- speaking = false
- paused = false
- tts.alertboundary = 64
- settimeout getref("init"), 0
- </script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment