Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- use warnings;
- use POSIX;
- $|++;
- my $pipe = '/tmp/speak.pipe';
- unlink $pipe;
- `mkfifo $pipe`;
- die unless( -p( $pipe ) );
- open( IN, $pipe ) || die "Could not read pipe: $pipe - $@";
- while( 1 ) {
- my @lines = <IN>;
- unless( scalar @lines > 0 ) {
- sleep 1;
- next;
- }
- speak( @lines );
- }
- sub speak {
- my @phrases = @_;
- open( TOUCH, '>/tmp/talking' ); close(TOUCH);
- my $say = join( '. ', @phrases );
- system( '/usr/bin/flite', '-t', $say );
- unlink( '/tmp/talking' );
- }
- unlink $pipe;
- 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement