[asterisk-users] Asterisk cant play sounds from AGI

Edwin Quijada listas_quijada at hotmail.com
Fri Jul 11 15:31:15 CDT 2008



----------------------------------------
> Date: Fri, 11 Jul 2008 11:29:58 -0700
> From: asterisk.org at sedwards.com
> To: asterisk-users at lists.digium.com
> Subject: Re: [asterisk-users] Asterisk cant play sounds from AGI
> 
> On Fri, 11 Jul 2008, Tilghman Lesher wrote:
> 
>>>> On Jul 10, 2008, at 7:54 PM, Edwin Quijada wrote:
>>>>
>>>>> My problem is that i cant hear anything when play the file sound 
>>>>> using $AGI->stream_file($filename); I put asterisk in verbose mode 
>>>>> but just see that it plays the sound but I cant hear anything.
> 
>> Check the format of the file.  In most cases, the file should be 8000Hz, 
>> single channel, uncompressed, signed linear, 16-bit samples format. 
>> Winamp can play a great many different formats, but Asterisk is limited 
>> to the formats for which it has a translator.
> 
> If the file is a "wav," it should look something like this:
> 
>  	-t2::sedwards:~$ file example.wav
>  	example.wav: RIFF (little-endian) data, WAVE audio, Microsoft\
>  		PCM, 16 bit, mono 8000 Hz
> 
> Also, just in case you trip over this, you pass a file name to Asterisk, 
> not a file type -- the bit after the period. Asterisk chooses the "best" 
> type from files of the same name based on the codecs available to the 
> channel.
> 

vm-debian#file tts-hello
example.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, mono 8000 Hz

I recorded the sound using Cepstral. This is my AGI 
I thought maybe was my sound card but this works fine
$AGI->say_number('9865');
$AGI->say_digits('873746');
and I can hear it in my SIP phone

use Asterisk::AGI;
use File::Basename;
use Digest::MD5 qw(md5_hex);
 
 
 $AGI = new Asterisk::AGI;
 %input = $AGI->ReadParse();
 #
$AGI->say_number('9865');
$AGI->say_digits('873746');
 
speak("Hello World....");
 
 
 
sub speak
  {
    $text = $_[0];
 
    my $hash = md5_hex($text);
 
    my $ttsdir = "/var/lib/asterisk/sounds/tts";
    my $cepoptions = "-p audio/sampling-rate=8000,audio/channels=1";
 
    my $wavefile = "$ttsdir/tts-$hash.wav";
 
    unless (-f $wavefile)
      {
        open(fileOUT, ">/var/lib/asterisk/sounds/tts/say-text-$hash.txt");
        print fileOUT "$text";
        close(fileOUT);
 
        my $execf="/opt/swift/bin/swift -f $ttsdir/say-text-$hash.txt -o $wavefile $cepoptions";
        system($execf);
 
        unlink("$ttsdir/say-text-$hash.txt");
      }
    $filename = 'tts/'.basename('tts/'.basename($wavefile,".wav"));
    $AGI->stream_file($filename);
#  unlink("$wavefile");


> Thanks in advance,
> ------------------------------------------------------------------------
> Steve Edwards      sedwards at sedwards.com      Voice: +1-760-468-3867 PST
> Newline                                             Fax: +1-760-731-3000
> 
> _______________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
> 
> AstriCon 2008 - September 22 - 25 Phoenix, Arizona
> Register Now: http://www.astricon.net
> 
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-users

_________________________________________________________________
Stop squinting -- view your photos on your TV.  Learn more.
http://www.microsoft.com/windows/digitallife/default.mspx?deepLink=photos


More information about the asterisk-users mailing list