Python speech recognition error converting mp3 file
<p>My first try on audio to text. </p>

<pre><code>import speech_recognition as sr
r = sr.Recognizer()
with sr.AudioFile("/path/to/.mp3") as source:
     audio = r.record(source)
</code></pre>

<p>When I execute the above code, the following error occurs,</p>

<pre><code>&lt;ipython-input-10-72e982ecb706&gt; in &lt;module&gt;()
----&gt; 1 with sr.AudioFile("/home/yogaraj/Documents/Python workouts/Python audio to text/show_me_the_meaning.mp3") as source:
      2     audio = sr.record(source)
      3 

/usr/lib/python2.7/site-packages/speech_recognition/__init__.pyc in __enter__(self)
    197                 aiff_file = io.BytesIO(aiff_data)
    198                 try:
--&gt; 199                     self.audio_reader = aifc.open(aiff_file, "rb")
    200                 except aifc.Error:
    201                     assert False, "Audio file could not be read as WAV, AIFF, or FLAC; check if file is corrupted"

/usr/lib64/python2.7/aifc.pyc in open(f, mode)
    950             mode = 'rb'
    951     if mode in ('r', 'rb'):
--&gt; 952         return Aifc_read(f)
    953     elif mode in ('w', 'wb'):
    954         return Aifc_write(f)

/usr/lib64/python2.7/aifc.pyc in __init__(self, f)
    345             f = __builtin__.open(f, 'rb')
    346         # else, assume it is an open file object already
--&gt; 347         self.initfp(f)
    348 
    349     #

/usr/lib64/python2.7/aifc.pyc in initfp(self, file)
    296         self._soundpos = 0
    297         self._file = file
--&gt; 298         chunk = Chunk(file)
    299         if chunk.getname() != 'FORM':
    300             raise Error, 'file does not start with FORM id'

/usr/lib64/python2.7/chunk.py in __init__(self, file, align, bigendian, inclheader)
     61         self.chunkname = file.read(4)
     62         if len(self.chunkname) &lt; 4:
---&gt; 63             raise EOFError
     64         try:
     65             self.chunksize = struct.unpack(strflag+'L', file.read(4))[0]
</code></pre>

<p>I don't know what I'm going wrong. Can someone say me what I'm wrong in the above code?</p>

<p><code>Speech recognition</code> supports WAV file format. 
Here is a sample WAV to text program using <code>speech_recognition</code>:</p>

<h3>Sample code (Python 3)</h3>

<pre><code>import speech_recognition as sr
r = sr.Recognizer()
with sr.AudioFile("woman1_wb.wav") as source:
    audio = r.record(source)

try:
    s = r.recognize_google(audio)
    print("Text: "+s)
except Exception as e:
    print("Exception: "+str(e))
</code></pre>

<h3>Output:</h3>

<pre><code>Text: to administer medicine to animals is frequency of very difficult matter and yet sometimes it's necessary to do so
</code></pre>

<p>Used WAV File URL: <a href="http://www-mobile.ecs.soton.ac.uk/hth97r/links/Database/woman1_wb.wav" rel="nofollow">http://www-mobile.ecs.soton.ac.uk/hth97r/links/Database/woman1_wb.wav</a></p>

python speech-recognition speech-to-text