Asterisk tips Weather PHP

Speak your local Weather using TTS engine (Cepstral)

Updated 2007-Nov-15 Andy Wysocki awysocki (a) absoftware dot_here com

Dial an extenstion and have asterisk pull a file for the weather service and use Cepstrals TTS Engine to convert it to a WAV file and then
have Asterisk play that file.

  • This php applicaiton does NOT need app_cepstral installed
  • Modify the script for your local weather
  • weather.php is the module name

I made a tar file http://qod.com/weather.1.00.tar



Go Back to: Asterisk tips and tricks - Asterisk AGI


Here is the README from the TAR file:

WEATHER 1.00 Nov 15, 2007
awysocki @ absoftware.com


weather.php was created from the festival weather PERL example on voip-info.org
It will pull a text file from noaa.gov weather forcasts and speak it out using
Cepstral TTS engine. This PHP module does NOT need the app_cepstral module installed
or loaded, but it does need Cepstral's swift module installed and working along with
an 8khz voice installed. See http://cepstral.com web site for installing 'swift'.

One known problem with this is if the user hangs up and Asterisk kills the PHP module
then the /tmp/*.txt and tts/*.wav files could be left around

SITES USED FOR SUPPORT AND DEVELOPMENT:
ftp://tgftp.nws.noaa.gov/data/forecasts/city/
http://voip-info.org
http://cepstral.com


CHANGES:
1.00 - Inital release 11/15/2007


INSTALLATION

Copy the weather.php file to the /var/lib/astersik/agi-bin directory. Make sure
the module can be executed by Asterisk. 'chmod a+x weather.php'

Edit the PHP file and modify the $parm_weather_url to point to your local weather file
you can browse the ftp://tgftp.nws.noaa.gov/data/forecasts/city/ ftp server to find
your state and town. Or use the San Franciso example to test with.

Create the /var/lib/asterisk/sounds/tts directory so the swift application can
create the WAV files where asterisk can read them.


Modify you extensions.conf file to create a new extension to call for weather

exten => 65,1,Answer
exten => 65,n,AGI(weather.php)
exten => 65,n,hangup


Reload your dial plan within asterisk, use the command

Asterisk> dialplan reload



HELP:

Things that can go wrong, Cepstral is not installed. You can test this alone with
the command

swift -o test.wav "This is a test"

If that works then try with your 8kHz voice file, change the william to the voice
name you downloaded and installed.

swift -o test.wav -n william-8kHz "This is a test"

If this works, make sure you have PHP installed on your system.

php -v


Other options is to turn on debugging in the PHP module
set the variable in the PARM section

$parm_debug_on=1;

If you hear the SOMETHING HAS GONE TERRIBLY WRONG then check that you created
the TTS directory under the sounds directory of Asterisk

Good luck



~~
FAQ
~~

"Q1 - I call in and don't hear anything"

A1 - There can be lots of issues here, Check that the PHP script in the cgi-bin directory has the execute bit on. check that the php file is formatted for unix. (use dos2unix command) and last, turn on the parm_debug_on option and look at the log file created by the PHP file. It should help you out, if its not created then check with Asterisk as to why it may not be calling the script

Any other problems e-mail me and as time permits I will help you out


See Also my other scripts:
Asterisk tips Wake-Up Call PHP - Asterisk tips Airport Weather PHP
Speak your local Weather using TTS engine (Cepstral)

Updated 2007-Nov-15 Andy Wysocki awysocki (a) absoftware dot_here com

Dial an extenstion and have asterisk pull a file for the weather service and use Cepstrals TTS Engine to convert it to a WAV file and then
have Asterisk play that file.

  • This php applicaiton does NOT need app_cepstral installed
  • Modify the script for your local weather
  • weather.php is the module name

I made a tar file http://qod.com/weather.1.00.tar



Go Back to: Asterisk tips and tricks - Asterisk AGI


Here is the README from the TAR file:

WEATHER 1.00 Nov 15, 2007
awysocki @ absoftware.com


weather.php was created from the festival weather PERL example on voip-info.org
It will pull a text file from noaa.gov weather forcasts and speak it out using
Cepstral TTS engine. This PHP module does NOT need the app_cepstral module installed
or loaded, but it does need Cepstral's swift module installed and working along with
an 8khz voice installed. See http://cepstral.com web site for installing 'swift'.

One known problem with this is if the user hangs up and Asterisk kills the PHP module
then the /tmp/*.txt and tts/*.wav files could be left around

SITES USED FOR SUPPORT AND DEVELOPMENT:
ftp://tgftp.nws.noaa.gov/data/forecasts/city/
http://voip-info.org
http://cepstral.com


CHANGES:
1.00 - Inital release 11/15/2007


INSTALLATION

Copy the weather.php file to the /var/lib/astersik/agi-bin directory. Make sure
the module can be executed by Asterisk. 'chmod a+x weather.php'

Edit the PHP file and modify the $parm_weather_url to point to your local weather file
you can browse the ftp://tgftp.nws.noaa.gov/data/forecasts/city/ ftp server to find
your state and town. Or use the San Franciso example to test with.

Create the /var/lib/asterisk/sounds/tts directory so the swift application can
create the WAV files where asterisk can read them.


Modify you extensions.conf file to create a new extension to call for weather

exten => 65,1,Answer
exten => 65,n,AGI(weather.php)
exten => 65,n,hangup


Reload your dial plan within asterisk, use the command

Asterisk> dialplan reload



HELP:

Things that can go wrong, Cepstral is not installed. You can test this alone with
the command

swift -o test.wav "This is a test"

If that works then try with your 8kHz voice file, change the william to the voice
name you downloaded and installed.

swift -o test.wav -n william-8kHz "This is a test"

If this works, make sure you have PHP installed on your system.

php -v


Other options is to turn on debugging in the PHP module
set the variable in the PARM section

$parm_debug_on=1;

If you hear the SOMETHING HAS GONE TERRIBLY WRONG then check that you created
the TTS directory under the sounds directory of Asterisk

Good luck



~~
FAQ
~~

"Q1 - I call in and don't hear anything"

A1 - There can be lots of issues here, Check that the PHP script in the cgi-bin directory has the execute bit on. check that the php file is formatted for unix. (use dos2unix command) and last, turn on the parm_debug_on option and look at the log file created by the PHP file. It should help you out, if its not created then check with Asterisk as to why it may not be calling the script

Any other problems e-mail me and as time permits I will help you out


See Also my other scripts:
Asterisk tips Wake-Up Call PHP - Asterisk tips Airport Weather PHP
Created by: awysocki, Last modification: Fri 16 of Nov, 2007 (04:38 UTC)
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+