Decode audio files using whichever backend is available. The library currently supports:
- Gstreamer via gst-python.
- Core Audio on Mac OS X via ctypes. (PyObjC not required.)
- MAD via the pymad bindings.
- FFmpeg via its command-line interface.
- The standard library wave and aifc modules (for WAV and AIFF files).
Use the library like so:
with audioread.audio_open(filename) as f: print f.channels, f.samplerate, f.duration for buf in f: do_something(buf)
Buffers in the file can be accessed by iterating over the object returned from
audio_open. Each buffer is a
str object containing raw
16-bit little-endian signed integer PCM data. (Currently, these PCM format
parameters are not configurable, but this could be added to most of the
Additional values are available as fields on the audio file object:
channelsis the number of audio channels (an integer).
samplerateis given in Hz (an integer).
durationis the length of the audio in seconds (a float).
audio_open function transparently selects a backend that can read the
file. (Each backend is implemented in a module inside the
package.) If no backends succeed in opening the file, a
exception is raised. This exception is only used when the file type is
unsupported by the backends; if the file doesn't exist, a standard
will be raised.
Possible additional backends:
- Other command-line tools?
decode.py script demonstrates using this package to
convert compressed audio files to WAV files.
- Fix opening WAV and AIFF files via Unicode filenames.
- Make FFmpeg timeout more robust. Dump FFmpeg output on timeout. Fix a nondeterministic hang in the Gstreamer backend. Fix a file descriptor leak in the MAD backend.
- Fix crash when FFmpeg fails to report a duration.
Fix a hang when FFmpeg fills up its stderr output buffer.
Add a timeout to
ffmpegtool execution (currently 10 seconds for each 4096-byte read); a
ReadTimeoutErrorexception is raised if the tool times out.
- Fix channel count detection for FFmpeg backend.
- Fix a problem with the Gstreamer backend where audio files could be left open
even after the
- Fix a hang in the GStreamer backend that occurs occasionally on some platforms.
- Initial release.