title: Why is speech recognition using OOP not working in this case?
body: <p>I am trying to use speech recognition with OOP. I try to convert the procedural code from <a href="https://github.com/bradtraversy/alexis_speech_assistant" rel="nofollow noreferrer">this github</a>.</p>
  <pre><code>import speech_recognition as sr #recognise speech
  import time
  
  
  class SpeechRecognition():
      def __init__(self):
          self.r = sr.Recognizer() #initialize recognizer that is responsible for recognizing the speech
              
      # listen for audio and convert it to text:
      def record_audio(self, ask=False):
          with sr.Microphone() as source: # microphone as source
              if ask: 
                  print(ask)
              audio = self.r.listen(source) # listen for the audio via source
              voice_data = ''
              try:
                  voice_data = self.r.recognize_google(audio, language='sv-SE') # convert audio to text
              except sr.UnknownValueError: # error: recognizer does not understand
                  print('Hörde inte det') 
              except sr.RequestError: # error: recognizer is not connected
                  print('Ledsen, tjänsten är nere')
              print(f&quot;&gt;&gt; {voice_data.lower()}&quot;) # print what user said
              return voice_data.lower()
  
      def init_speech_recognizer(self):
          time.sleep(1)
          print('Hur kan jag hjälpa dig?')
  
          while 1: #this will let it keep listen 
              voice_data = self.record_audio(&quot;Recording&quot;) # get the voice input
              print(&quot;Done&quot;)
              
  speechObj = SpeechRecognition()
  speechObj.init_speech_recognizer()
  </code></pre>
  <p>The output is:</p>
  <pre><code>Hur kan jag hjälpa dig?
  Recording
  </code></pre>
  <p>But whatever I say nothing gets printed. Why is this?</p>