[Asterisk-Users] festival text for weather report
dean collins
dean at collins.net.pr
Thu Feb 17 16:07:09 MST 2005
Hi Ernie,
Man I hope you didn't write all of that for me, I feel really bad now, someone posted to the list about 15 mins after I posted with the solution lol- I've already been playing with it for hours working out what other sites I can get it to read from as well.
Thanks anyway - good practive I guess.
I'm modifying the festival wikki page once I work out how.
Cheers,
Dean
-----Original Message-----
From: asterisk-users-bounces at lists.digium.com [mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Ernie Ankele
Sent: Thursday, February 17, 2005 5:39 PM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [Asterisk-Users] festival text for weather report
Dean,
Here is a rough starting point for you.
Put this into your /var/lib/asterisk/agi-bin/ directory. I used the
name getforecast. (Change the ZIP code info, line 29) and make it
executable.
<<< - FILE BEGIN ->>>
#!/bin/bash
# I grab the data from asterisk even though I don't use it
while read -e ARG && [ "$ARG" ] ; do
array=(` echo $ARG | sed -e 's/://'`)
export ${array[0]}=${array[1]}
done
checkresults()
{
while read line
do
case ${line:0:4} in
"200 " ) echo $line >&2
return;;
"510 " ) echo $line >&2
return;;
"520 " ) echo $line >&2
return;;
* ) echo $line >&2;;
esac
done
}
# answer the line and give some preliminary feedback
echo "ANSWER "
checkresults
echo "STREAM FILE national-weather-service \"\" "
checkresults
# Grab the forecast info page -- 80003 is MY zipcode, CHANGE TO YOUR
ZIPCODE!
tempstr=` curl -s "http://weather.toolbot.com/?where=80003&RSS" `
# Cleanup the results, get rid of html tags etc. (Could probably be
condensed)
tempstr=` echo $tempstr | sed 's:<?.*<h3>::g' | sed 's:=<.*$::'
| sed 's:<br />:~:g'|\
sed 's:<[br /h3]*>::g' | sed 's:nbsp;: :g' | sed
's:&::g' | sed 's:mph:miles per hour:g' `
# Create 'EOF' Mark in tempstr
tempstr=`echo $tempstr "~XOX" `
# Loop through string, echoing to file, convert to wave, speak them,
etc.
until [ "$tempstr" == "XOX" ]
do
lineout=`echo $tempstr | cut -f1 -d"~" `
echo $lineout > /tmp/linetospeak.txt
text2wave -f 8000 -o /tmp/forecastline.wav /tmp/linetospeak.txt
echo "STREAM FILE /tmp/forecastline \"1\""
checkresults
tempstr=` echo $tempstr | cut -f2- -d"~" `
done
echo "STREAM FILE goodbye \"\""
checkresults
rm /tmp/linetospeak.txt
rm /tmp/forecastline.wav
echo "HANGUP "
checkresults
<<<- FILE END ->>>
I have the following in my extensions.conf:
exten => 2996,1,Answer
exten => 2996,2,wait(1)
exten => 2996,3,agi,getforecast
exten => 2996,4,Hangup
I'm not sure how you enter the extension.conf in asterisk at home.
NOTE: I am still LEARNING shell scripting & AGI, so the above may be
kind of hack-ish. Helpful suggestions/advice very welcome!
Ernie Ankele
On Feb 16, 2005, at 9:24 PM, dean collins wrote:
> http://www.srh.noaa.gov/fwd/productviewnation.php?
> pil=OKXZFPOKX&version=0
>
>
>
> can anyone suggest how I could set up asterisk at home to read out
> allowed the following text when I dial extension 850?
>
>
> 815 PM EST WED FEB 16 2005
>
> .OVERNIGHT...MOSTLY CLEAR. LOWS 30 TO 35. NORTHWEST WINDS 15 TO 20
> MPH WITH GUSTS UP TO 30 MPH...DIMINISHING TO 10 TO 15 MPH LATE.
> .THURSDAY...PARTLY CLOUDY. COOLER WITH HIGHS AROUND 40. NORTHWEST
> WINDS AROUND 15 MPH.
> .THURSDAY NIGHT...PARTLY CLOUDY. LOWS IN THE MID 20S. WEST WINDS
> AROUND 15 MPH.
> .FRIDAY...PARTLY CLOUDY AND BRISK. HIGHS IN THE MID 30S. NORTHWEST
> WINDS 15 TO 25 MPH.
> .FRIDAY NIGHT...PARTLY CLOUDY AND BRISK. LOWS AROUND 17. NORTHWEST
> WINDS 15 TO 25 MPH.
>
>
>
>
>
>
>
>
>
> There's $20 via paypal to the first person to help me complete this
> (I'll then post it on the the wiki so anyone can replicate it)
>
> (anyone wanting to add to that bounty email me)
>
>
>
> Also if it is not too difficult I'd like it to skip to the next block
> each time you press '1' (eg go from overnight to Thursday)
>
>
>
> Also it doesn't need to be this particular web page that it connects
> to but something with current weather etc.
>
>
>
>
>
>
>
> Cheers,
>
> Dean
>
>
> _______________________________________________
> Asterisk-Users mailing list
> Asterisk-Users at lists.digium.com
> http://lists.digium.com/mailman/listinfo/asterisk-users
> To UNSUBSCRIBE or update options visit:
> http://lists.digium.com/mailman/listinfo/asterisk-users
_______________________________________________
Asterisk-Users mailing list
Asterisk-Users at lists.digium.com
http://lists.digium.com/mailman/listinfo/asterisk-users
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users
More information about the asterisk-users
mailing list