def main(): # obtain audio from the microphone r = sr.Recognizer() with sr.Microphone() as source: print("Say something!") r.listen_in_background(source, recognize) # ----------------------------