Guest User

brebs

a guest
Aug 18th, 2010
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.61 KB | None | 0 0
  1. Adds support for flite to speechd 0.56
  2.  
  3. Written by Paul Bredbury <[email protected]>
  4.  
  5.  
  6. --- speechd-orig    2010-08-18 22:44:44.000000000 +0700
  7. +++ speechd 2010-08-19 00:37:48.000000000 +0700
  8. @@ -8,8 +8,9 @@
  9.  #
  10.  # Requirements:
  11.  #  * A speech synthesis package.  Support is currently provided for Festival,
  12. -#    rsynth, and IBM ViaVoice TTS.
  13. +#    flite, rsynth, and IBM ViaVoice TTS.
  14.  #     - Festival:  http://www.cstr.ed.ac.uk/projects/festival/
  15. +#     - flite:  http://cmuflite.org/
  16.  #     - rsynth:  ftp://ftp.cdrom.com/pub/linux/sunsite/apps/sound/speech/
  17.  #     - ViaVoice: http://www-3.ibm.com/software/speech/dev/ttssdk_linux.html
  18.  #  * Perl (duh)
  19. @@ -64,7 +65,7 @@
  20.  #CMDLINE HELP BEGIN
  21.  
  22.  sub cmdlinehelp {
  23. -  print "Usage: speechd [-qQf] [-H <host>] [-P <port>] [-s <festival|rsynth|viavoice>] [-V <ViaVoice voice>]\n";
  24. +  print "Usage: speechd [-qQf] [-H <host>] [-P <port>] [-s <festival|flite|rsynth|viavoice>] [-V <ViaVoice voice>]\n";
  25.    print "    or speechd [-h]\n";
  26.    print "       -q  Quiet mode (Supresses STDOUT)\n";
  27.    print "       -Q  Very quiet mode (Supresses STDOUT and STDERR)\n";
  28. @@ -190,7 +191,11 @@
  29.  
  30.  print 'Speech synthesis system = "',$synth,'"',"\n";
  31.  
  32. -if ($synth eq 'rsynth') {
  33. +if ($synth eq 'flite') {
  34. +    @cmd = qw(flite -t);
  35. +    print "cmd = @cmd\n";
  36. +    &use_flite;
  37. +} elsif ($synth eq 'rsynth') {
  38.    if ($use_esd) {
  39.      print "rsynth does not seem to work with esd.\n";
  40.      @cmd = qw(esddsp say);
  41. @@ -208,7 +213,7 @@
  42.    }
  43.    &use_rsynth;
  44.  } elsif ($synth eq 'festival') {
  45. -  # speical cases here... need to fork and exec...bummer
  46. +  # special cases here... need to fork and exec...bummer
  47.    if ($use_esd)
  48.    {
  49.      @cmd = qw(esddsp festival --server);
  50. @@ -244,7 +249,7 @@
  51.  ############################
  52.  
  53.  ##############################
  54. -#DEFINITINO OF FUNCTIONS BEGIN
  55. +#DEFINITION OF FUNCTIONS BEGIN
  56.  
  57.  sub use_festival_SayText {
  58.    my $info;
  59. @@ -303,6 +308,31 @@
  60.    }
  61.  }
  62.  
  63. +sub use_flite {
  64. +  open( FIFO, "<$fifo" ) || die "can't read from $fifo $!\n";
  65. +  while(1) {
  66. +    # reads will block till someone writes something
  67. +    my $text = <FIFO>;
  68. +
  69. +    if (defined $text) {
  70. +      # Strip single quotes so contractions are treated as single words by string conversion
  71. +      # & convert "_" characters to " ".
  72. +      $text =~ tr/([_'])/ /d;
  73. +      # convert to lowercase so string substitution isn't case sensitive
  74. +      $text = lc ($text);
  75. +      # This does the string conversion.
  76. +      $text =~ s/(\w+)/$wordsub{$1} || $1/eg;
  77. +
  78. +      print "Output: $text";
  79. +      system(@cmd,$text);
  80. +      print "loop\n";
  81. +      #close FIFO;
  82. +    }
  83. +    sleep 2;  # this is recommended by the perlipc
  84. +              # manpage to avoid dup signals
  85. +  }
  86. +}
  87. +
  88.  sub use_rsynth {
  89.    open( FIFO, "<$fifo" ) || die "can't read from $fifo $!\n";
  90.    while(1) {
  91. @@ -314,7 +344,7 @@
  92.        #close FIFO;
  93.      }
  94.      sleep 2;  # this is recommended by the perlipc
  95. -            # manpage to avoid dup signals
  96. +              # manpage to avoid dup signals
  97.    }
  98.  }
  99.  
  100. @@ -472,8 +502,8 @@
  101.  =item
  102.  C<-s pkg>  
  103.  
  104. -Sets the speech synthesis package to use.  pkg can be either
  105. -'festival' or 'rsynth'.
  106. +Sets the speech synthesis package to use.  pkg can be
  107. +'festival', 'flite' or 'rsynth'.
  108.  
  109.  =item
  110.  C<-e>  
  111. @@ -563,7 +593,9 @@
  112.  
  113.  The Festival voice synthesis package:  I<http://www.cstr.ed.ac.uk/projects/festival/>
  114.  
  115. -The rsynth voice sysnthesis package:  I<ftp://ftp.cdrom.com/pub/linux/sunsite/apps/sound/speech/>
  116. +The flite voice synthesis package:  I<http://cmuflite.org/>
  117. +
  118. +The rsynth voice synthesis package:  I<ftp://ftp.cdrom.com/pub/linux/sunsite/apps/sound/speech/>
  119.  
  120.  The IBM ViaVoice TTS SDK package: I<http://www-3.ibm.com/software/speech/dev/ttssdk_linux.html>
Advertisement
Add Comment
Please, Sign In to add comment