Package: audioread
Decode audio files using whichever backend is available. The library
currently supports:GstreamerviaPyGObject.Core Audioon Mac OS X viactypes. (PyObjC not required.)MADvia thepymadbindings.FFmpegorLibavvia its command-line interface.The standard librarywave,aifc, andsunaumodules (for
uncompressed audio formats).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 fromaudio_open. Each buffer is a bytes-like object (buffer,bytes, orbytearray) containing raw16-bit little-endian signed integer PCM
data. (Currently, these PCM format parameters are not configurable, but this
could be added to most of the backends.)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).Theaudio_openfunction transparently selects a backend that can read the
file. (Each backend is implemented in a module inside theaudioreadpackage.) If no backends succeed in opening the file, aDecodeErrorexception is raised. This exception is only used when the file type is
unsupported by the backends; if the file doesn’t exist, a standardIOErrorwill be raised.A second optional parameter toaudio_openspecifies which backends to try
(instead of trying them all, which is the default). You can use theavailable_backendsfunction to get a list backends that are usable on the
current system.Audioread supports Python 3 (3.8+).ExampleThe includeddecode.pyscript demonstrates using this package to
convert compressed audio files to WAV files.TroubleshootingANoBackendErrorexception means that the library could not find one of
the libraries or tools it needs to decode audio. This could mean, for example,
that you have a broken installation ofFFmpeg. To check, try typingffmpeg-versionin your shell. If that gives you an error, try installing
FFmpeg with your OS’s package manager (e.g., apt or yum) orusing Conda.Version History3.0.1Fix a possible deadlock when FFmpeg’s version output produces too much data.3.0.0Drop support for Python 2 and older versions of Python 3. The library now
requires Python 3.6+.
Increase default block size in FFmpegAudioFile to get slightly faster file reading.
Cache backends for faster lookup (thanks to @bmcfee).
Audio file classes now inherit from a common baseAudioFileclass.2.1.9Work correctly with GStreamer 1.18 and later (thanks to @ssssam).2.1.8Fix an unhandledOSErrorwhen FFmpeg is not installed.2.1.7Properly close some filehandles in the FFmpeg backend (thanks to
@RyanMarcus and @ssssam).
The maddec backend now always produces bytes objects, like the other
backends (thanks to @ssssam).
Resolve an audio data memory leak in the GStreamer backend (thanks again to
@ssssam).
You can now optionally specify which specific backendsaudio_openshould
try (thanks once again to @ssssam).
On Windows, avoid opening a console window to run FFmpeg (thanks to @flokX).2.1.6Fix a “no such process” crash in the FFmpeg backend on Windows Subsystem for
Linux (thanks to @llamasoft).
Avoid suppressing SIGINT in the GStreamer backend on older versions of
PyGObject (thanks to @lazka).2.1.5Properly clean up the file handle when a backend fails to decode a file.
Fix parsing of “N.M” channel counts in the FFmpeg backend (thanks to @piem).
Avoid a crash in the raw backend when a file uses an unsupported number of
bits per sample (namely, 24-bit samples in Python < 3.4).
Add a__version__value to the package.2.1.4Fix a bug in the FFmpeg backend where, after closing a file, the program’s
standard input stream would be “broken” and wouldn’t receive any input.2.1.3Avoid some warnings in the GStreamer backend when using modern versions of
GLib. We now require at least GLib 2.32.2.1.2Fix a file descriptor leak when opening and closing many files using
GStreamer.2.1.1Just fix ReST formatting in the README.2.1.0The FFmpeg backend can now also use Libav’savconvcommand.
Fix a warning by requiring GStreamer >= 1.0.
Fix some Python 3 crashes with the new GStreamer backend (thanks to
@xix-xeaon).2.0.0The GStreamer backend now uses GStreamer 1.x via the new
gobject-introspection API (and is compatible with Python 3).1.2.2When running FFmpeg on Windows, disable its crash dialog. Thanks to
jcsaaddupuy.1.2.1Fix an unhandled exception when opening non-raw audio files (thanks to
aostanin).
Fix Python 3 compatibility for the raw-file backend.1.2.0Add support for FFmpeg on Windows (thanks to Jean-Christophe Saad-Dupuy).1.1.0Add support for Sun/NeXTAu filesvia the standard-librarysunaumodule (thanks to Dan Ellis).1.0.3Use the rawread (standard-library) backend for .wav files.1.0.2Send SIGKILL, not SIGTERM, to ffmpeg processes to avoid occasional hangs.1.0.1When GStreamer fails to report a duration, raise an exception instead of
silently setting the duration field to None.1.0.0Catch GStreamer’s exception when necessary components, such asuridecodebin, are missing.
The GStreamer backend now accepts relative paths.
Fix a hang in GStreamer when the stream finishes before it begins (when
reading broken files).
Initial support for Python 3.0.8All decoding errors are now subclasses ofDecodeError.0.7Fix opening WAV and AIFF files via Unicode filenames.0.6Make 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.0.5Fix crash when FFmpeg fails to report a duration.
Fix a hang when FFmpeg fills up its stderr output buffer.
Add a timeout toffmpegtool execution (currently 10 seconds for each
4096-byte read); aReadTimeoutErrorexception is raised if the tool times
out.0.4Fix channel count detection for FFmpeg backend.0.3Fix a problem with the Gstreamer backend where audio files could be left open
even after theGstAudioFilewas “closed”.0.2Fix a hang in the GStreamer backend that occurs occasionally on some
platforms.0.1Initial release.Et Ceteraaudioreadis by Adrian Sampson. It is made available underthe MIT
license. An alternative to this module isdecoder.py.