login | register
Wed 01 of Aug, 2007 [09:24 UTC]

voip-info.org

Search with Google
Search this site with Google. Results may not include recent changes.

Web www.voip-info.org
Shoutbox
  • Aykut, Wed 01 of Aug, 2007 [07:53 UTC]: Hi all, does anybody know about Thomson ST2030 SIP phone. I have upgraded it to latest version (1.56) but "Hold" and "Conf" features are not working after the upgrade ?? Do you know any solution or do you have Ver. 1.52 ?? Where can I find it?
  • Edward J Brown, Tue 31 of Jul, 2007 [23:33 UTC]: Has anybody experienced Choppy voice quality when using a Linksys SPA942 in an Asterisk Conference bridge? It works fine with my polycom and Cisco, but sucks with my Linksys.
  • www.astawerks.com, Fri 27 of Jul, 2007 [18:00 UTC]: does anyone use asterisk on top of clark connect? does it work good?
  • simon, Fri 27 of Jul, 2007 [14:16 UTC]: Hi All, Has anyone here managed to get the Cisco79x1 to successfully fail over to the backup proxy. I have 2 asterisk servers , handsets all register and function, except that backup proxy function doesn't work. Any working example would be very apprecia
  • Matthew Richmond, Thu 26 of Jul, 2007 [03:40 UTC]: using the page() application to page across our building...often the meetme conferences don't disconnect after the caller hangs up. Anyone else having this problem. (using Polycom phones)
  • Matthew Richmond, Wed 25 of Jul, 2007 [02:58 UTC]: thanks Nicholas Blasgen! I haven't worked with AGI before, but there's always a first! Thanks again!
  • Nicholas Blasgen, Tue 24 of Jul, 2007 [19:18 UTC]: Matthew Richmond, AGI will handle all that for you.
  • sam, Mon 23 of Jul, 2007 [16:39 UTC]: need help - certain voicemail extension will stop working and recording voicemail on asterisk - anyone know why and how to fix it? Thanks
  • john haji, Mon 23 of Jul, 2007 [14:55 UTC]: free calls to pakistan
  • bong, Sat 21 of Jul, 2007 [19:09 UTC]: hi good day to all can anyone help me how to configured the nortel sip to the signaling server and how to activate in mobile w/ sip compatible without mcs
Server Stats
  • Execution time: 0.38s
  • Memory usage: 2.19MB
  • Database queries: 31
  • GZIP: Disabled
  • Server load: 3.09

Asterisk text2cepstral www demo

Image
Image


Using cepstral webbased voice synthesized demo to generate voice prompts for asterisk on the fly


Prerequisites

  • Time
  • Asterisk
  • Internet Connectivity
  • PHP (in this example we use version 5.0.4)

Introduction

Why?

I personaly wanted to be able to generate occasional voice prompts dynamicaly without the need for recording on my home PC and uploading via FTP and then moving to the correct directory on my dedicated server.

Getting Started


# mkdir /etc/asterisk/php/
# cd /etc/asterisk/php/
# nano speech.php

Paste into nano


<?php
$args = $_SERVER["argv"];
$i = 0;
while ($i<sizeof($args))
{
       if ($i>0)
       {
               $arg[$i-2] = $args[$i];
       }
       $i++;
}
$text=urlencode(implode(" ",$arg));

system('rm /var/lib/asterisk/sounds/tikka.gsm');
system('/usr/bin/wget -O /tmp/tikka.wav "http://qs913.pair.com/cepstral/demos/demo.cgi/cepstral.wav?content='.$text.'&voice=Lawrence&rate=160&pitch=1&effect=none&submit=Synthesize+the+Text"');
?>


The above code will take commandline parameters passed to it from asterisk when we call it from extentions.conf.

Press CTRL + X to close nano, it will ask if you wish to save press y for yes and then press enter to save our file with the name speech.php.

Another file that we will be creating is time.php, this is based on the same file above but generates a fun time announcement. (UK Residents will recognise this hopefuly ;))

# nano time.php

Paste into nano


<?php
$today = date("h:i:s");
$text = "At the third stroke, the time sponsored by accurist will be, ";
$text .= date("'h'") . "" . date("'i'") . " and " . date("'s'") . " seconds BEEP BEEP BEEP";
system('rm /var/lib/asterisk/sounds/time.gsm');
system('/usr/bin/wget -O /tmp/time.wav "http://qs913.pair.com/cepstral/demos/demo.cgi/cepstral.wav?content='.$text.'&voice=Lawrence&rate=160&pitch=1&effect=none&submit=Synthesize+the+Text"');
?>


# cd ..
# nano extentions.conf

Paste into extentions.conf


