Hack52.Get Your Daily Weather Forecast from Your Telephone

Hack 52. Get Your Daily Weather Forecast from Your Telephone

The Weather Channel has "Local on the 8s" every 10 minutes, but why wait 10 minutes for your forecast when you can be listening to it on your IP phone right now?

Aside from cataloging sea species and running a really great tsunami readiness web site, the National Oceanic and Atmospheric Administration (NOAA) also operates the National Weather Service. Those are the guys from whom excitable TV meteorologists get their severe weather warning and watch information. But TV weather guys don't have an exclusive on NOAA's weather data feeds.

At NOAA's web site, http://www.noaa.gov/, localized weather data is published in text-file feeds that are updated regularly. Your Asterisk server can grab these feeds and, thanks to Festival [Hack #92], read you a weather report based on their contents. Have a look at this example:

 exten => 50,1,Answer exten => 50,2,System(/usr/bin/curl -s \ ftp://weather.noaa.gov/data/forecasts/city/oh/cleveland.txt \ | text2wave weather-feed.wav exten => 50,3,Wait(1) exten => 50,4,Playback(/tmp/weather-feed.wav) exten => 50,5,System(rm /tmp/weather-feed.wav -f) exten => 50,6,Hangup 

The extension 50 grabs the text feed for Cleveland, Ohio, using the curl application, and immediately converts it using text2wave, a piece of the Festival distribution, into a WAV, which it plays back using Asterisk. If you want to keep tabs on the weather in a few different cities, you can create an extension for each.

If you don't have curl, grab it from http://curl.haxx.se/.

VoIP Hacks
VoIP Hacks: Tips & Tools for Internet Telephony
ISBN: 0596101333
EAN: 2147483647
Year: 2005
Pages: 156

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net