title: Python Speech Recognition does not recognize my voice
body: <p>Always Traceback. I know for sure my mic is working because I am using it to search something in search google via voice.</p>
  <p>here is my code.</p>
  <pre><code>import speech_recognition as sr
  
  rec=sr.Recognizer()
  
  with sr.Microphone() as source:
      rec.adjust_for_ambient_noise(source,duration=5)
     
      print(&quot;Speak Now: &quot;)
      audio= rec.listen(source)
      try:
          text = rec.recognize_google(audio)
          print(text)
      except:
          print(&quot;sorry, could not hear your voice&quot;)
  </code></pre>
  <p>whenever I run, it always stuck on &quot;please speak now&quot; display and then display this traceback</p>
  <pre><code>speak now:
  sorry, could not hear your voice
  Traceback (most recent call last):
    File &quot;C:\Program Files (x86)\Python\lib\runpy.py&quot;, line 194, in _run_module_as_main
      return _run_code(code, main_globals, None,
    File &quot;C:\Program Files (x86)\Python\lib\runpy.py&quot;, line 87, in _run_code
      exec(code, run_globals)
    File &quot;c:\program files (x86)\microsoft visual studio\2019\community\common7\ide\extensions\microsoft\python\core\debugpy\__main__.py&quot;, line 45, in &lt;module&gt;
      cli.main()
    File &quot;c:\program files (x86)\microsoft visual studio\2019\community\common7\ide\extensions\microsoft\python\core\debugpy/..\debugpy\server\cli.py&quot;, line 430, in main
      run()
    File &quot;c:\program files (x86)\microsoft visual studio\2019\community\common7\ide\extensions\microsoft\python\core\debugpy/..\debugpy\server\cli.py&quot;, line 267, in run_file
      runpy.run_path(options.target, run_name=compat.force_str(&quot;__main__&quot;))
    File &quot;C:\Program Files (x86)\Python\lib\runpy.py&quot;, line 265, in run_path
      return _run_module_code(code, init_globals, run_name,
    File &quot;C:\Program Files (x86)\Python\lib\runpy.py&quot;, line 97, in _run_module_code
      _run_code(code, mod_globals, init_globals,
    File &quot;C:\Program Files (x86)\Python\lib\runpy.py&quot;, line 87, in _run_code
      exec(code, run_globals)
    File &quot;C:\Users\MARTIN\Documents\Learning Python\sr\sr\sr.py&quot;, line 14, in &lt;module&gt;
      print(&quot;sorry, could not hear your voice&quot;)
    File &quot;_pydevd_bundle/pydevd_cython.pyx&quot;, line 1260, in _pydevd_bundle.pydevd_cython.SafeCallWrapper.__call__
    File &quot;_pydevd_bundle/pydevd_cython.pyx&quot;, line 344, in _pydevd_bundle.pydevd_cython.PyDBFrame.trace_exception
    File &quot;_pydevd_bundle/pydevd_cython.pyx&quot;, line 231, in _pydevd_bundle.pydevd_cython.is_unhandled_exception
    File &quot;c:\program files (x86)\microsoft visual studio\2019\community\common7\ide\extensions\microsoft\python\core\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_collect_bytecode_info.py&quot;, line 167, in collect_try_except_info
      def collect_try_except_info(co, use_func_first_line=False):
  IndexError: list index out of range
  </code></pre>
  <p>Please someone help me fix this. Thanks in advance, I am beginner in speech recognition of python.</p>