Advertisement
digigram

WeatherSpeak

Mar 31st, 2013
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.65 KB | None | 0 0
  1. #!/bin/bash
  2. #Simple script to lookup Current weather from AccuWeather and send output to text-to-speak
  3. #Ideas found all over web
  4. #Stitched together by DigiGram (chris@digigram.za.net)
  5.  
  6. #Checking dependencies
  7. command -v curl >/dev/null 2>&1 || { echo >&2 "Maybe try sudo apt-get install curl first"; }
  8. command -v grep >/dev/null 2>&1 || { echo >&2 "Maybe try sudo apt-get install grep first"; }
  9. command -v sed >/dev/null 2>&1 || { echo >&2 "Maybe try sudo apt-get install sed first"; }
  10. command -v espeak >/dev/null 2>&1 || { echo >&2 "Maybe try sudo apt-get install espeak first"; }
  11. command -v curl >/dev/null 2>&1 || { echo >&2 "Maybe try sudo apt-get install curl first"; }
  12.  
  13. #Set these as you wish
  14. location="AF|ZA|FS|PARYS"   #Zip code for US, Location code for International "AF|ZA|FS|PARYS"
  15. voice=mb-us1                #"sudo apt-get install mbrola-us1" (mb-us1) for female, "sudo apt-get install mbrola-us2" (mb-us2) for male. Others exist as well. Even 'n default one if you do not want to install mbrola
  16. cc='ZA'                     #two letter code of your country or state. Leave as XX if you don't want your Country to pe pronounced
  17. country='South Africa'      #Your countries name, or what you would like to hear after your city name. Anything goes.
  18.  
  19. #Done with settings. Sit back and enjoy
  20. #Get weather, parse output, say it out loud
  21. #If it seems to take forever, check your internet connection. If she just speaks to slow, increase -s
  22. curl -s --connect-timeout 30 http://rss.accuweather.com/rss/liveweather_rss.asp?metric=1\&locCode=$location | grep "Currently in" | sed 's/^[ \t]*<description>//' | sed 's/&.*;//' | sed 's/'"$cc"'/'"$country"'/' | espeak -v $voice -s165 -p45 -g3 >/dev/null
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement