The program '[54148] pythonw.exe' has exited with code 0 (0x0).

  • Thread starter Thread starter KB2001
  • Start date Start date
K

KB2001

Guest
Hi!! Im just start learning creat some AL by python code and that problem just show when im trying to start my code.I don´t know what to do because This is my first time i have this so please help me.Thanks

This is my code:

import speech_recognition
import pyttsx3
from datetime import date
from datetime import datetime

robot_ear = speech_recognition.Recognizer()
robot_mouth = pyttsx3.init()
robot_brain = ""

while True:
with speech_recognition.Microphone() as mic:
print("Robot: I´m Listening")
audio = robot_ear.listen(mic)

print("Robot: ...")


try:
you = robot_ear.recognize_google(audio)
except:
you = ""

print("You: " = you)


if you == "":
robot_brain = "I cant hear you,try again"
elif you == "hello":
robot_brain = "hello sir"
elif "hello" in you:
robot_brain = "Hello sir"
elif "today" in you:
today = date.today()
robot_brain = today.strftime("%B %D, %Y")
elif "time" in you:
now = datetime.now()
robot_brain = now.strftime("%H hours %M minutes %S seconds")
elif you == "today":
today = date.today()
robot_brain = today.strftime("%B %d, %Y")
elif you == "time":
now = datetime.now()
robot_brain = now.strftime("%H hours %M minutes %S seconds")
elif "president of USA" in you:
robot_brain ="Donald Trump"
elif "bye" in you:
robot_brain = "Good Bye,sir"
print("Robot: " + robot_brain)
robot_mouth.say(robot_brain)
robot_mouth.runAndWait()
break
else:
robot_brain = "im fine thank you and you"

print("Robot: " + robot_brain)
robot_mouth.say(robot_brain)
robot_mouth.runAndWait()

Continue reading...
 
Back
Top