The following was heavily inspired by a recent post by
Mr. Muskrat titled
We're Going on a Bear Hunt. Just pass the 8 Ball a question and sit back in amazement as all is revealed. Guaranteed to provide nanoseconds of entertainment. :)
#!perlenv -w
use strict;
use Win32::OLE;
my $line = shift;
my $voice;
$voice = Win32::OLE->new("Speech.VoiceText") or die ("TTS failed");
$voice->Register( "", "$0" );
$voice->{Enabled} = 30;
$voice->{Speed} = 140;
&talk;
sub talk {
$voice->Speak( "you want to know,", 1 );
$voice->Speak( $line, 1 );
sleep 1;
print $line, $/;
while ( $voice->IsSpeaking() ) {
sleep 1;
&answer;
}
}
sub answer {
srand;
my @answer = (
"outlook good",
"outlook not so good",
"my reply is no",
"don't count on it",
"you may rely on it",
"ask again later",
"most likely",
"cannot predict now",
"yes, definitely",
"better not tell you now",
"it is certain",
"very doubtful",
"it is decidedly so",
"concentrate and ask again",
"signs point to yes",
"my sources say no",
"without a doubt",
"reply hazy, try again",
"as i see it, yes"
);
my $response = $answer[ rand(@answer) ];
$voice->Speak( $response, 1 );
sleep 2;
print $response, $/;
while ( $voice->IsSpeaking() ) {
sleep 1;
}
}
cheers, semio
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.