Huge thanks to Joshua Colp for mirroring services

Asterisk@home festival weather report

Share on Twitter Digg this story Click to view a printable version Fri, 25 Feb 2005 03:21:16 -0500

Dean Collins has posted a script to allow you to get a weather report via the Festival Speech Synthesis engine:

This script was developed by Mark Johnson.

All I did (Dean Collins) was type up the instructions and make it easy to understand.

This Script will allow you to dial and extension number on your Asterisk@home V0.6 or later pabx and have it read you the weather for your city

How it does this is;

1/ When you dial your extension it causes the weather.agi script to run

2/ This makes the program net::ftp connect to the internet and download a text file from the weather.noaa.gov computer

3/ Festival the 'reads' this text file out to you

Net::ftp is now part of the perl library so you dont need to download this

Festival is installed from V0.6 or later of Asterisk@home so you dont need to download this

You need to work out which text file is suitable for yourself and modify the text below

my $custpath = "city/oh";
my $filename = "youngstown.txt";

The way I worked out what was suitable for me in NY, new_york was to log in via a ftp client and manually browse through to the appropriate folder. Now you have all the appropriate information - lets start.

So Step 1 - Copy the text below into Notepad and name it weather.agi

#!/usr/bin/perl -w

use Asterisk::AGI;
use Net::FTP;

my $AGI = new Asterisk::AGI;
my $server = "weather.noaa.gov";
my $basepath = "data/forecasts";
my $custpath = "city/oh";
my $filename = "youngstown.txt";

my @lines;

$AGI->exec('AGI',"festival-script.pl|"Please wait while I get the latest forecast."");

$ftp = Net::FTP->new($server, Debug => 0)
or die "Cannot connect to $server: $@";

$ftp->login("anonymous","a@b.com")
or die "Cannot login with anonymous/a@b.com", $ftp->message;

$ftp->cwd("$basepath/$custpath")
or die "Cannot change working directory ", $ftp->message;

$ftp->binary;
$ftp->get($filename,"/tmp/$filename.$$") || die "Error while downloading /tmp/$filename.$$!!!n", $ftp->message;

open(INPUT,"

while(<INPUT>) {
if(grep(/^./,$_)) {
chomp($_);
$_ =~ s/^.//;
push(@lines,$_);
print "$_n";
}
}

for($i = 0; $i < scalar(@lines); $i++) {
$AGI->exec('AGI',"festival-script.pl|"$lines[$i]"");
}

$AGI->exec('AGI',"festival-script.pl|"Thank you and please call again!"");
unlink("/tmp/$filesname.$$");
exit;

Step 2 - Copy the text below into Notepad and name it festival-weather-script.pl

#!/usr/bin/perl

#make a tts dir inside your sounds dir (as specified below)
#adjust the t2wp variable to point to your festival bin directory

use Asterisk::AGI;
use File::Basename;
use Digest::MD5 qw(md5_hex);

$AGI = new Asterisk::AGI;

my %input = $AGI->ReadParse();
my ($text)=@ARGV;
my $hash = md5_hex($text);
my $sounddir = "/var/lib/asterisk/sounds/tts";
my $wavefile = "$sounddir/"."tts-$hash.wav";
my $t2wp= "/usr/src/festival/bin/";

unless (-f $wavefile) {
open(fileOUT, ">$sounddir"."/say-text-$hash.txt");
print fileOUT "$text";
close(fileOUT);
my $execf=$t2wp."text2wave $sounddir/say-text-$hash.txt -F 8000 -o $wavefile";
system($execf);
unlink($sounddir."/say-text-$hash.txt");
}
$AGI->stream_file('tts/'.basename($wavefile,".wav"),1);

STEP 3 - Copy the 2 files into your /var/lib/asterisk/agi-bin directory

I use a program called winscp to do this [http://winscp.sourceforge.net/eng/index.php]

(it looks just like a ftp program but allows you to connect to asterisk and swap files between your windows pc and asterisk server)

STEP 4 - Create an extension number for your weather report.

I use Extension 850. The reason I use this is because in the asterisk@home installations AMP uses the 800 series for the Meetme rooms.

As this is similar to a Meetme function I'm going to put all of my festival extensions from 850 onwards.

Be carefule you dont have an extension on your pabx called 50 (because AMP will over write this Weather code with the meetme room number 850 for extension 50)

4/a) Log into Asterisk@home using a browser http://-asterisk-ip-adress/admin

Then click on Maintenance
Then click on ConfigEdit
Then click on Extensions.conf

Now you need to scroll down to where you see the [ext-meetme] context about ¾ of the way down the file

[ext-meetme]

exten => _8X,1,Answer
exten => _8X,2,Wait(1)
exten => _8X,3,GotoIf($[${CALLERIDNUM} = ${EXTEN:1}]?5:4)
exten => _8X,4,MeetMe2(${EXTEN}|sM)
exten => _8X,5,MeetMe2(${EXTEN}|asM)

etc
etc
etc

4/b) Then add the following text at the end of the context

