title: Python SpeechRecognition AttributeError: __exit__ with sr.Microphone()
body: <p>I am trying to use SpeechRecognition 3.5 to turn Speech into Text. I am using <strong>Python 2.7.13</strong>. I looked up some examples using this module, and all the examples I found included:</p>
  
  <pre><code>r = sr.Recognizer()
  with sr.Microphone() as source:
      audio = r.listen(source)
  </code></pre>
  
  <p>But when I run this it always spits out this error</p>
  
  <pre><code>AttributeError: __exit__
  </code></pre>
  
  <p>Im not sure how to fix this, as </p>
  
  <pre><code>with sr.Microphone() as source:
  </code></pre>
  
  <p>Is looking for an <strong>exit</strong> method but cannot find one. So I tried taking out the with keyword, so it looked like this:</p>
  
  <pre><code>source = sr.Microphone()
  audio = r.listen(source)
  </code></pre>
  
  <p>But it then spits an AssertionError at me.</p>
  
  <pre><code>AssertionError: Audio source must be entered before listening, see documentation for ``AudioSource``; are you using ``source`` outside of a ``with`` statement?
  </code></pre>
  
  <p>Im not sure what to do from here. Could anyone explain to me why this doesn't work?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>sr.Microphone -> sr.Microphone()</p>
  
  <p><strong>Edit 2:</strong></p>
  
  <p>The error was caused due to me not importing PyAudio (which is required) and I did not realize. Now I can't stop it recording the microphone.</p>