Basically the concept is simple, we are going to write few lines of code in python to get temperature from some URL (openweathermap.org). Then make a string which should speak out by speaker.
Then finally make this python script into cron job into your Mac OS X.
Step 1: Write simple python script code
Step 2 : Check the program is working
Then finally make this python script into cron job into your Mac OS X.
Step 1: Write simple python script code
import urllib # Web service fetch
import json # JSON parse
import os # text to speech convert
## get data from server
url = 'http://api.openweathermap.org/data/2.5/weather?q=Jaipur,In&units=metric'
u = urllib.urlopen(url)
## json parse
data = json.load(u)
## make final string which should speak out
finalMessage = 'In '+data['name']+ ' temprature is '+ str(data['main']['temp']) + ' celcius. Forcasting says it is expacting '+data['weather'][0]['main']
### finally text to speak out
os.system("say "+ finalMessage)
#os.system("echo "+ finalMessage)
Step 2 : Check the program is working
python weather.py