import pyttsx3 as pyt
import datetime as DT
hour = int(DT.datetime.now().hour)
print(hour)
# enter code here
speak = pyt.init()
voices = speak.getProperty('voices')
speak.setProperty('voice', voices[1].id)
if hour>= 0 and hour<12:
speak("Good Morning Sir !")
elif hour >=0 and hour<12 and hour<18:
speak("Good Afternoon Sir !")
Asked
Active
Viewed 568 times
-1

GeeTransit
- 1,458
- 9
- 22

Mahmoud Ahmed
- 3
- 3
1 Answers
0
You'll want to call speak.say
instead of just speak
like such:
if hour>= 0 and hour<12:
speak.say("Good Morning Sir !")
elif hour >=0 and hour<12 and hour<18:
speak.say("Good Afternoon Sir !")
And also, you should rename speak
to engine
to be more descriptive. Here's an example from the docs:
import pyttsx3
engine = pyttsx3.init()
engine.say('Sally sells seashells by the seashore.')
engine.say('The quick brown fox jumped over the lazy dog.')
engine.runAndWait()

GeeTransit
- 1,458
- 9
- 22