audioread

cross-library (GStreamer + Core Audio + MAD + FFmpeg) audio decoding for Python

https://github.com/beetbox/audioread

Science Score: 23.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    2 of 24 committers (8.3%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.9%) to scientific vocabulary

Keywords

audio python

Keywords from Contributors

dsp librosa music tensors optimizing-compiler deep-neural-networks distributed transpiler
Last synced: 6 months ago · JSON representation

Repository

cross-library (GStreamer + Core Audio + MAD + FFmpeg) audio decoding for Python

Basic Info
  • Host: GitHub
  • Owner: beetbox
  • License: mit
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 360 KB
Statistics
  • Stars: 511
  • Watchers: 25
  • Forks: 107
  • Open Issues: 39
  • Releases: 0
Topics
audio python
Created over 14 years ago · Last pushed almost 2 years ago
Metadata Files
Readme License

README.rst

audioread
=========

Decode audio files using whichever backend is available. The library
currently supports:

- `Gstreamer`_ via `PyGObject`_.
- `Core Audio`_ on Mac OS X via `ctypes`_. (PyObjC not required.)
- `MAD`_ via the `pymad`_ bindings.
- `FFmpeg`_ or `Libav`_ via its command-line interface.
- The standard library `wave`_, `aifc`_, and `sunau`_ modules (for
  uncompressed audio formats).

.. _Gstreamer: http://gstreamer.freedesktop.org/
.. _gst-python: http://gstreamer.freedesktop.org/modules/gst-python.html
.. _Core Audio: http://developer.apple.com/technologies/mac/audio-and-video.html
.. _ctypes: http://docs.python.org/library/ctypes.html
.. _MAD: http://www.underbit.com/products/mad/
.. _pymad: http://spacepants.org/src/pymad/
.. _FFmpeg: http://ffmpeg.org/
.. _Libav: https://www.libav.org/
.. _wave: http://docs.python.org/library/wave.html
.. _aifc: http://docs.python.org/library/aifc.html
.. _sunau: http://docs.python.org/library/sunau.html
.. _PyGObject: https://pygobject.readthedocs.io/

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 bytes-like object (``buffer``, ``bytes``, or
``bytearray``) 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 backends.)

Additional values are available as fields on the audio file object:

- ``channels`` is the number of audio channels (an integer).
- ``samplerate`` is given in Hz (an integer).
- ``duration`` is the length of the audio in seconds (a float).

The ``audio_open`` function transparently selects a backend that can read the
file. (Each backend is implemented in a module inside the ``audioread``
package.) If no backends succeed in opening the file, a ``DecodeError``
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 ``IOError``
will be raised.

A second optional parameter to ``audio_open`` specifies which backends to try
(instead of trying them all, which is the default). You can use the
``available_backends`` function to get a list backends that are usable on the
current system.

Audioread supports Python 3 (3.8+).

Example
-------

The included ``decode.py`` script demonstrates using this package to
convert compressed audio files to WAV files.

Troubleshooting
---------------

