title: Hi, I have a problem with python speech recognition. Once my program runs for a few minutes it stops responding to what im saying
body: <p>The purpose of this program is to connect to my spotify and skip the song/previous/pause when prompted. After a few minutes of saying commands (testing), it stops responding no exceptions are given nothing. It doesn't crash, just stops listening. Does it reach max capacity? Occupy too much RAM, fill the stack?</p>
  <p>I have tried to change my loop, but I don't see anything wrong with it.</p>
  <pre><code>import os
  import spotipy
  import spotipy.util as util
  from json.decoder import JSONDecodeError
  
  username = 'xxxxx'
  client_id = 'xxxxxxxxxxxxxxxxxxxxxx'
  client_secret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
  redirect_uri = 'http://google.com/'
  scope = 'user-modify-playback-state'
  
  
  try:
      token = util.prompt_for_user_token(username, scope, client_id, client_secret, redirect_uri)
  except (AttributeError, JSONDecodeError):
      os.remove(f&quot;.cache-{username}&quot;)
      token = util.prompt_for_user_token(username, scope, client_id, client_secret, redirect_uri)
  
  
  
  sp = spotipy.Spotify(auth=token)
  
  
  
  import speech_recognition as sr
  
  while True:
      r = sr.Recognizer()
      with sr.Microphone() as source:
          print(&quot;Speak: &quot;)
          audio = r.listen(source)
  
          try:
              text = r.recognize_google(audio)
              print(text)
              if text == &quot;skip song&quot;:
                  
                  sp.next_track()
  
  
              elif text == &quot;previous song&quot;:
                                  
                  sp.previous_track()
  
  
              elif text == &quot;pause&quot;:
                  sp.pause_playback()
      
          except:
              print(&quot;Speak Again&quot;)
  </code></pre>