2019.11.13 wf = wave.open(file_name, 'wb') # wf = wave.open("sine.wav", 'wb') wf.setnchannels(channel_num) wf.setframerate(framerate) wf.setsampwidth(sample_width) for i in sine_wave: data = struct.pack('<h', int(i)) wf.writeframesraw(data) wf.close