A ``NoBackendError`` exception 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 of `FFmpeg`_. To check, try typing
``ffmpeg -version`` in your shell. If that gives you an error, try installing
FFmpeg with your OS's package manager (e.g., apt or yum) or `using Conda
`_.

Version History
---------------

3.0.2
  Support path-like objects (not just strings) in the Core Audio backend.

3.0.1
  Fix a possible deadlock when FFmpeg's version output produces too much data.

3.0.0
  Drop 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 base ``AudioFile`` class.

2.1.9
  Work correctly with GStreamer 1.18 and later (thanks to @ssssam).

2.1.8
  Fix an unhandled ``OSError`` when FFmpeg is not installed.

2.1.7
  Properly 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 backends ``audio_open`` should
  try (thanks once again to @ssssam).
  On Windows, avoid opening a console window to run FFmpeg (thanks to @flokX).

2.1.6
  Fix 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.5
  Properly 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.4
  Fix 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.3
  Avoid some warnings in the GStreamer backend when using modern versions of
  GLib. We now require at least GLib 2.32.

2.1.2
  Fix a file descriptor leak when opening and closing many files using
  GStreamer.

2.1.1
  Just fix ReST formatting in the README.

2.1.0
  The FFmpeg backend can now also use Libav's ``avconv`` command.
  Fix a warning by requiring GStreamer >= 1.0.
  Fix some Python 3 crashes with the new GStreamer backend (thanks to
  @xix-xeaon).

2.0.0
  The GStreamer backend now uses GStreamer 1.x via the new
  gobject-introspection API (and is compatible with Python 3).

1.2.2
  When running FFmpeg on Windows, disable its crash dialog. Thanks to
  jcsaaddupuy.

1.2.1
  Fix an unhandled exception when opening non-raw audio files (thanks to
  aostanin).
  Fix Python 3 compatibility for the raw-file backend.

1.2.0
  Add support for FFmpeg on Windows (thanks to Jean-Christophe Saad-Dupuy).

1.1.0
  Add support for Sun/NeXT `Au files`_ via the standard-library ``sunau``
  module (thanks to Dan Ellis).

1.0.3
  Use the rawread (standard-library) backend for .wav files.

1.0.2
  Send SIGKILL, not SIGTERM, to ffmpeg processes to avoid occasional hangs.

1.0.1
  When GStreamer fails to report a duration, raise an exception instead of
  silently setting the duration field to None.

1.0.0
  Catch GStreamer's exception when necessary components, such as
  ``uridecodebin``, 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.8
  All decoding errors are now subclasses of ``DecodeError``.

0.7
  Fix opening WAV and AIFF files via Unicode filenames.

0.6
  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.

0.5
  Fix crash when FFmpeg fails to report a duration.
  Fix a hang when FFmpeg fills up its stderr output buffer.
  Add a timeout to ``ffmpeg`` tool execution (currently 10 seconds for each
  4096-byte read); a ``ReadTimeoutError`` exception is raised if the tool times
  out.

0.4
  Fix channel count detection for FFmpeg backend.

0.3
  Fix a problem with the Gstreamer backend where audio files could be left open
  even after the ``GstAudioFile`` was "closed".

0.2
  Fix a hang in the GStreamer backend that occurs occasionally on some
  platforms.

0.1
  Initial release.

.. _Au files: http://en.wikipedia.org/wiki/Au_file_format

Et Cetera
---------

``audioread`` is by Adrian Sampson. It is made available under `the MIT
license`_. An alternative to this module is `decoder.py`_.

.. _the MIT license: http://www.opensource.org/licenses/mit-license.php
.. _decoder.py: http://www.brailleweb.com/cgi-bin/python.py

Owner

  • Name: beetbox
  • Login: beetbox
  • Kind: organization

purveyors of fine open-source tools for music nerds

GitHub Events

Total
  • Issues event: 3
  • Watch event: 29
  • Issue comment event: 30
  • Pull request review event: 2
  • Pull request event: 2
  • Fork event: 3
Last Year
  • Issues event: 3
  • Watch event: 29
  • Issue comment event: 30
  • Pull request review event: 2
  • Pull request event: 2
  • Fork event: 3

Committers

Last synced: 11 months ago

All Time
  • Total Commits: 240
  • Total Committers: 24
  • Avg Commits per committer: 10.0
  • Development Distribution Score (DDS): 0.342
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Adrian Sampson a****n@r****g 158
Sam Thursfield s****m@a****k 17
Bomme 1****e 17
Jean-Christophe SAAD-DUPUY j****y@f****g 13
Brian McFee b****e@n****u 4
Johnny Robeson j****y@l****t 3
Florian Kaldowski f****X 3
Ryan Marcus r****n@r****o 3
Carl Thomé c****e@g****m 2
Paul Brossier p****m@p****g 2
Todd t****8@g****m 2
jmoore j****h@g****m 2
llamasoft m****o@g****m 2
xix xeaon x****n@g****m 2
Andrei Ostanin a****n@g****m 1
Cosmologist s****v@g****m 1
Dan Ellis d****e@e****u 1
Glen Baker i****s@g****m 1
Kurt Mosiejczuk k****t@c****k 1
Simon Chopin c****n@g****m 1
Tim Gates t****s@i****m 1
Ubuntu a****n@y****m 1
mightbecharles 5****s 1
Daniel Herman d****n@p****m 1

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 75
  • Total pull requests: 43
  • Average time to close issues: 3 months
  • Average time to close pull requests: 3 months
  • Total issue authors: 65
  • Total pull request authors: 24
  • Average comments per issue: 3.87
  • Average comments per pull request: 2.65
  • Merged pull requests: 30
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 3
  • Pull requests: 3
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 3
  • Pull request authors: 2
  • Average comments per issue: 0.0
  • Average comments per pull request: 4.67
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • bmcfee (5)
  • albertz (3)
  • slychief (2)
  • loretoparisi (2)
  • pconerly (2)
  • Bomme (2)
  • pscn (1)
  • samisherif95 (1)
  • timgates42 (1)
  • mohdeqhwan (1)
  • Shivamagrawal2014 (1)
  • PiotrDabkowski (1)
  • antlarr (1)
  • beantowel (1)
  • gaoming95 (1)
Pull Request Authors
  • ssssam (8)
  • Bomme (5)
  • bmcfee (4)
  • sampsyo (3)
  • HemantKArya (2)
  • ghost (2)
  • lucas42 (2)
  • carlthome (2)
  • timgates42 (2)
  • LucasThompson (1)
  • kmosiejczuk (1)
  • iepathos (1)
  • mightbecharles (1)
  • Charliechen1 (1)
  • llamasoft (1)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 14
  • Total downloads:
    • pypi 3,953,685 last-month
  • Total docker downloads: 50,931,582
  • Total dependent packages: 52
    (may contain duplicates)
  • Total dependent repositories: 3,396
    (may contain duplicates)
  • Total versions: 68
  • Total maintainers: 3
pypi.org: audioread

Multi-library, cross-platform audio decoding.

  • Versions: 27
  • Dependent Packages: 50
  • Dependent Repositories: 3,368
  • Downloads: 3,953,685 Last month
  • Docker Downloads: 50,931,582
Rankings
Dependent repos count: 0.2%
Downloads: 0.3%
Dependent packages count: 0.4%
Docker downloads count: 0.4%
Average: 1.4%
Stargazers count: 2.9%
Forks count: 4.4%
Maintainers (1)
Last synced: 6 months ago
proxy.golang.org: github.com/beetbox/audioread
  • Versions: 19
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 7.0%
Average: 8.2%
Dependent repos count: 9.3%
Last synced: 6 months ago
alpine-edge: py3-audioread

Multi-library, cross-platform audio decoding

  • Versions: 4
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Average: 9.9%
Forks count: 11.8%
Stargazers count: 13.3%
Dependent packages count: 14.6%
Maintainers (1)
Last synced: 7 months ago
alpine-edge: py3-audioread-pyc

Precompiled Python bytecode for py3-audioread

  • Versions: 3
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Average: 10.0%
Forks count: 12.2%
Dependent packages count: 13.9%
Stargazers count: 13.9%
Maintainers (1)
Last synced: 7 months ago
spack.io: py-audioread

cross-library (GStreamer + Core Audio + MAD + FFmpeg) audio decoding for Python.

  • Versions: 1
  • Dependent Packages: 1
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Forks count: 10.3%
Stargazers count: 10.6%
Average: 12.2%
Dependent packages count: 28.1%
Maintainers (1)
Last synced: 6 months ago
conda-forge.org: audioread
  • Versions: 6
  • Dependent Packages: 1
  • Dependent Repositories: 28
Rankings
Dependent repos count: 7.0%
Forks count: 17.6%
Average: 18.0%
Stargazers count: 18.6%
Dependent packages count: 29.0%
Last synced: 7 months ago
alpine-v3.22: py3-audioread-pyc

Precompiled Python bytecode for py3-audioread

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 100%
Maintainers (1)
Last synced: 7 months ago
alpine-v3.21: py3-audioread-pyc

Precompiled Python bytecode for py3-audioread

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 100%
Maintainers (1)
Last synced: 7 months ago
alpine-v3.21: py3-audioread

Multi-library, cross-platform audio decoding

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 100%
Maintainers (1)
Last synced: 7 months ago
alpine-v3.22: py3-audioread

Multi-library, cross-platform audio decoding

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 100%
Maintainers (1)
Last synced: 7 months ago
alpine-v3.19: py3-audioread

Multi-library, cross-platform audio decoding

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 100%
Maintainers (1)
Last synced: 7 months ago
alpine-v3.20: py3-audioread

Multi-library, cross-platform audio decoding

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 100%
Maintainers (1)
Last synced: 6 months ago
alpine-v3.19: py3-audioread-pyc

Precompiled Python bytecode for py3-audioread

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 100%
Maintainers (1)
Last synced: 7 months ago
alpine-v3.20: py3-audioread-pyc

Precompiled Python bytecode for py3-audioread

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 100%
Maintainers (1)
Last synced: 6 months ago

Dependencies

.github/workflows/main.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
pyproject.toml pypi