[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Chorus



#!perl -w

# 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

SETUP:

{
  my @v = (
    'Cellos',
    'Fred', # bad PA system
    'Good News',
  );
  $voice = $Voice{$v[rand @v]};
}

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 = (); 
foreach (@Syllables) {
  my $r = rand @shuffled+1;
  push(@shuffled,$shuffled[$r]);
  $shuffled[$r] = $_;
}
$text = "@shuffled";

# start speech
foreach (@Channels) {
                SpeakText $_, $text or die $^E;
}
WaitNextEvent while SpeechBusy;

END {
  foreach (@Channels) {
    DisposeSpeechChannel $_;
  }
}

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org