Python Speech Recognition: 'module' object has no attribute 'microphone'
问题 Running the following code on a macbook air 64 bit, testing the code on python 2.7 and python 3.4 import speech_recognition as sr r = sr.Recognizer() with sr.microphone() as source: audio = r.listen(source) try: print("You said " + r.recognize(audio)) except LookupError: print("Could not understand audio") When i try python 2.7, I keep getting the error of : Traceback (most recent call last): File "star.py", line 3, in <module> with sr.microphone() as source: AttributeError: 'module' object