title: UnknownValueError result from recognize_google
body: <p>I cannot understand why I am getting this error when doing speech recognition, it works for a while, but then this error pops up.</p>
  
  <pre><code>Traceback (most recent call last):
    File "C:/Python27/new4.py", line 46, in &lt;module&gt;
      mainfunction(source)
    File "C:/Python27/new4.py", line 27, in mainfunction
      user = r.recognize_google(audio)
    File "C:\Python27\lib\site-packages\speech_recognition\__init__.py", line 780, in recognize_google
      if not isinstance(actual_result, dict) or len(actual_result.get("alternative", [])) == 0: raise UnknownValueError()
  UnknownValueError
  </code></pre>
  
  <p>And this is the code that I am running:</p>
  
  <pre><code>def mainfunction(source):
      audio = r.listen(source)
      user = r.recognize_google(audio)
  
      # recognize speech using Google Speech Recognition
      try:
          # for testing purposes, we're just using the default API key
          # to use another API key, use `r.recognize_google(audio, key="GOOGLE_SPEECH_RECOGNITION_API_KEY")`
          # instead of `r.recognize_google(audio)`
          print("Google Speech Recognition thinks you said " + user)
      except sr.UnknownValueError:
          print("Google Speech Recognition could not understand audio")
      except sr.RequestError as e:
          print("Could not request results from Google Speech Recognition service; {0}".format(e))
  
  
  
  if __name__ == "__main__":
      r = sr.Recognizer()
      with sr.Microphone() as source:
          while 1:
              mainfunction(source)
  </code></pre>
  
  <p>What am I doing wrong here?</p>