Skip to main content

multi-library, cross-platform audio decoding

Project description

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

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 buffer or str object containing raw 16-bit little-endian integer PCM data. (Currently, these PCM format attributes 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 automatically 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.

Future Work

Possible additional backends:

  • PyOgg?

  • Other command-line tools?

Example

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

Et Cetera

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

Project details


Download files

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

Source Distribution

audioread-0.1.tar.gz (11.4 kB view details)

Uploaded Source

File details

Details for the file audioread-0.1.tar.gz.

File metadata

  • Download URL: audioread-0.1.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for audioread-0.1.tar.gz
Algorithm Hash digest
SHA256 9b996adf3fe3f57291acd4b7d6ecda1b282f1eb6fb7d435d9b73affe52c4cc6c
MD5 c16b72723d16b9eed3e0df82498ee723
BLAKE2b-256 a464e56f9b6f170f64affcca75daaf61c8a0c828a29ec9a28ad8928f70f90c5d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page