A simple script which speaks the selected text with artificial voice. The script creates temporary VBScript and hidden IE window. Uses Microsoft Speech API and any Speech Engine registered in the Windows Registry. If you use Windows 2000/XP, most likely, your system already has the necessary components.
Code:
#F12::
SpeakingSelected:
FileDelete, %A_ScriptDir%\SpeechMe.vbs
FileAppend, Set ISpeechVoice `= CreateObject`(`"SAPI.SpVoice`"`)`n, %A_ScriptDir%\SpeechMe.vbs
FileAppend, Set oIE `= WScript.CreateObject`(`"InternetExplorer.Application`"`)`n, %A_ScriptDir%\SpeechMe.vbs
FileAppend, oIE.navigate `"about`:blank`"`n, %A_ScriptDir%\SpeechMe.vbs
FileAppend, ISpeechVoice.Speak oIE.document.parentWindow.clipboarddata.getData`(`"text`"`)`, SPF_DEFAULT`n, %A_ScriptDir%\SpeechMe.vbs
FileAppend, Set oIE = Nothing, %A_ScriptDir%\SpeechMe.vbs
ClipSaved =
ClipSaved := ClipboardAll
Clipboard =
Send, ^c
ClipWait, 1
Clipboard = %Clipboard%
If Clipboard =
{
Clipboard = The text to speech not found! Please select some text and retry.
}
Run, WSCRIPT.EXE "%A_ScriptDir%\SpeechMe.vbs",,, WSCRIPT_PID
SetTimer, Wait5sec, 5000
Return
Wait5sec:
FileDelete, %A_ScriptDir%\SpeechMe.vbs
Clipboard := ClipSaved
SetTimer, Wait5sec, Off
Return
#F11::
StopSpeaking:
Process, Close, %WSCRIPT_PID%
DetectHiddenWindows, On
SetTitleMatchMode, 2
WinClose, about`:blank
SetTitleMatchMode, 3
DetectHiddenWindows, Off
Return
For info only: the file "SpeechMe.vbs"
Code:
Set ISpeechVoice = CreateObject("SAPI.SpVoice")
Set oIE = WScript.CreateObject("InternetExplorer.Application")
oIE.navigate "about:blank"
ISpeechVoice.Speak oIE.document.parentWindow.clipboarddata.getData("text"), SPF_DEFAULT
Set oIE = Nothing