Podcasting Weather Forecasts

The podcasting technique described in Chapter 4 is a hotbed of development at the moment. One idea put forward was to use it to deliver weather forecasts via a web service and a text-to-speech application.

Jorge Velázquez put together a script to do just that. Released at http://www.jorgev.com/archives/000115.html, it requires an account with weather.com and an installation of Lame (from http://lame.sourceforge.net/) and text2wave on the server.

How to Use It

The URL accepts two parameters, locid and unit . The locid is the weather.com location identifier for the city you require. For U.S. cities, this can be a zip code, and for non-U.S. cities, it is a special weather.com code. (e.g., 92126 for San Diego, CA, or ITXX0067 for Rome, Italy). The unit parameter is optional and can be either m for metric or s for imperial measurements. It defaults to imperial.

The location code for Florence, Italy, is ITXX0028, so the URL for the feed would be http://www.example.com/cgi-bin/weather.cgi?locid=ITXX0028. Simple.

The Code Itself

Jorge’s code is, in his own words, very simple. This is how he describes it:

A brief explanation of how the script works, it’s actually quite simple: I first call into weather.com’s XML Data Feed. Then I use XPath to extract the data in which I am interested. I format this information into a text file, which I then pass onto the text2wave utility which performs the text-to-speech conversion. Finally, since wav files are so huge, I convert ...

Get Developing Feeds with RSS and Atom now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.