Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2015
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.56 KB | None | 0 0
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use POSIX;
  5.  
  6. $|++;
  7.  
  8. my $pipe = '/tmp/speak.pipe';
  9. unlink $pipe;
  10. `mkfifo $pipe`;
  11. die unless( -p( $pipe ) );
  12.  
  13. open( IN, $pipe ) || die "Could not read pipe: $pipe - $@";
  14. while( 1 ) {
  15.   my @lines = <IN>;
  16.   unless( scalar @lines > 0 ) {
  17.     sleep 1;
  18.     next;  
  19.   }
  20.   speak( @lines );
  21. }
  22.  
  23. sub speak {
  24.   my @phrases = @_;
  25.  
  26.   open( TOUCH, '>/tmp/talking' ); close(TOUCH);
  27.  
  28.   my $say = join( '. ', @phrases );
  29.   system( '/usr/bin/flite', '-t', $say );
  30.  
  31.   unlink( '/tmp/talking' );
  32. }
  33.  
  34. unlink $pipe;
  35.  
  36. 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement