简体   繁体   English

ImportError:python IDLE 中没有名为“speech_recognition”的模块

[英]ImportError: No module named 'speech_recognition' in python IDLE

I'm trying to use the speech recognition module with python 3.5.1 to make my jarvis AI voice activated, I have looked through stack overflow and found some questions similar to mine but they did not have the answer that i needed.我正在尝试使用带有 python 3.5.1 的语音识别模块来激活我的 jarvis AI 语音,我查看了堆栈溢出并发现了一些类似于我的问题,但他们没有我需要的答案。 i need an answer individualized for this, I have downloaded all the necessary packages and still no luck: i get this error:我需要一个个性化的答案,我已经下载了所有必要的包,但仍然没有运气:我得到这个错误:

ImportError: No module named 'speech_recognition'

If I run:如果我跑:

python -m speech_recognition

In terminal it runs only in terminal, i can talk to it and it isn't nearly spot on but it hears me and and can interpret some words.在终端中,它仅在终端中运行,我可以与它交谈并且它几乎没有出现,但它能听到我的声音并且可以解释一些单词。 I have downloaded all the packages in terminal from this sites instructions.我已经从该站点说明下载了终端中的所有软件包。

https://pypi.python.org/pypi/SpeechRecognition/ https://pypi.python.org/pypi/SpeechRecognition/

When i run my code in IDLE my code gets the error shown above.当我在 IDLE 中运行我的代码时,我的代码得到上面显示的错误。 I'm on a iMac running macOS Sierra 10.12.2, if anyone has the answer that would be helpful.我在运行 macOS Sierra 10.12.2 的 iMac 上,如果有人有帮助的答案。 Thank you!谢谢!

heres my code:这是我的代码:

import speech_recognition
import pyttsx

speech_engine = pyttsx.init('sapi5') # see         
speech_engine.setProperty('rate', 150)

def speak(text):
   speech_engine.say(text)
   speech_engine.runAndWait()

recognizer = speech_recognition.Recognizer()

def listen():
    with speech_recognition.Microphone() as source:
        recognizer.adjust_for_ambient_noise(source)
        audio = recognizer.listen(source)

    try:
        return recognizer.recognize_sphinx(audio) 
        # or: return recognizer.recognize_google(audio)
    except speech_recognition.UnknownValueError:
        print("Could not understand audio")
    except speech_recognition.RequestError as e:
        print("Recog Error; {0}".format(e))

    return ""



speak("Say something!")
speak("I heard you say " + listen())

Install Speech Recognition using使用安装语音识别

pip install SpeechRecognition点安装语音识别

I upgraded my python to 3.7 in mac, but then I was facing similar issue.我在mac中将我的python升级到3.7,但后来我遇到了类似的问题。

pip3 install SpeechRecognition pip3 安装语音识别

this worked for me这对我有用

Try this in windows command prompt for python 3.7 32 bit在 python 3.7 32 位的 windows 命令提示符下试试这个

python -m pip install -U pip

pip install winspeech

pip install SpeechRecognition

OS X Sierra comes with Python 2.7.10 . OS X Sierra 附带 Python 2.7.10 Since you are using Python 3.5.1, you have presumably installed it yourself and you now have two versions of Python.由于您使用的是 Python 3.5.1,因此您可能自己安装了它,并且您现在有两个版本的 Python。 IDLE is clearly running with the Python version for which you did not install the speech_recognition module. IDLE 显然正在运行您安装speech_recognition模块的 Python 版本。

What to do depends on your set-up.做什么取决于您的设置。 I'd start by running idle3 from the command line, instead of idle .我将从命令行运行idle3开始,而不是idle If your module is installed for Python 3, that's all you need.如果您的模块是为 Python 3 安装的,那么这就是您所需要的。 If this doesn't work, check everything with an eye to the different versions and straighten them out the way you want them.如果这不起作用,请检查所有内容并注意不同的版本,并按照您想要的方式整理它们。

在此处输入图像描述

Try This it will work!试试这个它会工作! I had faced the same problem.我也遇到过同样的问题。

 pip install SpeechRecognition

In may case the error was - No module named speechRecognition incase that's the case with you try editing the import code and use import speech_recognition as sr It worked for me.在可能的情况下,错误是 - 没有名为 speechRecognition 的模块,因为您尝试编辑导入代码并使用 import speech_recognition as sr 它对我有用。 Sometimes pip gives these issues有时 pip 会出现这些问题

First, make sure you have all the requirements listed in the “Requirements”:首先,确保您具有“要求”中列出的所有要求:

Install Xcode in Unix Development mode.在 Unix 开发模式下安装 Xcode。 Install Xcode - Command Line tools (Type 'Xcode-select —install' in the terminal )安装 Xcode - 命令行工具(在终端中输入“Xcode-select —install”)

** **

Install Port or Brew (port  [or] Brew  )
sudo brew install portaudio [or] sudo port install portaudio (for loading mic drivers)
sudo pip install pyaudio [or] sudo easy_install install pyaudio (Mic Sources)
sudo pip install SpeechRecognition [or] sudo easy_install install SpeechRecognition
sudo port install FLAC.

** **

I solved this problem.我解决了这个问题。 I just installed SpeechRecognition in project properties.我刚刚在项目属性中安装了 SpeechRecognition。 Settings -> Project:(nameofyourproject)-> Python: Interpreter.设置->项目:(您的项目名称)-> Python:解释器。 Click on plus and find SpeechRecognition, install it.点击加号,找到 SpeechRecognition,安装。

in pychaem tap the hint(alt+enter) and tap install packages while select the package or tap F2 to take to it.在 pychaem 中点击提示(alt+enter)并点击安装包,同时选择包或点击 F2 接受它。

for python3 try running the command to install the SpeechRecognition module: pip3 install SpeechRecognition对于 python3,请尝试运行以下命令来安装 SpeechRecognition 模块:pip3 install SpeechRecognition

What worked for me was, I installed jupyter notebooks again and on anaconda prompt and then I executed pip install SpeechRecognition对我有用的是,我再次安装了 jupyter 笔记本并在 anaconda 提示符下,然后我执行了pip install SpeechRecognition

followed by其次是

pip install PyAudio-0.2.11-cp39-cp39-win_amd64.whl pip install PyAudio-0.2.11-cp39-cp39-win_amd64.whl

again.再次。

user must be root so use用户必须是 root 所以使用

sudo pip install --upgrade pip

It will work.它会起作用的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM