Multimedia and Browser Modules
wave
Reads and writes uncompressed PCM WAV audio data, including channel count, sample width, frame rate and frame bytes. A frame includes one sample per channel. This module does not play audio or decode arbitrary compressed formats. The example uses a small in-memory mono PCM file.
Formal Syntax & Structure
python syntaxpython
import waveReturn Value
module
Module namespace available through import; import is a statement, not a value-returning expression.
Working Example
Example Snippetpython
import wavefrom io import BytesIObuffer = BytesIO()with wave.open(buffer, "wb") as writer: writer.setparams((1, 2, 8000, 0, "NONE", "not compressed")) writer.writeframes(b"\x00\x00" * 4)buffer.seek(0)with wave.open(buffer, "rb") as reader: print(reader.getnframes(), reader.getframerate())