exten => 850,1,Answer
exten => 850,2,AGI(weather.agi);
exten => 850,3,Hangup

that's it, reboot your pc, dial 850 and listen to the weather.

Any problems copy and paste your cli with any errors.

Cheers,

Dean


You haven't voted yet! Vote:
Current Rating: 0/10 (0 votes)

Comments (Click to post)

Comments
Name:
Subject:
Website:
Message: 

Similar Articles (Based on Title)

Asterisk-Users: AGI File for unpatched Festival - October 14, 2004
Donny Kavanagh has released an AGI file to allow text to speech from Festival to be used with Asterisk without patching Festival. He also asks for help with Sphinx (speech to text).

Report on Day 2 of Astricon by LennyT - September 24, 2004
Awesome notes of Astricon Day 2, check them out

VoIP-forum.com: NIST report urges caution with VoIP security - January 28, 2005
Olle's site has posted a link to an article on VoIP security.

*-Dev: Jitterbuffer in CVS HEAD: How to use, how to report problems - March 18, 2005
Steve Kann has posted some instructions for using the new jitterbuffer and PLC (Packet Loss Concealment) code in Asterisk CVS-HEAD.

Adventures in RTCP - a short report - January 28, 2010
Olle has posted a writeup on his RTCP work - still could do with more testers.

Nerd Vittles: Weather, Weather, Everywhere - May 18, 2006
Nerd Vittles today introduces new Weather Forecasts for Asterisk using Carnegie Mellon Universitys new voice synthesis system, Flite.

Small Asterisk Weather / Cepstral Howto - June 3, 2006
Matt Gibson has posted details of a weather script for Cepstral.

Nerd Vittles: Weather reports - June 16, 2006
Nerd Vittles today walks you through turning your Asterisk server into a branch office of the National Weather Service...

Nerd Vittles: The Asterisk Weather Station - December 12, 2006
Nerd Vittles today introduces the ultimate Weather Station for any Asterisk system. And it works from any phone.

Nerd Vittles: Weather, Weather Everywhere - February 8, 2007
Nerd Vittles today introduces its new worldwide weather forecasting system for Asterisk...

Asterisk@Home 0.3 iso released - January 11, 2005 - January 13, 2005
Andrew has mailed us to let you know that the latest version of the Asterisk@Home ISO has been released.

Asterisk@Home 0.3 iso released - January 19, 2005
Jason Becker (of AMP fame) has let us know that Version 0.3 of the Asterisk@Home iso has been released. It now includes AMP.

Asterisk@Home 0.5 Released today - February 12, 2005
The Asterisk@Home team have mailed us about the latest version of Asterisk@Home.


Original Content (C) 2004-2010 Matt Riddell
Back 5  Feed Add
to
Google Subscribe with Bloglines
Go to today

Icons by: FastIcon.com


Back to life
July 21, 2010 Average Vote: 10
Hey all - I am back online after some pretty big projects which have taken all my time. Will be updating the Asterisk news over the next few days.

Nerd Vittles: Building a Bluetooth Proximity Detection System with Asterisk
December 12, 2005 Average Vote: 10
The Nerd Vittles site has an article on proximity detection using Asterisk and a TomTom GPS

