I'm trying to create a little program which should print something if in what I say (not only one word but a phrase) (using speech_recognizer) there is a word which is contained in a list of words (word_list). Also the output should change if I say one word or another so I need to check exactly which word is it.
import speech_recognition as sr
word_list = ['Giotto', 'Raffaello', 'Michelangelo']
recognizer_instance = sr.Recognizer()
with sr.Microphone() as source:
recognizer_instance.adjust_for_ambient_noise(source)
print("I'm listening...")
audio = recognizer_instance.listen(source)
print('Printing what I heard...')
try:
text = recognizer_instance.recognize_google(audio, language='it-IT')
print(text)
except Exception as e:
print(e)
this is my code at the moment and I can't figure out how to check if one of the words contained in the text variable is in my word_list