#!perl -w # Chorus v1.0 # # Yet another peculiar use of text-to-speech. # # Run this multiple times for different voices. use Mac::Speech; use Mac::Events; use constant CHANNELS => 2; # number of voices to use use constant EXCLUDE => qw(aa av cu ei eo eu ia ii io iu iv ix ok ox oz uk vi); # pairs to exclude undef $/; { my @v = ( 'Cellos', 'Fred', # bad PA system 'Good News', 'Boing', 'Bad News', 'Pipe Organ', 'Ralph', ); #$voice = $Voice{$v[rand @v]}; $voice = $Voice{MacPerl::Pick("Choose a voice: ", @v) or exit}; } for (1..CHANNELS) { push @Channels, NewSpeechChannel($voice) or die $^E; } %exclude = map {($_, 1)} EXCLUDE; # make pairs for ('aa'..'zz') { push @Syllables, $_ unless !/[aeiouy]/ or $exclude{$_}; } # shuffle pairs @shuffled = (); for (1..10) { foreach (@Syllables) { my $r = rand @shuffled+1; push(@shuffled,$shuffled[$r]); $shuffled[$r] = $_; }} $text = @ARGV ? <> : "@shuffled"; # start speech foreach (@Channels) { SpeakText $_, $text or die $^E; } WaitNextEvent while SpeechBusy; END { foreach (@Channels) { DisposeSpeechChannel $_; } }