我的代码是
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))
当我运行它时,我得到了:
ImportError: No module named SpeechRecognition
我认为我已经安装了这个模块:
>pip list
SpeechRecognition (3.6.5)
Git仓库提供的代码如下:
import speech_recognition as sr
但是它也没有起作用。
speech_recognition
。我会赌 @Daniel 说的是对的。 - MariusSiuramwhich python
,which pip
。并尝试使用/usr/local/lib/python2.7/python -m speech_recognition
启动speech_recogntion? - Daniel/usr/local/lib/python2.7/python
,/usr/local/bin/python2.7/python
,.. :) - Daniel