On Windows, text-to-speech is easy. Windows has a builtin text-to-speech service. Even Windows XP has it.
If you save the following code as a text file and rename it to SPEAK.VBS and then call it from Perl...your Windows PC will speak! The first argument should be a number between 1 and 100. The second argument should be some English words enclosed with double quotes. (If you omit the double quotes, then it will only read the first word.)
IF Wscript.Arguments.length > 1 THEN
SET VOICE = CreateObject("SAPI.SpVoice")
VOICE.Volume = Wscript.Arguments(0)
VOICE.Speak Wscript.Arguments(1)
WScript.Quit 1
ELSE
WScript.Echo "Usage: speak.vbs <VOLUME> <TEXT>"
END IF
WScript.Quit 0
(Note: Don't send too much text all at one time, because the computer will freeze up while it speaks. At least, that's what happens in Windows XP. So, if you have a bunch of things you want the computer to read, then call SPEAK.VBS with just a few words at a time. That way if you want to press CTRL+BREAK, you can interrupt your program, and it will stop speaking. But if you call SPEAK.VBS with a whole paragraph, it will not stop until it has finished reading the entire paragraph.)
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|