Upgrade 3CX to v18 and get it hosted free!

Asterisk tips Weather PHP

Author image

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

Go Back to: Asterisk tips and tricksAsterisk 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/
https://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 PHPAsterisk tips Airport Weather PHP


Article Reviews

Write a Review

Your email address will not be published. Required fields are marked *

Required Field. Minimum 5 characters.

Required Field. Minimum 5 characters, maximum 50.

Required field.There is an error with this field.

Required Field.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

There are no reviews for this article. Be the first one to write a review.

Related Posts:

Get 3CX - Absolutely Free!
Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.