Python wave

From wikinotes

Documentation

official docs
intro tutorial https://www.tutorialspoint.com/read-and-write-wav-files-using-python-wave
detailed tutorial https://nbviewer.jupyter.org/github/mgeier/python-audio/blob/master/audio-files/audio-files-with-wave.ipynb

Usage

import wave

# create new wave file
wav_file = wave.open('/var/tmp/audio.wav', 'wb')
wav_file.setnchannels(2)        # 2 for stereo
wav_file.setframerate(44100.0)  # 44100 Hz
wav_file.setsampwidth(2)        # ??
wav_file.close()