Skip to content

Instantly share code, notes, and snippets.

@myroslav
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save myroslav/6a8141538a263f647939 to your computer and use it in GitHub Desktop.
Save myroslav/6a8141538a263f647939 to your computer and use it in GitHub Desktop.
Weather ratox oracle
#!/usr/bin/sh
tail -n0 -f text_out | while read line; do
address=${line:17:${#line}} # strip off date time
echo "Predicting weather at $address. Wait a moment and pick up the call!.." > text_in
curl -s --get --data-urlencode "query=$address" \
http://api.wunderground.com/auto/wui/geo/ForecastXML/index.xml | \
perl -ne '/<title>([^<]+)/&&printf "%s: ",$1;/<fcttext>([^<]+)/&&print $1,"\n"' | \
perl -MHTML::Entities -pe 'binmode(STDOUT, ":encoding(utf8)"); decode_entities($_);' | \
perl -MHTML::Entities -pe 'binmode(STDOUT, ":encoding(utf8)"); decode_entities($_);' | \
text2wave | sox -t wav - -r 48000 -c 1 -e signed -b 16 -L -t wav - > call_in
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment