Tinkering with getting a text-to-speech component worked into my dial plan without having to run the Festival server. Entries in extensions.conf and the tts.agi script are below. I know I must be close as it worked once. Was shocked as it was after about 50 different tries. Tried it again and it didn't work. Been tinkering since so the script is not exactly the same but it's close. Thinking the file may have been deleted before it was played, I've tried clearing the UNLINK option to tempfile() but still no luck. When the file was being created in '/tmp/ but * was lookig in .../sounds, I would get an eror indicating it couldn't find the file so I know the "STREAM FILE" command was being sent. When I fixed the paths, the error went away. Log message from the console were: -- Executing Wait("SIP/106-5a8d", "1") in new stack -- Executing AGI("SIP/106-5a8d", "tts.agi|Shall we play a game?") in new stack -- Launched AGI Script /var/lib/asterisk/agi-bin/tts.agi tts.agi|Shall we play a game?: FORKING text2wave tts.agi|Shall we play a game?: CREATED /var/lib/asterisk/sounds/HykFjnCdwu-tts.wav tts.agi|Shall we play a game?: DONE -- AGI Script tts.agi completed, returning 0 -- Executing Hangup("SIP/106-5a8d", "") in new stack "extensions.conf" entries like so: exten => 7003,1,Wait(1) exten => 7003,2,AGI(tts.agi|Shall we play a game?) exten => 7003,3,Hangup "tts.agi" script like so: #!/usr/bin/perl -w # # tts.agi - AGI script for test-to-speech using Festival's text2wave # # modules use strict; use Asterisk::AGI; use File::Basename; use File::Temp; # defined use constant SOUNDS => '/var/lib/asterisk/sounds'; use constant TEXT2WAVE => '/root/work/festival/bin/text2wave'; use constant TEXT => join( ' ', @ARGV ); # init AGI my $AGI = new Asterisk::AGI; my %input = $AGI->ReadParse(); # temp file my (undef, $tmpfile) = File::Temp::tempfile( DIR => SOUNDS, SUFFIX => '-tts.wav', UNLINK => 1 ); $AGI->verbose( "FORKING text2wave\n", 4 ); # fork my $pid = open my $pipe, "|-"; die "fork() failed: $!" unless defined $pid; if ( !$pid ) { # child open STDOUT, ">$tmpfile" or die "can't redir to $tmpfile: $!"; exec TEXT2WAVE, '-F', '8000', '-'; die "exec() failed: $!"; } else { # parent print $pipe TEXT; close $pipe; waitpid $pid, 0; $AGI->verbose( "CREATED $tmpfile\n", 4 ); $AGI->stream_file( basename( $tmpfile, '.wav' ) ); } # outahere $AGI->verbose( "DONE\n", 4 ); 0; Any suggestions appreciated, Paul -- Paul A. Dugas Dugas Enterprises, LLC email: paul@dugasenterprises.com 1711 Indian Ridge Drive phone: 404.932.1355 fax: 770.516-4841 Woodstock, GA 30189 USA [ onsite at the Georgia DOT's West Annex, 404.463.2860 x158 ]
Could these files be cached as well? Donny -----Original Message----- From: Paul Dugas [mailto:Paul@DugasEnterprises.com] Sent: October 10, 2004 12:56 PM To: Asterisk Mailing List Subject: [Asterisk-Users] TTS via text2wave Tinkering with getting a text-to-speech component worked into my dial plan without having to run the Festival server. Entries in extensions.conf and the tts.agi script are below. I know I must be close as it worked once. Was shocked as it was after about 50 different tries. Tried it again and it didn't work. Been tinkering since so the script is not exactly the same but it's close. Thinking the file may have been deleted before it was played, I've tried clearing the UNLINK option to tempfile() but still no luck. When the file was being created in '/tmp/ but * was lookig in .../sounds, I would get an eror indicating it couldn't find the file so I know the "STREAM FILE" command was being sent. When I fixed the paths, the error went away. Log message from the console were: -- Executing Wait("SIP/106-5a8d", "1") in new stack -- Executing AGI("SIP/106-5a8d", "tts.agi|Shall we play a game?") in new stack -- Launched AGI Script /var/lib/asterisk/agi-bin/tts.agi tts.agi|Shall we play a game?: FORKING text2wave tts.agi|Shall we play a game?: CREATED /var/lib/asterisk/sounds/HykFjnCdwu-tts.wav tts.agi|Shall we play a game?: DONE -- AGI Script tts.agi completed, returning 0 -- Executing Hangup("SIP/106-5a8d", "") in new stack "extensions.conf" entries like so: exten => 7003,1,Wait(1) exten => 7003,2,AGI(tts.agi|Shall we play a game?) exten => 7003,3,Hangup "tts.agi" script like so: #!/usr/bin/perl -w # # tts.agi - AGI script for test-to-speech using Festival's text2wave # # modules use strict; use Asterisk::AGI; use File::Basename; use File::Temp; # defined use constant SOUNDS => '/var/lib/asterisk/sounds'; use constant TEXT2WAVE => '/root/work/festival/bin/text2wave'; use constant TEXT => join( ' ', @ARGV ); # init AGI my $AGI = new Asterisk::AGI; my %input = $AGI->ReadParse(); # temp file my (undef, $tmpfile) = File::Temp::tempfile( DIR => SOUNDS, SUFFIX => '-tts.wav', UNLINK => 1 ); $AGI->verbose( "FORKING text2wave\n", 4 ); # fork my $pid = open my $pipe, "|-"; die "fork() failed: $!" unless defined $pid; if ( !$pid ) { # child open STDOUT, ">$tmpfile" or die "can't redir to $tmpfile: $!"; exec TEXT2WAVE, '-F', '8000', '-'; die "exec() failed: $!"; } else { # parent print $pipe TEXT; close $pipe; waitpid $pid, 0; $AGI->verbose( "CREATED $tmpfile\n", 4 ); $AGI->stream_file( basename( $tmpfile, '.wav' ) ); } # outahere $AGI->verbose( "DONE\n", 4 ); 0; Any suggestions appreciated, Paul -- Paul A. Dugas Dugas Enterprises, LLC email: paul@dugasenterprises.com 1711 Indian Ridge Drive phone: 404.932.1355 fax: 770.516-4841 Woodstock, GA 30189 USA [ onsite at the Georgia DOT's West Annex, 404.463.2860 x158 ] _______________________________________________ Asterisk-Users mailing list Asterisk-Users@lists.digium.com http://lists.digium.com/mailman/listinfo/asterisk-users To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
I was refering to cacheing the generated wave files so they didn't have to be created everytime. It would be ideal if they did, save plenty of cpu time. Is this possible? Donny -----Original Message----- From: Paul Dugas [mailto:Paul@DugasEnterprises.com] Sent: October 11, 2004 10:58 AM To: Asterisk Users Mailing List - Non-Commercial Discussion Subject: RE: [Asterisk-Users] TTS via text2wave Donny Kavanagh said:> Could these files be cached as well?Not sure what files you're refering to but the AGI Perl script isn't being cached as I've been able to change it and call the extension to see the changes without a reload. No res_perl going on here unless it magically part of the stock build now; don't think so. I don't think the sound files are being cached as their names are pretty unique as generated by the Perl File::Temp module. Is there a way to enable additional debugging of the activity in * due to the "STREAM FILE" command from my AGI? Doing a "set verbose" and "set debug" with really big numbers doen's give me anything useful. Thanks again, Paul -- Paul A. Dugas Dugas Enterprises, LLC email: paul@dugasenterprises.com 1711 Indian Ridge Drive phone: 404.932.1355 fax: 770.516-4841 Woodstock, GA 30189 USA [ onsite at the Georgia DOT's West Annex, 404.463.2860 x158 ] _______________________________________________ Asterisk-Users mailing list Asterisk-Users@lists.digium.com http://lists.digium.com/mailman/listinfo/asterisk-users To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users