code: def record(self):
          
  
          while True:
              frames = []
              self.stream.start_stream()
              for i in range(self.num_frames):
                  data = self.stream.read(self.config.FRAMES_PER_BUFFER)
                  frames.append(data)
              self.output.seek(0)
              w = wave.open(self.output, 'wb')
              w.setnchannels(self.config.CHANNELS)
              w.setsampwidth(self.audio.get_sample_size(self.config.FORMAT))
              w.setframerate(self.config.RATE)
              w.writeframes(b''.join(frames))
              w.close()
              yield
docs: Record PyAudio stream into StringIO output
  
          This coroutine keeps stream open; the stream is closed in stop()