Speech recognition not working in ubuntu
<p>I am starting a work which needs to convert audio into text. I am using the speechrecognition library of python. I saw a tutorial on github on how to use it. The program is not bale to recognise my voice through microphone.</p>

<p>I am using python 2.7 on ubuntu 16.04.</p>

<p>Code:</p>

<pre><code>import speech_recognition as sr

# obtain audio from the microphone
r = sr.Recognizer()
with sr.Microphone() as source:
    print("Say something!")
    r.adjust_for_ambient_noise(source)
    audio = r.listen(source)

# recognize speech using Sphinx
try:
    print("Sphinx thinks you said " + r.recognize_sphinx(audio))
except sr.UnknownValueError:
    print("Sphinx could not understand audio")
except sr.RequestError as e:
    print("Sphinx error; {0}".format(e))
</code></pre>

<p><a href="https://github.com/Uberi/speech_recognition/blob/master/examples/microphone_recognition.py" rel="nofollow">github code link</a></p>

<p>Output on terminal:</p>

<pre><code>shivam@shivam-HP-Pavilion-15-Notebook-PC:~/Python/audio$ python temp.py
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_dmix.c:1029:(snd_pcm_dmix_open) unable to open slave
Say something!
</code></pre>

<p>After, "Say something!", it keeps on blinking but my voice is not recognised.</p>

<p><a href="http://i.stack.imgur.com/kBx15.png" rel="nofollow"><img src="http://i.stack.imgur.com/kBx15.png" alt="mic settings"></a>
<a href="http://i.stack.imgur.com/fxN98.png" rel="nofollow"><img src="http://i.stack.imgur.com/fxN98.png" alt=""></a></p>

<p>I couldn't get <code>PocketSphinx</code> module installed , running into issues.
But if I switch <code>recognize_sphinx</code> with <code>recognize_google</code>, its working for me.</p>

<p>Here is your modified code.</p>

<pre><code>import speech_recognition as sr

# obtain audio from the microphone
r = sr.Recognizer()
with sr.Microphone() as source:
    print("Say something!")
    r.adjust_for_ambient_noise(source)
    audio = r.listen(source)

# recognize speech using Sphinx
try:
    #print("Sphinx thinks you said " + r.recognize_sphinx(audio))
    print("Sphinx thinks you said " + r.recognize_google(audio))
except sr.UnknownValueError:
    print("Sphinx could not understand audio")
except sr.RequestError as e:
    print("Sphinx error; {0}".format(e))
</code></pre>

<p>Output</p>

<pre><code>Python 2.7.9 (default, Dec 10 2014, 12:24:55) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
&gt;&gt;&gt; ================================ RESTART ================================
&gt;&gt;&gt; 
Say something!
Sphinx thinks you said hello
&gt;&gt;&gt; 
</code></pre>

<p>Hope this is useful.</p>

python speech-recognition speech-to-text