import speech_recognition
import pyttsx3
from datetime import date, datetime
robot_ear = speech_recognition.Recognizer()
robot_mouth = pyttsx3.init()
robot_brain = ""
while True:
	with speech_recognition.Microphone() as mic:
		print ("Robot: I'm listenning")
		audio = robot_ear.listen(mic)
	print("Robot: ...")
	try:
		you = robot_ear.recognize_google(audio)
	except:
		you = ""
	print("You: " + you)
	if you == "":
		robot_brain = "I can't hear you, try again"
	elif "friend" in you:
		robot_brain = "His name is Thao Hung Nguyen"
	elif "old are you" in you:
		robot_brain = "I am just two weeks old."
	elif "Vietnamese" in you:
		robot_brain = "Happy New Year! Chuc Mung Nam Moi. Do I say it correctly?"
	elif "your name" in you:
		robot_brain = "My name is Robot Python. Just kidding. I am a ROBOT. I am born from Python language."
	elif "hello" in you:
		robot_brain = "Hello Mister Tuyen Minh Doe"
	elif "today" in you:
		today = date.today()
		robot_brain = "Today is " + today.strftime("%B %d, %Y").replace('0', '')
	elif "time" in you:
		now = datetime.now()
		robot_brain = "Now is " + now.strftime("%H O'clock %M minutes %S seconds").replace('0', '')
	elif "president" in you:
		robot_brain = "Joe Biden"
	elif "John" in you:
		robot_brain = "Sorry, mister John Dinh was passed away in Vietnam in 2023. He is in Heaven now."
	elif "sister" in you:
		robot_brain = "Hello Tuyen's sister. I know you are one of eleven siblings of Tuyen. How are you?"
	elif "brother" in you:
		robot_brain = "Hello Tuyen's brother. I know you are one of eleven siblings of Tuyen. How are you?"
	elif "Helen" in you:
		robot_brain = "Ah ha. Hello Helen. I know Helen is one of Tuyen's sisters. Helen! How are you?"
	elif "Henry" in you:
		robot_brain = "Ah ha. Hello Henry. I know you are one of Tuyen's friends for a long time. Henry, how are you?"
	elif "Dora" in you:
		robot_brain = "Ah ha. Hello Dora's parent. I know Dorathy is  one of Tuyen's nieces. How is Dorathy? And what is she doing now?"
	elif "Thomas" in you:
		robot_brain = "Ah ha. Hello Thomas's parent. I know Thomas is  one of Tuyen's nephews. I'd heard Thomas is joinning the army. How is he doing now?"
	elif "Nathan" in you:
		robot_brain = "Ah ha. Hello Nathan's parent. I know Nathan is  one of Tuyen's nephews. How is Nathan? And what is he doing now?"
	elif "Martin" in you:
		robot_brain = "Ah ha. Hello Martin's parent. I know Martin is  one of Tuyen's nephews. How is Martin? And what is he doing now?"
	elif "Vincent" in you:
		robot_brain = "Ah ha. Hello Vincent Chu. I know you are one of Tuyen's friends for a long time. Vincent, how are you?"
	elif "Angela" in you:
		robot_brain = "She is Kevin's sister."
	elif "how many" in you:
		robot_brain = "Eleven. Three brothers and eight sisters."
	elif "Kevin" in you:
		robot_brain = "Kevin is Angela's brother."
	elif "bye" in you:
		robot_brain = "Good bye... It's nice chatting with you. Talk to you next time."
		print ("Robot: " + robot_brain)
		robot_mouth.say(robot_brain)
		robot_mouth.runAndWait()
		break
	else:
		robot_brain = "I'm fine thank you and you"
	print ("Robot: " + robot_brain)
	robot_mouth.say(robot_brain)
	robot_mouth.runAndWait()
