On the colon of the 'time' if statement is a syntax error. I am pretty new to python AND python syntax is kinda weird for me. (I come from Java)
It doesent show the error code for some reason. There is just a window that pops up saying 'Syntax Error' (I am using IDLE).
I am working on Ubuntu 18.04.1 LTS. Have tried putting if statements outside with. Have tried putting if statements outside def.
def button_clicked():
with sr.Microphone() as source:
print ('What do you want me to do?')
audio = r.listen(source)
text = r.recognize_google(audio)
print(text)
if text == 'exit' or text == 'stop':
os.system("espeak 'Bye Bye!'")
sys.exit()
if text == 'date':
date = str(datetime.datetime.now().date())
os.system("espeak '{}'".format(date)
if text == 'time':
time = str(datetime.datetime.now().time())
os.system("espeak '{}'".format(time)
Gives an error. Should not give an error.
Note: I am posting for the first time on stack overflow, excuse if my post doesent meet the standards. If it doesent please point it out and I will make note of it.
Aucun commentaire:
Enregistrer un commentaire