Hello Everyone, Why EAGI is made so complex? The audio captured with the EAGI-perl script on voip-info.org is almost not useful. The clarity of the audio is pathetic. Am i missing something??? I have Digium TDM 12B. I can get calls to my VoIP phone ok thru TDM and asterisk. But when i use EAGI-perl script, neither GSM nor RAW audio file created after capture sounds clear. Lot of noise and voice can not even be heard. Please Help!!! Thanks Frank EAGI-perl script: =========== #!/usr/bin/perl # # Note that this example doesn't check the results of AGI calls, and doesn't use # Asterisk::AGI in an attempt to keep it simple and dependency free. # # This program is free software; you can redistribute it and/or modify # it under the same terms as Perl itself. # # Author: Simon P. Ditner / http://uc.org/simon # # Usage: # - Create an AGI in /var/lib/asterisk/agi-bin, i.e.: perl.eagi # - Call using EAGI from your dialplan: exten => 100,1,EAGI(perl.eagi) # use warnings; use strict; use IO::Handle; $| = 1; # Turn of I/O Buffering my $buffer = undef; my $result = undef; my $AUDIO_FD = 3; # Audio is delivered on file descriptor 3 my $audio_fh = new IO::Handle; $audio_fh->fdopen( $AUDIO_FD, "r" ); # Open the audio file descriptor for reading # Skip over the preamble that Asterisk sends this AGI while( <STDIN> ) { chomp($_); last if length($_) == 0; } # Playback beep print "STREAM FILE beep \"#\"\n"; $result = <STDIN>; # Record 5 seconds of audio at 8,000 samples/second (uses 16 bit integers) # 5 seconds x 8000 samples/second x ( 16 bits / 8bits/byte ) = 80000 bytes my $bytes_read = $audio_fh->read( $buffer, 80000 ); $audio_fh->close(); # Playback beep print "STREAM FILE beep \"#\"\n"; $result = <STDIN>; # Write the raw audio to a file for later analysis my $fh; open( $fh, ">/tmp/recording.raw" ); print $fh $buffer; close( $fh ); # Also convert the raw audio on-the-fly to the GSM format using 'sox', so that # we can play it back to the user right now. open( $fh, "|/usr/bin/sox -t raw -r 8000 -s -w -c 1 - /tmp/recording.gsm" ); # | | | | | | | # | | | | | | '-- Write to this file # | | | | | '-- Read from STDIN # | | | | '-- Mono Audio # | | | '-- Samples are words (a word is 2 bytes = 16 bit audio) # | | '-- The audio is signed (32766..-32766) # | '-- The sample rate is 8,000 samples/second # '-- The input format is SLIN, which is 'raw' audio print $fh $buffer; close( $fh ); # Playback /tmp/recording.gsm print "STREAM FILE /tmp/recording \"#\"\n"; $result <STDIN>; exit; __________________________________________ Yahoo! DSL ? Something to write home about. Just $16.99/mo. or less. dsl.yahoo.com
Date: Mon, 5 Dec 2005 21:48:56 -0800 (PST) From: ha i <hai_2k@yahoo.com> Subject: [Asterisk-Users] EAGI Audio Capture To: asterisk-users@lists.digium.com Message-ID: <20051206054856.34294.qmail@web35613.mail.mud.yahoo.com> Content-Type: text/plain; charset=iso-8859-1 Hello Everyone, Why EAGI is made so complex? The audio captured with the EAGI-perl script on voip-info.org is almost not useful. The clarity of the audio is pathetic. Am i missing something??? I have Digium TDM 12B. I can get calls to my VoIP phone ok thru TDM and asterisk. But when i use EAGI-perl script, neither GSM nor RAW audio file created after capture sounds clear. Lot of noise and voice can not even be heard. Please Help!!! Thanks Frank EAGI-perl script: =========== #!/usr/bin/perl # # Note that this example doesn't check the results of AGI calls, and doesn't use # Asterisk::AGI in an attempt to keep it simple and dependency free. # # This program is free software; you can redistribute it and/or modify # it under the same terms as Perl itself. # # Author: Simon P. Ditner / http://uc.org/simon # # Usage: # - Create an AGI in /var/lib/asterisk/agi-bin, i.e.: perl.eagi # - Call using EAGI from your dialplan: exten => 100,1,EAGI(perl.eagi) # use warnings; use strict; use IO::Handle; $| = 1; # Turn of I/O Buffering my $buffer = undef; my $result = undef; my $AUDIO_FD = 3; # Audio is delivered on file descriptor 3 my $audio_fh = new IO::Handle; $audio_fh->fdopen( $AUDIO_FD, "r" ); # Open the audio file descriptor for reading # Skip over the preamble that Asterisk sends this AGI while( <STDIN> ) { chomp($_); last if length($_) == 0; } # Playback beep print "STREAM FILE beep \"#\"\n"; $result = <STDIN>; # Record 5 seconds of audio at 8,000 samples/second (uses 16 bit integers) # 5 seconds x 8000 samples/second x ( 16 bits / 8bits/byte ) = 80000 bytes my $bytes_read = $audio_fh->read( $buffer, 80000 ); $audio_fh->close(); # Playback beep print "STREAM FILE beep \"#\"\n"; $result = <STDIN>; # Write the raw audio to a file for later analysis my $fh; open( $fh, ">/tmp/recording.raw" ); print $fh $buffer; close( $fh ); # Also convert the raw audio on-the-fly to the GSM format using 'sox', so that # we can play it back to the user right now. open( $fh, "|/usr/bin/sox -t raw -r 8000 -s -w -c 1 - /tmp/recording.gsm" ); # | | | | | | | # | | | | | | '-- Write to this file # | | | | | '-- Read from STDIN # | | | | '-- Mono Audio # | | | '-- Samples are words (a word is 2 bytes = 16 bit audio) # | | '-- The audio is signed (32766..-32766) # | '-- The sample rate is 8,000 samples/second # '-- The input format is SLIN, which is 'raw' audio print $fh $buffer; close( $fh ); # Playback /tmp/recording.gsm print "STREAM FILE /tmp/recording \"#\"\n"; $result <STDIN>; exit; __________________________________________ Yahoo! DSL ? Something to write home about. Just $16.99/mo. or less. dsl.yahoo.com
Hi Guys, Can you guys please provide me with some example code for EAGI to give out GOOD audio data? The audio returned by perl-script (RAW, gsm and wav) is really bad and is not clear at all. Looks like the data returned is signed SLINEAR 16-bit data. How can i get the clear noise free audio from it? Can i apply some DSP filters on it? please help. I want to get the audio clarity as if someone is leaving a voicemail. When voicemail messages sound so clean, how come audio on EAGI (FD:3) sounds so bad??? I want this for Live audio streaming. So record/monitor may not be helpful. Your help is appreciated. Thanks, Frank __________________________________________ Yahoo! DSL ? Something to write home about. Just $16.99/mo. or less. dsl.yahoo.com