audio = pyaudio.PyAudio() stream = audio.open(format=FORMAT, channels=CHANNELS, rate=RATE, output=True, frames_per_buffer=CHUNK) try: while True: data = s.recv(CHUNK) stream.write(data) except KeyboardInterrupt: pass