Search code examples
pythonspeech-recognitionpyaudio

Python SpeechRecognition running but not hearing through the mic


So I'm trying to use python SpeechRecognition 1.1.3 but it is not recognizing me through my mic. I've installed pyAudio and everything seems to be working smoothly when I run the example code provided by SpeechRecognition:

# NOTE: this requires PyAudio because it uses the Microphone class
import speech_recognition as sr
r = sr.Recognizer()
with sr.Microphone() as source:                # use the default microphone as the audio source
    audio = r.listen(source)                   # listen for the first phrase and extract it into audio data

try:
    print("You said " + r.recognize(audio))    # recognize speech using Google Speech Recognition
except LookupError:                            # speech is unintelligible
    print("Could not understand audio")

It just sits waiting to hear an input from the mic. The mic works and SpeechRecognition is able to recognize that it is the default mic because when I unplug it the code barfs. Any suggestions?

I am running python 2.7.6 and my OS is Windows 7. Additionally, I've got all of this on an E: drive just to make life a little more complicated... :/


Solution

  • According to the script, Pyaudio hasn't been installed. Don't worry, this is a common syntax error an application could receive. What I recommend you doing is you have to reinstall your Python program to the version that will be able to run under the Pyaudio 1.1.3. You haven't specified what version of Python you're using and what OS is your computer operating under (i.e. Windows Vista, 7 or 8). Supposing that you might be using either Windows 8 or 7, you have to type in easy_install in the windows cmd. Yet, if that won't work, install this Python script: http://peak.telecommunity.com/dist/ez_setup.py Then reattempt the process by typing in easy_install from C:\<Your python directory>\Scripts\. Hope this helped.