title: Unbound local variable referenced before assignment
body: <p>I have some code that i followed using a youtube tutorial and it runs fine, a friend followed the same code and it is identical to mine. both using python ide VScode, tested on python 3.10 and 3.9. The indents are exactly the same in fact everything is the same as mine.</p>
  <p>The code works perfectly on my computer but not my friends as she gets the 'unbound local variable referenced before assignment error' which i do not get.</p>
  <p>Can anyone recommend why this might be happening?</p>
  <pre><code>import speech_recognition as sr
  import pyttsx3
  import pywhatkit
  import datetime
  import wikipedia
  import pyjokes
  
  
  listener = sr.Recognizer()
  engine = pyttsx3.init()
  voices = engine.getProperty('voices')
  engine.setProperty('voice', voices[1].id)
  
  def talk(text):
      engine.say(text)
      engine.runAndWait()
  
  def take_command():
      try:
          with sr.Microphone() as source:
              print('Listening...')
              voice = listener.listen(source)
              command = listener.recognize_google(voice)
              command = command.lower()
              if 'alexa' in command:
                  command = command.replace('alexa', '')
                  print(command)
      except:
          pass
      return command
  
  def run_alexa():
      command = take_command()
      print(command)
      if 'play' in command:
          song = command.replace('play', '')
          talk('playing ' + song)
          print(song)
          pywhatkit.playonyt(song)
      elif 'time' in command:
          time = datetime.datetime.now().strftime('%H:%M')
          print(time)
          talk('Current time is ' + time)
      elif 'who is' in command:
          person = command.replace('who is', '')
          info = wikipedia.summary(person, 1)
          print(info)
          talk(info)
      elif 'date' in command:
          talk('sorry, I have a headache')
      elif 'are you single' in command:
          talk('I am in a relationship with Siri')
      elif 'joke' in command:
          talk(pyjokes.get_joke())
      else:
          talk('Please say that again.')
  
  while True:
      run_alexa()
  </code></pre>