#!perl # "Laugh Track" v1.0 # by David Seay <g-s@navix.net> # use Mac::Speech; $script = " Ethyl: Hey MacPerlers, how many programmers does it take to change a light bulb? Fred: I don't know. How many programmers does It take to change a light bulb? Ethyl: 5! 1 to change the light bulb and 4 to sit back and say, He ain't so Hot! "; &joke; &laugh; sub joke { $cast{"Ethyl"} = Kathy; $cast{"Fred"} = Fred; @lines = split(/\n/, $script); for $i (1..$#lines) { ($character,$speech) = split(/:/, $lines[$i]); $voice = $Voice{$cast{$character}}; $channel = NewSpeechChannel($voice) or die $^E; SpeakText($channel, $speech) || die $^E; while (SpeechBusy()) {} DisposeSpeechChannel($channel); } } sub laugh { @words = split(",","ha ha ,hey hey ,ho ho ,ha ha ,he he "); @speakers = split(",","Fred,Kathy,Princess"); $voices = 6; for $v (0..$voices) { $phrase = "ha ha "; for $w (0..6) { $phrase .= $words[int(rand ($#words + 1))] } $channel[$v] = NewSpeechChannel ($Voice{$speakers[int(rand ($#speakers + 1))]}) or die $^E; SpeakText $channel[$v], $phrase; } while (SpeechBusy()) { $v = int(rand ($voices)); $pitch = int(rand (20)) + 48; SetSpeechPitch $channel[$v], $pitch; select(undef, undef, undef, .1); } for $v (0..$voices) { DisposeSpeechChannel $channel[$v] } } ===== Want to unsubscribe from this list? ===== Send mail with body "unsubscribe" to macperl-request@macperl.org