One reason I think that the weather forecast module never took off is because it was, IMHO, never properly coded. Never mind that it used the crappy festival or flite synthesized voices, which was bad enough, but it also paused in unnatural places due to its inability to skip over line breaks in the original forecast. To me, it was always painful to listen to - I could never actually understand what was being said because I was so hung up on how bad it sounded, particularly the seemingly random pauses that were caused because it treated a new line as if it were a period or other indication that it should pause.
The one I have liked the best used the Cepstral voices, which are not free, but sound 1000% better than any of the free synthesized voices. But even if you don’t want to use the Cepstral voices, the routine could easily be modified to use the flite or festival synthesizer, and it does eliminate the unnatural pauses. You can find that code at …
http://www.voip-info.org/wiki/view/Modified+Weather.agi+to+Work+with+Cepstral
(THE ABOVE IS ONE LINE, this forum mangles lines that are too long so you’ll have to join them)
… but don’t use the first weather.agi on the page (and don’t follow the link to the Trixbox forum), instead skip about halfway down the page to where it says “Alternative change (Not by the original poster:).”
One thing that has changed recently is that you can now buy an “Allison” voice from Cepstral to give your system a fairly uniform voice. One bad thing about the Cepstral voices is that there are occasional words they just don’t get right, but fortunately you can usually do a phonetic substitution to tweak that problem for commonly-used words (you can use the same technique to change odd references to local landmarks, for example if the NWS insists on using “highway 75” when everyone knows it as “Interstate 75” you can make that substitution). The code gives examples, for example the Cepstral voice couldn’t say “daybreak” properly so the code author substituted “day brake.”
Having said that, bear in mind that if you live near a major city you may be able to simply download and play an AccuWeather forecast (I don’t know about the legality of this if you do it in a commercial environment, so you may want to check with AccuWeather if you have any questions about that). A list of cities for which podcasts are available can be found here: http://www.accuweather.com/promotion.asp?dir=aw&page=podcast
Let’s say you want a forecast for the Twin Cities of Minneapolis/St. Paul (just as an example, you could add something like this as a Dialplan Injection or in extensions_custom.conf (this is how it appears as a Dialplan Injection, using Naftali5’s module):
Ringing
AGI(mspweather.agi)
GotoIf($[“x${IVR_CONTEXT}” = “x”]?app-blackhole,hangup,1:${IVR_CONTEXT},return,1)
The last line means that if you called the forecast directly it should hang up afterwards, but if you goth here via an IVR it should return to the IVR and let you make another selection. Anyway, here’s what mspweather.agi looks like - note that for it to work you must have all of the Perl modules called by the script installed (Asterisk::AGI is probably already installed, but XML::Simple and/or LWP::Simple may not be, so you may have to install whatever is missing), and you must have have lame installed in /usr/bin/lame (change the path in the script if lame is somewhere else on your system):
#!/usr/bin/perl
use XML::Simple;
use Asterisk::AGI;
use LWP::Simple;
$AGI = new Asterisk::AGI;
$xml = new XML::Simple;
$noext = "/tmp/mspweather";
$resampled = $noext . ".mp3";
$AGI->verbose("Getting XML file\n",1);
$data = $xml->XMLin(get("http://podcast.accuweather.com/podcast_rss/msp.xml"));
$url = $data->{channel}->{item}->{enclosure}->{url};
$AGI->verbose("Extracted URL $url from XML file",1);
$url =~ m#(?:.*/)(.*)$#;
$podcast = "/tmp/" . $1;
if (-s $podcast)
{
$AGI->verbose("$podcast already exists - skipping download\n",1);
}
else
{
system ('rm /tmp/MSP*.mp3');
$AGI->verbose("Getting $url\n",1);
getstore("$url", "$podcast") or die "Could not retrieve podcast";
$AGI->verbose("$podcast retrived\n",1);
system("/usr/bin/lame --silent --mp3input --scale 20 --abr 32 -m m -h $podcast $resampled")==0 or die "Could not convert file";
$AGI->verbose("$pd converted to $resampled\n",1);
}
# $podcast =~ s/\.\w*$//;
$AGI->answer;
$AGI->exec("ControlPlayback","$noext|5000|6|4|#|*|1");
exit;
A couple notes on the above: The system call to lame is to change the volume so it’s at a comfortable listening level. And the use of ControlPlayback lets you skip through the forecast (or back up) if you like.
The AccuWeather forecasts are free to download and sound a lot better than anything you can generate locally, but since Accuweather is a commercial product I’d only use them on a home or noncommercial system, and not expose them to outside callers. To avoid copyright issues and still have a reasonably good sounding forecast, I’d go with the Cepstral voices and the NWS forecasts.
[Rant about the forum software removed - the issues I was having back then have mostly been fixed.]