speech_recognition module stuck in "say something" - python
<p>I am trying a python script for speech recognition, i have installed the required pyaudio and SpeechRecognition modules in my enivronment.</p>

<p>The program was running fine till yesterday, but now it is stuck in "say something". Below is my code.</p>

<pre><code>import speech_recognition as sr
print "say something1"
r = sr.Recognizer()
print "say something2"
with sr.Microphone() as source:                # use the default microphone as the audio source
    print "say something3"
    audio = r.listen(source,timeout=3)                   # listen for the first phrase and extract it into audio data

print "say something"
try:
    print("You said " + r.recognize(audio))    # recognize speech using Google Speech Recognition
except LookupError:                            # speech is unintelligible
    print("Could not understand audio")
</code></pre>

<p>Console o/p :-</p>

<pre><code>say something1
say something2
ALSA lib pcm_dsnoop.c:606:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dmix.c:1029:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_dmix.c:1029:(snd_pcm_dmix_open) unable to open slave
say something3
</code></pre>

<p>Not duplicate of/ Have refferd to :- <a href="http://stackoverflow.com/questions/32005310/speech-recognition-python-code-not-working">speech recognition python code not working</a></p>

<p>I have had the same problem with me, i ended up installing jack2d and pulseaudio and what not.</p>

<p>That was the problem, I then uninstalled the jack2d by running  </p>

<pre><code>sudo apt-get remove --auto-remove jack
</code></pre>

<p>Then restarted the system, and then ran </p>

<pre><code>jack_control  stop
</code></pre>

<p>Then this will give the voice input to pulse-aduio.</p>

<p>When you run the program, the console should print</p>

<pre><code>ALSA lib pcm_dsnoop.c:606:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
</code></pre>

<p>The last lines state that Jack has stopped and the voice input is being redirected to pulse.</p>

<p>what actually happening here is, the audio resoruce(mic) is being channeled only to either jack or pulse, so I uninstalled jack</p>

<p>Now my program works just fine</p>

python python-2.7 speech-recognition