Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 125365
Collapse All | Expand All

(-)speechd.orig (-13 / +22 lines)
Lines 255-280 Link Here
255
  while(1) {
255
  while(1) {
256
    #open( FIFO, "<$fifo" ) || die "can't read from $fifo $!\n";
256
    #open( FIFO, "<$fifo" ) || die "can't read from $fifo $!\n";
257
    my $line = 0;
257
    my $line = 0;
258
		my $text;
258
    my $text;
259
    while ($text = <FIFO>)
259
    while ($text = <FIFO>)
260
    {
260
    {
261
			next if $text eq "\n";
261
      next if $text eq "\n";
262
262
      $line++;
263
      $line++;
263
      print "Line: $line\n";
264
      print "Line: $line\n";
264
      print "Input:  $text";
265
      print "Input:  $text";
265
      # escape backslashes and quotes
266
266
      $text =~ s/(["\\])/\\$1/g;
267
      if ( $text !~ m/^ *\(.+\)/ ) { # a string delimited by parenthesis is treated as a command (as is)
267
      # Strip single quotes so contractions are treated as single words by string conversion 
268
        # escape backslashes and quotes
268
      # & convert "_" characters to " ".
269
        $text =~ s/(["\\])/\\$1/g;
269
      $text =~ tr/([_'])/ /d;
270
        # Strip single quotes so contractions are treated as single words by string conversion 
270
      # convert to lowercase so string substitution isn't case sensitive
271
        # & convert "_" characters to " ".
271
      $text = lc ($text);
272
        $text =~ tr/([_'])/ /d;
272
      #Thanks to Abigail in #Perl on EFNet for assistance w/ the followoing line.
273
        # convert to lowercase so string substitution isn't case sensitive
273
      #This does the string conversion.
274
        $text = lc ($text);
274
      $text =~ s/(\w+)/$wordsub{$1} || $1/eg;
275
        #Thanks to Abigail in #Perl on EFNet for assistance w/ the following line.
276
        #This does the string conversion.
277
        $text =~ s/(\w+)/$wordsub{$1} || $1/eg;
278
        # remove trailing newline
279
        $text =~ s/\n$//;
280
        # insert the string in a festival "SayText" command
281
        $text = '(SayText "'.$text.'")'."\n";
282
      }
283
275
      if ($handle) {   # Sanity checks are always nice...
284
      if ($handle) {   # Sanity checks are always nice...
276
        print "Output: $text";
285
        print "Output: $text";
277
        print($handle '(SayText "',$text,'")') or die "Could not write to Festival ($!)\n";
286
        print($handle $text) or die "Could not write to Festival ($!)\n"; 
278
        recv($handle, $info, 200, 0);
287
        recv($handle, $info, 200, 0);
279
        print "Festival: $info\n";
288
        print "Festival: $info\n";
280
      } else {
289
      } else {

Return to bug 125365