尝试这种方式:
r = sr.Recognizer()m = sr.Microphone(device_index=2)def loop(): with m as source: print("say something") audio = r.listen(source) try: print("you said "+r.recognize_google(audio)) except sr.UnknownValueError: print("Could not understand") except sr.RequestError as e: print("errpr: {0}".format(e))loop()不要创建多个
Microphone()实例。