[inbound]
exten => _X.,1,Answer
exten => _X.,2,System(php -q /etc/asterisk/php/speech.php Please Wait.) ; tells caller to "please wait"
exten => _X.,3,System(sox /tmp/tikka.wav -r 8000 -c 1 -s -w /var/lib/asterisk/sounds/tikka.gsm resample -ql) ; using sox (sox.sourceforge.net) encode our new wave file downloaded from cepstral website to a format more comfortable to asterisk for sending to our caller.
exten => _X.,4,Playback(tikka) ; playback the file tikka(.gsm) contained in /var/lib/asterisk/sounds/
exten => _X.,5,Wait,1
exten => _X.,6,System(php -q /etc/asterisk/php/time.php) ; this is our time generation script
exten => _X.,7,System(sox /tmp/time.wav -r 8000 -c 1 -s -w /var/lib/asterisk/sounds/time.gsm resample -ql)
exten => _X.,8,Wait,1
exten => _X.,9,Playback(time)
exten => _X.,10,Wait,5


Breakdown of PHP Script



<?php //begin php code
$text = "At the third stroke, the time sponsored by accurist will be, "; // set our intro message
$text .= date("'h'") . "" . date("'i'") . " and " . date("'s'") . " seconds BEEP BEEP BEEP"; // get hour, minute and seconds and complete our message sentance.
system('rm /var/lib/asterisk/sounds/time.gsm'); // delete the old time.gsm file
system('/usr/bin/wget -O /tmp/time.wav "http://qs913.pair.com/cepstral/demos/demo.cgi/cepstral.wav?content='.$text.'&voice=Lawrence&rate=160&pitch=1&effect=none&submit=Synthesize+the+Text"'); // using wget, grab the wave file generated by the cepstral demo website and save it to /tmp/ with the filename time.wav
?> // close script tag


Save your new time.php script, reload extentions.conf in asterisk.

Ring your asterisk box.. enjoy!

For more scripts in the future checkout my website http://www.tikka-d.co.uk (currently no asterisk information however).
Created by tikka, Last modification by tikka on Wed 25 of May, 2005 [23:07 UTC]

Comments Filter

A few modifications and a bugfix.

by Tom on Saturday 17 of December, 2005 [16:00:23 UTC]
Hi There,

Thanks for your scripting - it works quite well, even with the time delay to collect the file from the web. I have modified your script to acomplish a few little extras.

a) their website now uses session ID's, and if you don't pass a valid SID, you just get back a "session expired" message.
b) I have changed the output filetype to .sln - aparrently this is asterisk's preferred format these days (not sure)
c) It now reads the text from a file, which allows me to dynamically create messages without rewriting the extensions.conf file each time
d) added -r to wget so it just overwrites any old .wav files that have been downloaded with the same name.

I will be using this to call me when an alarm goes off in the server room... We are using IPmonitor and MOM to email when there is a problem with a server. My next task is to monitor a spool folder and mangle sendmail or procmail so it only passes (and therefore speaks) the important parts of the emails.

usage for this script is:
php speakfile.php sometextfile.txt outputmessage

so in extensions.conf you can use something like:
exten => _X.,2,System(php -q /etc/asterisk/php/speakfile /var/spool/asterisk/sendmailconnector/test.txt outputmessage)
exten => _x.,2,Background(outputmessage);


<?php
$args = $_SERVER"argv";
// read the filename base as the second argument to the script
$filebase=$args2;
// read the textfile contents as the first arguement to the script
// print to screen during debug
//echo file_get_contents("$args1");
$text=urlencode(implode(" ",file("$args1")));
//remove newlines - I'm not sure how cepstral will deal with these.
$remove_nl = array("%0A" => "");
$speechstring=strtr($text,$remove_nl);
// remove the old .sln file, so if it doesn't work at least asterisk can't present incorrect speech
system('rm /var/lib/asterisk/sounds/'.$filebase.'.sln');
// get the session ID
$sid=system('/usr/bin/lynx -source http://qs913.pair.com/cepstral/demos/demo.cgi/cepstral.wav |grep sid |cut -b 43-106');
system('/usr/bin/wget -r -O /tmp/'.$filebase.'.wav "http://qs913.pair.com/cepstral/demos/demo.cgi/cepstral.wav?content='.$speechstring.'&voice=Diane&rate=160&pitch=1&effect=none&submit=Synthesize+the+Text&sid='.$sid.'"');
system('/usr/bin/sox /tmp/'.$filebase.'.wav -t raw -r 8000 -c 1 -s -w /var/lib/asterisk/sounds/p2voice/'.$filebase.'.sln');
?>

My ToDo list is also to incorporate a lockfile, so if one process is currently generating files, another cannot start the same process.

Thanks for your work
Tom :-)

Please update this page with new information, just login and click on the "Edit" or "Add Comment" button above. Get a free login here: Register Thanks! - support@voip-info.org

Page Changes | Comments

Sponsored by:

Terms of Service Privacy Policy
© 2003-2007 Arte Marketing, Inc.

Powered by bitweaver