Skip to content

Instantly share code, notes, and snippets.

@chmodsss
Last active July 13, 2016 07:29
Show Gist options
  • Save chmodsss/c4212a261413513db471ad2caf0a02e1 to your computer and use it in GitHub Desktop.
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
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'])
@chmodsss
Copy link
Author

For ubuntu systems to run the script after booting, the following line is added to /etc/rc.local file

sleep 20
python /home/user_name/welcome_greeter.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment