问题
My code is
import SpeechRecognition as sr
# obtain audio from the microphone
r = sr.Recognizer()
with sr.Microphone() as source:
print("Say something!")
audio = r.listen(source)
# recognize speech using Microsoft Bing Voice Recognition
BING_KEY = "Somevalue" # Microsoft Bing Voice Recognition API keys 32-character lowercase hexadecimal strings
try:
print("Microsoft Bing Voice Recognition thinks you said " + r.recognize_bing(audio, key=BING_KEY))
except sr.UnknownValueError:
print("Microsoft Bing Voice Recognition could not understand audio")
except sr.RequestError as e:
print("Could not request results from Microsoft Bing Voice Recognition service; {0}".format(e))
When I run it, I got
ImportError: No module named SpeechRecognition
I think I did install this module:
>pip list
SpeechRecognition (3.6.5)
the code given by the git repository is like this
import speech_recognition as sr
but it isn't working either
回答1:
I think the problem is
import SpeechRecognition as sr
where you should use
import speech_recognition as sr
来源:https://stackoverflow.com/questions/43806542/importerror-no-module-named-speechrecognition