audioread


Nameaudioread JSON
Version 3.0.1 PyPI version JSON
download
home_pageNone
SummaryMulti-library, cross-platform audio decoding.
upload_time2023-09-27 19:27:53
maintainerNone
docs_urlNone
authorNone
requires_python>=3.6
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            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
<https://anaconda.org/conda-forge/ffmpeg>`_.

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

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

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "audioread",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "Adrian Sampson <adrian@radbox.org>",
    "download_url": "https://files.pythonhosted.org/packages/db/d2/87016ca9f083acadffb2d8da59bfa3253e4da7eeb9f71fb8e7708dc97ecd/audioread-3.0.1.tar.gz",
    "platform": null,
    "description": "audioread\n=========\n\nDecode audio files using whichever backend is available. The library\ncurrently supports:\n\n- `Gstreamer`_ via `PyGObject`_.\n- `Core Audio`_ on Mac OS X via `ctypes`_. (PyObjC not required.)\n- `MAD`_ via the `pymad`_ bindings.\n- `FFmpeg`_ or `Libav`_ via its command-line interface.\n- The standard library `wave`_, `aifc`_, and `sunau`_ modules (for\n  uncompressed audio formats).\n\n.. _Gstreamer: http://gstreamer.freedesktop.org/\n.. _gst-python: http://gstreamer.freedesktop.org/modules/gst-python.html\n.. _Core Audio: http://developer.apple.com/technologies/mac/audio-and-video.html\n.. _ctypes: http://docs.python.org/library/ctypes.html\n.. _MAD: http://www.underbit.com/products/mad/\n.. _pymad: http://spacepants.org/src/pymad/\n.. _FFmpeg: http://ffmpeg.org/\n.. _Libav: https://www.libav.org/\n.. _wave: http://docs.python.org/library/wave.html\n.. _aifc: http://docs.python.org/library/aifc.html\n.. _sunau: http://docs.python.org/library/sunau.html\n.. _PyGObject: https://pygobject.readthedocs.io/\n\nUse the library like so::\n\n    with audioread.audio_open(filename) as f:\n        print(f.channels, f.samplerate, f.duration)\n        for buf in f:\n            do_something(buf)\n\nBuffers in the file can be accessed by iterating over the object returned from\n``audio_open``. Each buffer is a bytes-like object (``buffer``, ``bytes``, or\n``bytearray``) containing raw **16-bit little-endian signed integer PCM\ndata**. (Currently, these PCM format parameters are not configurable, but this\ncould be added to most of the backends.)\n\nAdditional values are available as fields on the audio file object:\n\n- ``channels`` is the number of audio channels (an integer).\n- ``samplerate`` is given in Hz (an integer).\n- ``duration`` is the length of the audio in seconds (a float).\n\nThe ``audio_open`` function transparently selects a backend that can read the\nfile. (Each backend is implemented in a module inside the ``audioread``\npackage.) If no backends succeed in opening the file, a ``DecodeError``\nexception is raised. This exception is only used when the file type is\nunsupported by the backends; if the file doesn't exist, a standard ``IOError``\nwill be raised.\n\nA second optional parameter to ``audio_open`` specifies which backends to try\n(instead of trying them all, which is the default). You can use the\n``available_backends`` function to get a list backends that are usable on the\ncurrent system.\n\nAudioread supports Python 3 (3.8+).\n\nExample\n-------\n\nThe included ``decode.py`` script demonstrates using this package to\nconvert compressed audio files to WAV files.\n\nTroubleshooting\n---------------\n\nA ``NoBackendError`` exception means that the library could not find one of\nthe libraries or tools it needs to decode audio. This could mean, for example,\nthat you have a broken installation of `FFmpeg`_. To check, try typing\n``ffmpeg -version`` in your shell. If that gives you an error, try installing\nFFmpeg with your OS's package manager (e.g., apt or yum) or `using Conda\n<https://anaconda.org/conda-forge/ffmpeg>`_.\n\nVersion History\n---------------\n\n3.0.1\n  Fix a possible deadlock when FFmpeg's version output produces too much data.\n\n3.0.0\n  Drop support for Python 2 and older versions of Python 3. The library now\n  requires Python 3.6+.\n  Increase default block size in FFmpegAudioFile to get slightly faster file reading.\n  Cache backends for faster lookup (thanks to @bmcfee).\n  Audio file classes now inherit from a common base ``AudioFile`` class.\n\n2.1.9\n  Work correctly with GStreamer 1.18 and later (thanks to @ssssam).\n\n2.1.8\n  Fix an unhandled ``OSError`` when FFmpeg is not installed.\n\n2.1.7\n  Properly close some filehandles in the FFmpeg backend (thanks to\n  @RyanMarcus and @ssssam).\n  The maddec backend now always produces bytes objects, like the other\n  backends (thanks to @ssssam).\n  Resolve an audio data memory leak in the GStreamer backend (thanks again to\n  @ssssam).\n  You can now optionally specify which specific backends ``audio_open`` should\n  try (thanks once again to @ssssam).\n  On Windows, avoid opening a console window to run FFmpeg (thanks to @flokX).\n\n2.1.6\n  Fix a \"no such process\" crash in the FFmpeg backend on Windows Subsystem for\n  Linux (thanks to @llamasoft).\n  Avoid suppressing SIGINT in the GStreamer backend on older versions of\n  PyGObject (thanks to @lazka).\n\n2.1.5\n  Properly clean up the file handle when a backend fails to decode a file.\n  Fix parsing of \"N.M\" channel counts in the FFmpeg backend (thanks to @piem).\n  Avoid a crash in the raw backend when a file uses an unsupported number of\n  bits per sample (namely, 24-bit samples in Python < 3.4).\n  Add a ``__version__`` value to the package.\n\n2.1.4\n  Fix a bug in the FFmpeg backend where, after closing a file, the program's\n  standard input stream would be \"broken\" and wouldn't receive any input.\n\n2.1.3\n  Avoid some warnings in the GStreamer backend when using modern versions of\n  GLib. We now require at least GLib 2.32.\n\n2.1.2\n  Fix a file descriptor leak when opening and closing many files using\n  GStreamer.\n\n2.1.1\n  Just fix ReST formatting in the README.\n\n2.1.0\n  The FFmpeg backend can now also use Libav's ``avconv`` command.\n  Fix a warning by requiring GStreamer >= 1.0.\n  Fix some Python 3 crashes with the new GStreamer backend (thanks to\n  @xix-xeaon).\n\n2.0.0\n  The GStreamer backend now uses GStreamer 1.x via the new\n  gobject-introspection API (and is compatible with Python 3).\n\n1.2.2\n  When running FFmpeg on Windows, disable its crash dialog. Thanks to\n  jcsaaddupuy.\n\n1.2.1\n  Fix an unhandled exception when opening non-raw audio files (thanks to\n  aostanin).\n  Fix Python 3 compatibility for the raw-file backend.\n\n1.2.0\n  Add support for FFmpeg on Windows (thanks to Jean-Christophe Saad-Dupuy).\n\n1.1.0\n  Add support for Sun/NeXT `Au files`_ via the standard-library ``sunau``\n  module (thanks to Dan Ellis).\n\n1.0.3\n  Use the rawread (standard-library) backend for .wav files.\n\n1.0.2\n  Send SIGKILL, not SIGTERM, to ffmpeg processes to avoid occasional hangs.\n\n1.0.1\n  When GStreamer fails to report a duration, raise an exception instead of\n  silently setting the duration field to None.\n\n1.0.0\n  Catch GStreamer's exception when necessary components, such as\n  ``uridecodebin``, are missing.\n  The GStreamer backend now accepts relative paths.\n  Fix a hang in GStreamer when the stream finishes before it begins (when\n  reading broken files).\n  Initial support for Python 3.\n\n0.8\n  All decoding errors are now subclasses of ``DecodeError``.\n\n0.7\n  Fix opening WAV and AIFF files via Unicode filenames.\n\n0.6\n  Make FFmpeg timeout more robust.\n  Dump FFmpeg output on timeout.\n  Fix a nondeterministic hang in the Gstreamer backend.\n  Fix a file descriptor leak in the MAD backend.\n\n0.5\n  Fix crash when FFmpeg fails to report a duration.\n  Fix a hang when FFmpeg fills up its stderr output buffer.\n  Add a timeout to ``ffmpeg`` tool execution (currently 10 seconds for each\n  4096-byte read); a ``ReadTimeoutError`` exception is raised if the tool times\n  out.\n\n0.4\n  Fix channel count detection for FFmpeg backend.\n\n0.3\n  Fix a problem with the Gstreamer backend where audio files could be left open\n  even after the ``GstAudioFile`` was \"closed\".\n\n0.2\n  Fix a hang in the GStreamer backend that occurs occasionally on some\n  platforms.\n\n0.1\n  Initial release.\n\n.. _Au files: http://en.wikipedia.org/wiki/Au_file_format\n\nEt Cetera\n---------\n\n``audioread`` is by Adrian Sampson. It is made available under `the MIT\nlicense`_. An alternative to this module is `decoder.py`_.\n\n.. _the MIT license: http://www.opensource.org/licenses/mit-license.php\n.. _decoder.py: http://www.brailleweb.com/cgi-bin/python.py\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Multi-library, cross-platform audio decoding.",
    "version": "3.0.1",
    "project_urls": {
        "Home": "https://github.com/beetbox/audioread"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "578d30aa32745af16af0a9a650115fbe81bde7c610ed5c21b381fca0196f3a7f",
                "md5": "5fd661c667005d4e9e1368316f0ee6c1",
                "sha256": "4cdce70b8adc0da0a3c9e0d85fb10b3ace30fbdf8d1670fd443929b61d117c33"
            },
            "downloads": -1,
            "filename": "audioread-3.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5fd661c667005d4e9e1368316f0ee6c1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 23492,
            "upload_time": "2023-09-27T19:27:51",
            "upload_time_iso_8601": "2023-09-27T19:27:51.334719Z",
            "url": "https://files.pythonhosted.org/packages/57/8d/30aa32745af16af0a9a650115fbe81bde7c610ed5c21b381fca0196f3a7f/audioread-3.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "dbd287016ca9f083acadffb2d8da59bfa3253e4da7eeb9f71fb8e7708dc97ecd",
                "md5": "3de844f9c75b97691da85e0f1ec76e90",
                "sha256": "ac5460a5498c48bdf2e8e767402583a4dcd13f4414d286f42ce4379e8b35066d"
            },
            "downloads": -1,
            "filename": "audioread-3.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "3de844f9c75b97691da85e0f1ec76e90",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 116513,
            "upload_time": "2023-09-27T19:27:53",
            "upload_time_iso_8601": "2023-09-27T19:27:53.084777Z",
            "url": "https://files.pythonhosted.org/packages/db/d2/87016ca9f083acadffb2d8da59bfa3253e4da7eeb9f71fb8e7708dc97ecd/audioread-3.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-27 19:27:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "beetbox",
    "github_project": "audioread",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "audioread"
}
        
Elapsed time: 0.12280s