Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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, 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/

When i run my code in IDLE my code gets the error shown above. I'm on a iMac running macOS Sierra 10.12.2, if anyone has the answer that would be helpful. 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())
like image 693
Sergei Glimis Avatar asked Jan 23 '17 01:01

Sergei Glimis


People also ask

How do I install the Python speech recognition package?

First, make sure you have all the requirements listed in the “Requirements” section. The easiest way to install this is using pip install SpeechRecognition. Otherwise, download the source distribution from PyPI, and extract the archive. In the folder, run python setup.py install.

How do I import speech recognition in Anaconda?

try to install using Anaconda Navigator: go to Anaconda Navigator, Environments, (select your environment), click on the dropdown with 'Installed', and change to 'Uninstalled', search the package you need, check the box beside the name of the package and finally click on 'Apply'.

Could not find a version that satisfies the requirement speech recognition?

Solution 1: Just update pip You just need to update pip and your error will be resolve. Just follow this command. If you are windows users Then run this command. And then also upgrade setuptools after doing the above.


1 Answers

Install Speech Recognition using

pip install SpeechRecognition

like image 51
Senthuja Avatar answered Oct 22 '22 14:10

Senthuja