ImportError: No module named SpeechRecognition

冷暖自知 提交于 2021-02-20 18:56:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!