Coder Social home page Coder Social logo

audioread's Introduction

audioread

Decode audio files using whichever backend 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 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.

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.

Version History

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.

Et Cetera

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

audioread's People

Contributors

sampsyo avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.