Skip to main content

Fast reading of all kind of audio files

Project description

tests docs

The python package audiofile provides a meta package to handle all kind of audio files under Python with a focus on reading speed.

Documentation: https://audiofile.readthedocs.io/

Installation

It is recommended to first create a Python virtual environment using a tool like virtualenv, e.g.

virtualenv --python=/usr/bin/python3 --no-site-packages _env
source _env/bin/activate

Afterwards install audiofile with

pip install audiofile

In order to handle all possible audio files, please make sure ffmpeg and mediainfo are installed on your system.

If you want to use Python 2.7 make sure you install the following backports package as well:

pip install backports.tempfile

Usage

Import the package and use it to write or read an audio file, or get information about its metadata:

import numpy as np
import audiofile as af

sampling_rate = 8000  # in Hz
noise = np.random.normal(0, 1, sampling_rate)
noise /= np.amax(np.abs(noise))
af.write('noise.wav', noise, sampling_rate)
af.channels('noise.wav')
af.duration('noise.wav')
sig, fs = af.read('noise.wav')

It should work with every audio file you will work with. WAV, FLAC, and OGG files are handled by soundfile. The reading of all other audio files is managed by converting them to a temporary WAV file by pysox or ffmpeg, which means it can handle audio from video files as well.

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

audiofile-0.1.3.tar.gz (10.9 kB view hashes)

Uploaded Source

Built Distribution

audiofile-0.1.3-py3-none-any.whl (6.0 kB view hashes)

Uploaded Python 3

Supported by

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