Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to make all time greeter using python

import datetime
import time
import pyttsx3
hour = datetime.datetime.now().strftime("%I")
am_or_pm = datetime.datetime.now().strftime("%p")
morning = False
afternoon = False
evening = False
night = False
while True:
    if int(hour) <= 8 and am_or_pm == "AM" and morning == False:
        pyttsx3.speak("Good morning sir")
        morning = True
    elif int(hour) == 12 and am_or_pm == "PM" and afternoon == False:
        pyttsx3.speak("Good afternoon sir")
        afternoon = True
    elif int(hour) >= 4 and am_or_pm == "PM" and evening == False:
        pyttsx3.speak("Good evening sir")
        evening = True
    elif int(hour) == 7 and am_or_pm == "PM" :
        pyttsx3.speak("sir would you like to take a break")
        morning = False
        afternoon = False
        evening = False
        
    time.sleep(10)
        
 
PREVIOUS NEXT
Tagged: #time #greeter #python
ADD COMMENT
Topic
Name
2+2 =