SHARE
TWEET

Random speech

a guest Jul 5th, 2014 233 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/perl
  2. use Switch;
  3.  
  4. # Generates word samples with random voices and intonation, and
  5. # saves the output as 16-bit 8 kHz WAV files
  6.  
  7. # Put the words you want to generate in this list:
  8. my @words = qw/yes no/;
  9.  
  10. # Generate this many instances of each word:
  11. my $loopcount = 100;
  12.  
  13. # These are the "non-novelty" voices available on my system; you
  14. # may have to edit the list depending on what is available to you:
  15. my @voices = qw/Alex Bruce Fred Junior Ralph Agnes Kathy Princess Vicki Victoria/;
  16.  
  17. # ================ STOP EDITING HERE ================
  18.  
  19. my @emph = ("[[emph +]]","[[emph -]]","");
  20. my @punc = (".","!","?");
  21. foreach (@words) {
  22.   for (my $i=0; $i<$loopcount; $i++) {
  23.     my $s = sprintf("say -v %s '[[rate %+d]][[pbas %+d]]%s %s%s' -o %s_%04d.wav --data-format=I16\@8000",
  24.                        $voices[rand @voices],
  25.                        int(rand(150))+1,
  26.                        int(rand(20)-10),
  27.                        $emph[rand @emph],
  28.                        $_,
  29.                        $punc[rand @punc],
  30.                        $_,
  31.                        $i
  32.                    );
  33.     printf("\rGenerating files... '%s' (%d/%d)",$_,$i+1,$loopcount);
  34.     `$s`;
  35.   }
  36.   print(" Finished\n");
  37. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top