Automated Testing Update
July 30, 2010 Average Vote: 10
Russell Bryant has posted details of a new mailing list for automated testing of Asterisk and some information on the progress that has been made. There is no way to say how important I think this work is. It really makes a huge difference to Asterisk and the ability to use it in an enterprise environment. Really great work.

VoIP-Info: FFasterisk Video file converter
August 25, 2006 Average Vote: 10
The wiki has a link to a new piece of software for converting video to the format required for Asterisk.

Code Review: SRTP support for Asterisk
March 12, 2009 Average Vote: 10
Terry Wilson has moved his SRTP branch onto the Digium review board.

HumBug - Pre BETA Launch Registration
July 27, 2010 Average Vote: 10
Nir Simionovich has posted details of the beta of the new call analytics service.

Interview with BKW_
December 7, 2004 Average Vote: 10
We've finally completed our interview with BKW. Hope you like! :-)

SlashDot: GSM and Asterisk Integration
August 21, 2005 Average Vote: 10
There is a post up on SlashDot which talks about using cellphones with Asterisk.

Interview with Mark Spencer
November 26, 2004 Average Vote: 9.9
We have managed to get an interview with Mark Spencer AKA Markster. Mark Spencer is the creator of Asterisk and by far the most active developer.

Asterisk and Kamailio realtime integration tutorial
May 24, 2010 Average Vote: 9.9
Daniel-Constantin Mierla has posted a link to a tutorial on integrating Asterisk and Kamailio using realtime.

Asterisk IPv6 update
February 1, 2010 Average Vote: 9.8
Olle has posted an update on IPV6 in Asterisk and a link to a blog post of his.

Proposal for T.38 transparent gateway design in Asterisk
April 29, 2010 Average Vote: 9.8
Kevin Fleming has posted a proposed design for a transparent T.38 gateway for Asterisk:

Asterisk Monitoring with iPhone and iPod touch
February 12, 2010 Average Vote: 9.7
For the past couple of weeks I have been working on an app that allows you to monitor and restart Asterisk servers.

Monitoring Asterisk with Munin
January 7, 2010 Average Vote: 9.7
I had a few requests for these munin plugins after some discussion on one of the Asterisk lists and thought people might like them.

New Zealand Asterisk Voices
March 2, 2006 Average Vote: 9.7
Chris Hodgetts has posted details of recordings of Asterisk Sounds with a New Zealand accent.


Automated Testing Update
July 30, 2010
Russell Bryant has posted details of a new mailing list for automated testing of Asterisk and some information on the progress that has been made. There is no way to say how important I think this work is. It really makes a huge difference to Asterisk and the ability to use it in an enterprise environment. Really great work.

Asterisk 1.8.0-beta2 Now Available
July 28, 2010
The Asterisk Development Team has announced the release of Asterisk 1.8.0-beta2.

HumBug - Pre BETA Launch Registration
July 27, 2010
Nir Simionovich has posted details of the beta of the new call analytics service.

Branch Merging Changes
July 26, 2010
Russell Bryant has posted details of some changes to the way developers need to commit code to Asterisk because of the newly released 1.8 branch.

Asterisk 1.8.0-beta1 is Now Available
July 26, 2010
The Asterisk Development Team has announced the release of Asterisk 1.8.0-beta1. This release marks the beginning of the testing process for the eventual release of Asterisk 1.8.0.

Asterisk 1.6.2.10 Now Available
July 26, 2010
The Asterisk Development Team has announced the release of Asterisk 1.6.2.10.

Asterisk 1.4.34 Now Available
July 26, 2010
The Asterisk Development Team has announced the release of Asterisk 1.4.34.

AppleRaisin - AstDB over realtime
July 23, 2010
Olle has posted a note about his awesome AppleRaisin branch which provides the ability to store AstDB in realtime. This would make for a much simpler failover and clustering situation.

QueueMetrics 1.6.1 released
July 22, 2010
Lenz has posted a note to inform us that QueueMetrics version 1.6.1 has been released. This release offers a large number of bug fixes, misc improvements and new developements including hotdesking.

Asterisk 1.8 Branch Creation
July 22, 2010
Russell Bryant has posted a note to inform us of the creation of the 1.8 branch of Asterisk.