title: Why am I getting Speech Recognition errors even though I installed it correctly?
body: <p>Okay so here's the error message I get:
  Error 263 for command:
  close voice.mp3
  The specified device is not open or is not recognized by MCI.
  Failed to close the file: voice.mp3</p>
  <p>The code:</p>
  <pre class="lang-py prettyprint-override"><code>import time
  import playsound
  import speech_recognition
  import speech_recognition as sr
  from gtts import gTTS
  
  def speak(text):
      tts = gTTS(text=text, lang=&quot;en&quot;)
      filename = &quot;voice.mp3&quot;
      tts.save(filename)
      playsound.playsound(filename)
  
  def get_audio():
      r = sr.Recognizer()
      with sr.Microphone() as source:
          audio = r.listen(source)
          said = &quot;&quot;
  
          try:
              said = r.recognize_google(audio)
              print(said)
          except Exception as e:
              print(&quot;Exception: &quot; + str(e))
      return said
  
  text = get_audio()
  
  if &quot;sexy&quot; in text:
      speak(&quot;You're sexy too daddy.&quot;)
  Please don't ask...
  </code></pre>
  <p>I'm using PyCharm  if it helps somehow...
  Also, from time to time I get this error:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;C:\Users\mat30\PycharmProjects\Monday\main.py&quot;, line 16, in get_audio
      audio = r.listen(source)
    File &quot;C:\Users\mat30\AppData\Local\Programs\Python\Python39\lib\site-packages\speech_recognition\__init__.py&quot;, line 652, in listen
      buffer = source.stream.read(source.CHUNK)
    File &quot;C:\Users\mat30\AppData\Local\Programs\Python\Python39\lib\site-packages\speech_recognition\__init__.py&quot;, line 161, in read
      return self.pyaudio_stream.read(size, exception_on_overflow=False)
    File &quot;C:\Users\mat30\AppData\Local\Programs\Python\Python39\lib\site-packages\pyaudio.py&quot;, line 608, in read
      return pa.read_stream(self._stream, num_frames, exception_on_overflow)
  OSError: [Errno -9999] Unanticipated host error
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File &quot;C:\Users\mat30\PycharmProjects\Monday\main.py&quot;, line 26, in &lt;module&gt;
      text = get_audio()
    File &quot;C:\Users\mat30\PycharmProjects\Monday\main.py&quot;, line 23, in get_audio
      print(&quot;Exception: &quot; + str(e))
    File &quot;C:\Users\mat30\AppData\Local\Programs\Python\Python39\lib\site-packages\speech_recognition\__init__.py&quot;, line 151, in __exit__
      self.stream.close()
    File &quot;C:\Users\mat30\AppData\Local\Programs\Python\Python39\lib\site-packages\speech_recognition\__init__.py&quot;, line 166, in close
      if not self.pyaudio_stream.is_stopped():
    File &quot;C:\Users\mat30\AppData\Local\Programs\Python\Python39\lib\site-packages\pyaudio.py&quot;, line 543, in is_stopped
      return pa.is_stream_stopped(self._stream)
  OSError: [Errno -9988] Stream closed
  </code></pre>