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