Skip to main content
Donate to the Python Software Foundation or Purchase a PyCharm License to Benefit the PSF! Donate Now

A Python module for reading and writing WAV files using numpy arrays.

Project description

wavio is a Python module that defines two functions:

  • reads a WAV file and returns an object that holds the sampling rate, sample width (in bytes), and a numpy array containing the data.
  • wavio.write writes a numpy array to a WAV file, optionally using a specified sample width.

The module uses the wave module in Python’s standard library, so it has the same limitations as that module. In particular, it does not support compressed WAV files, and it does not handle floating point WAV files. (When floating point data is passed to wavio.write it is converted to integers before being written to the WAV file.) The functions can read and write 8-, 16-, 24- and 32-bit integer WAV files.

wavio has been tested with Python versions 2.7, 3.4, 3.5, 3.6 and 3.7.

wavio depends on numpy (

The package has a suite of unit tests, but it should still be considered prototype-quality software. There may be backwards-incompatible API changes between releases.


The following code (also found in the docstring of wavio.write) writes a three second 440 Hz sine wave to a 24-bit WAV file:

import numpy as np
import wavio

rate = 22050  # samples per second
T = 3         # sample duration (seconds)
f = 440.0     # sound frequency (Hz)
t = np.linspace(0, T, T*rate, endpoint=False)
x = np.sin(2*np.pi * f * t)
wavio.write("sine24.wav", x, rate, sampwidth=3)

Author:Warren Weckesser
License:BSD 2-clause (

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
wavio-0.0.4-py2.py3-none-any.whl (9.0 kB) Copy SHA256 hash SHA256 Wheel py2.py3
wavio-0.0.4.tar.gz (7.1 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page