<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def record(self):
 """ Record PyAudio stream into StringIO output This coroutine keeps stream open; the stream is closed in stop() """


        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