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

Replies are listed 'Best First'.
Re: Magic Perl 8 Ball
by zentara (Cardinal) on Feb 04, 2003 at 15:35 UTC
    This is just a general comment on voice synthesis. It seems that most of the examples here on perlmonks are for win32 and it's voice synthesizer. Linux users can have their own excellent voice synthesizer too, it's called Festival. It dosn't have much of a perl interface right now, but it "talks good". It helps to type your text "phonetically" to get really life like output. For example: to get a realistic "suffering succotash" you might have to enter "suhf ring suh ka tash". But anyways, Linux users don't feel left out of this cool use of computers. Festival