audioread is a Python library that provides a unified, cross-platform interface for decoding audio files using various underlying system libraries such as GStreamer, FFmpeg, or libmad. It aims to offer a simple way to read raw audio data and its properties from many common audio formats. The current version is 3.1.0, and it maintains a moderate release cadence, primarily for bug fixes and compatibility with newer Python versions or backend libraries.
pip install audioreadVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to open an audio file using `audioread.audio_open`, access its properties (channels, samplerate, duration), and iterate through its raw audio data buffers. It also includes error handling for the common `NoBackendError` (when no system audio decoding library is found) and `FileNotFoundError`.
Install a compatible audio decoding library on your system (e.g., `sudo apt-get install gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad ffmpeg` on Debian/Ubuntu, or `brew install ffmpeg` on macOS).
Manually convert the `bytes` buffers to suitable numerical formats (e.g., using `numpy.frombuffer` with appropriate `dtype` and `channels` information) for further processing.
Be aware of potential inaccuracies when relying on `duration` for precise timing. For critical applications, consider processing the entire file to determine true length or using backends known for better accuracy if available.
Upgrade your Python environment to Python 3.9 or a newer version to use `audioread` 3.x.
Install the module using pip: 'pip install audioread'.
Ensure that FFmpeg or GStreamer is installed and accessible in your system's PATH.
Use 'from audioread import audio_open' to import the function correctly.
Install a suitable audio decoding backend for your operating system and ensure its executable is in your system's PATH. For example, on Ubuntu/Debian: `sudo apt-get install ffmpeg` or `sudo apt-get install libav-tools`. On Windows, download FFmpeg, extract it, and add the path to its `bin` directory to your system's PATH environment variable. Restart your terminal or IDE after installation.
Ensure the audio file is not corrupted and is in a format supported by your installed backend (e.g., MP3, WAV, FLAC). Try playing the file with a standard media player to confirm its integrity. If a backend like FFmpeg is installed, ensure it's up-to-date and correctly configured to handle the file's format.