Most likely, it's a quoting problem that's behind your issue. Try replacing your call to system with print to see what exactly you're passing.
If you want to see how to do it the other way, here's some code (taken from my talk Fun with Asterisk and Perl) that shows how to use the list form of exec to invoke Festival and stream the result back to Asterisk:
#!/usr/bin/perl -w # # Speaks the text in $ARGV[0]. # Caches text-to-speech conversions as 8-kHz .WAV files. use Asterisk::AGI; use File::Basename; use Digest::MD5 qw(md5_hex); use strict; # set up communications w/ Asterisk my $agi = new Asterisk::AGI; $agi->ReadParse(); # figure out the WAV file to use based on a hash of the text to say my ($text_to_say) = @ARGV; my $hash = md5_hex($text_to_say); my $sounddir = "/var/lib/asterisk/sounds"; my $wavefile = "$sounddir/say-text-$hash.wav"; # unless we have already cached this text-to-speed conversion, # create the WAV file using Festival's text2wav (expensive) unless (-f $wavefile) { require File::Temp; my (undef, $tmpfile) = File::Temp::tempfile(DIR => $sounddir); my $pid = open my $pipe, "|-"; die "can't fork: $!" unless (defined $pid); if (!$pid) { # child open STDOUT, ">$tmpfile" or die "can't redir to $tmpfile: $!"; exec qw( text2wave -F 8000 - ); # text->speech conv; 8-kHz WAV + output die "exec in child failed: $!"; } else { # parent print $pipe $text_to_say; close $pipe; waitpid $pid, 0; # wait until text->speech conv. is done rename $tmpfile, $wavefile or die "can't rename $tmpfile to $wavefile: $!"; } } # stream the WAV file down the phone line $agi->stream_file(basename($wavefile, ".wav"));
Cheers,
Tom
Tom Moertel : Blog / Talks / CPAN / LectroTest / PXSL / Coffee / Movie Rating Decoder
In reply to Re: I'm banging my head with simple trick
by tmoertel
in thread I'm banging my head with simple trick
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |