Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. from StackOverflow import Speak
  2. import datetime
  3.  
  4. def time_compare():
  5. now = datetime.datetime.now()
  6. today12pm = now.replace(hour=12,minute=0,second=0,microsecond=1)
  7. today4pm = now.replace(hour=15,minute=0,second=0,microsecond=0)
  8. today6pm = now.replace(hour=18, minute=0, second=0, microsecond=0)
  9.  
  10. if now < today12pm:
  11. Speak.Sen_speak ("Good Morning Shiv!")
  12. elif today12pm <= now and now < today4pm:
  13. Speak.Sen_speak("Good Afternoon Shiv")
  14. elif today4pm <= now and now <today6pm:
  15. Speak.Sen_speak("Good Evening Shiv")
  16. else:
  17. Speak.Sen_speak("It seems to be night, are we really going to work")
  18. input("Press Enter To exit")
  19.  
  20. time_compare()
  21.  
  22. import pyttsx
  23.  
  24.  
  25. def Sen_speak(msg):
  26. try:
  27. engine = pyttsx.init()
  28. engine.setProperty('voice', 'HKEY_LOCAL_MACHINESOFTWAREMicrosoftSpeechVoicesTokensTTS_MS_EN-US_ZIRA_11.0')
  29. engine.say(msg)
  30. engine.runAndWait()
  31. return 'said'
  32. except:
  33. return 'Err'
  34.  
  35.  
  36. def Testing_method():
  37. message = raw_input("Enter To Speak")
  38. result = Sen_speak(message)
  39. if result == 'said':
  40. print ("Said Successfully")
  41. else:
  42. print ("Error With Sound")
  43.  
  44.  
  45.  
  46. #Testing_method()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement