#!perl # "Poetry Reader" v 1.0 # by David Seay g-s@navix.net # # November 1999 # Type cmd '.' to stop speech # package Main; use Mac::Speech; use Mac::Events; use Mac::Events qw(@Event $CurrentEvent); use Mac::LowMem; $Event[keyDown] = \&key_down; $script = <<"EOF"; From the introduction to Noah's Ark, the mini-musical, words by David Seay, Copyright, 1988 by Greenblatt and Seay. There once was a time in the days of olde Before there were books, when stories were told. Stories that did more than just entertain, Stories that taught and that tried to explain. Stories of histÕry, of mystÕry, and might. Stories to teach the wrong from the right. Children would listen and remember them well So when they became parents they had stories to tell. From one generation to the next they passed Until the printing press was invented at last. Then the stories were published so they could be read, Compiled from old texts, and from what had been said. Translations were made for every tongue So they could be shared by the old and the young. The histÕry of mankind reduced to just pages, Eternally teaching on down thru the ages Of all of those stories we have picked one But weÕve added some details to make it more fun. Tho, actually this story starts off quite sad. It was back in a time when most people were bad. It was a time it is written, when God regretted That mankind had ever even been begetted. So God determined to put an end to all flesh, Except for a few who could start again fresh. Of all on the earth only Noah was blameless. Noah walked with God while all else were shameless. So God told Noah to build an ark out of wood. God gave the dimensions and Noah understood. The ark would hold Noah, his wife, and three sons, Shem, Ham, and Japheth, and their wives, the lucky ones. The ark would be simple, without fancy features And large enough, too, for pairs of all creatures. Noah did all that the Lord had instructed And an ark with three decks was finÕly constructed. ThatÕs where we pick up our story in progress With NoahÕs wifeÕs last minute packing up process. EOF @lines = split(/\n/, $script); print "$lines[0]\n\n"; @approvedVoices = split(/ /,"Ralph Princess Fred Kathy"); $vvv = CountVoices(); $v = 0; for $i (1..$#lines) { $speech = $lines[$i]; if (length($speech) < 1) { print "\n"; next; } $v++; if ($v > $#approvedVoices) { $v = 0 } $~="OUT1"; write; $~="STDOUT"; $voice = $Voice{$approvedVoices[$v]}; $channel = NewSpeechChannel($voice) or die $^E; SpeakText($channel, $speech) || die $^E; while (SpeechBusy()) { WaitNextEvent() } } DisposeSpeechChannel($channel); exit(0); # --------------------- sub key_down { # Enables cmd period to stop speech my($ev) = @_; $k = chr($ev->character); if (($CurrentEvent->modifiers & 256) == 256 && $k eq ".") { StopSpeech $channel or die $^E; DisposeSpeechChannel($channel); exit(0); } } format OUT1 = @>>>>>>>>>>>>>>>: ^* $approvedVoices[$v], $speech .