antonello_image = face_recognition.load_image_file("faces/anto.jpg")
antonello_image_encoding = face_recognition.face_encodings(antonello_image)[0]
def say(text, language = 'en'):
speech = gTTS(text = text, lang = language, slow = False)
mp3_file = 'text.mp3'
speech.save(mp3_file)
p = vlc.MediaPlayer(mp3_file)
p.play()
time.sleep(2)
def process_answer():
recognizer = sr.Recognizer()
microphone = sr.Microphone()
with microphone as source:
recognizer.adjust_for_ambient_noise(source)
audio = recognizer.listen(source)
try:
response = recognizer.recognize_google(audio)
print('Received response {}'.format(response))
except sr.RequestError:
print('Error')
except sr.UnknownValueError:
response = 'Sorry I cannot understand'
return response
person = recognize() # using the face recognition
say('Hello ' + person + ', are you ready?')
response = process_answer()
if ('yes' in response):
say('Ok, let\'s start')
else:
say('No problem, maybe tomorrow')