Last active
July 13, 2016 07:29
-
-
Save chmodsss/c4212a261413513db471ad2caf0a02e1 to your computer and use it in GitHub Desktop.
python script using espeak for voice greeting with time and weather during system startup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess, datetime, time | |
welcome = "Hello Siva, welcome" | |
s = '-s 140' | |
g = '-g 0.8' | |
f = '-vf3' | |
a = '-a 150' | |
day = datetime.date.today().strftime('%A') | |
month = datetime.date.today().strftime('%B') | |
date = datetime.date.today().strftime('%d') | |
subprocess.call(['espeak',s,g,f,a,welcome]) | |
time.sleep(0.7) | |
subprocess.call(['espeak',s,g,f,a,'Today is'+day+date+month]) | |
time.sleep(0.4) | |
# EDDK is the icao code for Bonn. Change it to the icao code for your city | |
weather_process = subprocess.Popen(['weather','-i','EDDK'], stdout= subprocess.PIPE) | |
weather_info = weather_process.communicate() | |
temp = weather_info[0].splitlines()[2] | |
wtr = weather_info[0].splitlines()[-1] | |
temperature = temp[temp.find('(')+1 : -3] | |
weather = wtr[wtr.find(':')+2 :] | |
subprocess.call(['espeak',s,g,f,a,'The outside temperature is'+str(temperature)+'degrees']) | |
time.sleep(0.4) | |
subprocess.call(['espeak',s,g,f,a,'and the weather is'+weather]) | |
time.sleep(0.4) | |
subprocess.call(['espeak',s,g,f,a,'Have a nice day']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For ubuntu systems to run the script after booting, the following line is added to
/etc/rc.local
file