Audio manager in Python Object-Oriented Programming
Project description
AudiooPy - Audio manager in Python Object-Oriented Programming
Overview
AudiooPy contains some useful operations on sound files and sound fragments. It operates on sound frames, meaning they consist of signed integer samples 8, 16, or 32 bits wide, stored in bytes-like objects.
Among others, it allows the followings:
- Audio reader/writer for wav -- based on Python standard library
- Manipulate raw audio data
- Audio mixer
- Channels extractor
- Channels mixer
- Automated calculation of statistical descriptors for audio data
- High-fidelity automatic detection of sounding segments - also called IPUs. See: https://hal.archives-ouvertes.fr/hal-03697808
AudiooPy is self-implemented, it does not require any other external library.
License
AudiooPy is an open source library under the terms of the GNU General Public License version 3.
Install AudiooPy
From pypi.org:
> python -m pip install AudiooPy
From its wheel package:
Download the wheel file (AudiooPy-xxx.whl) and install it in your python environment with:
> python -m pip install <AudiooPy-xxx.whl>
From its repo:
Download the repository and unpack it, or clone with git
. Optionally, it can be installed with:
> python -m pip install .
Install all the optional dependencies with:
> python -m pip install ".[docs, tests]"
AudiooPy package includes the following folders and files:
- "audioopy": the source code package
- "docs": the documentation of audioopy library in HTML and Markdown
- "tests": the tests of the source code
- "scripts": a few python scripts using audioopy to manipulate audio files
Quick Start
A few scripts are already available in the scripts
folder. Try for example:
> python ./scripts/audioinfo.py -w samples/oriana1.wa
Or, you can do it yourself! Open an audio file and get some information with:
import audioopy.aio
audio = audioopy.aio.open("samples/oriana1.wav")
audio.get_sampwidth()
audio.get_framerate()
audio.get_duration()
audio.get_nchannels()
audio.get_nframes()
audio.rms()
audio.clipping_rate(0.4)
Advanced usage
Example of automatic detection of sounding segments:
import audioopy
import audioopy.aio
import audioopy.audioutils
audio = audioopy.aio.open("samples/oriana1.wav")
channel = audio.extract_channel(0)
chansil = audioopy.ChannelSilence(channel, winlenght=0.01)
chansil.search_silences(threshold=0, mintrackdur=0.040)
chansil.filter_silences(minsildur=0.250)
tracks = chansil.extract_tracks(mintrackdur=0.300, shiftdurstart=0.010, shiftdurend=0.010)
tracks.append((channel.get_nframes(), channel.get_nframes()))
tracks_times = audioopy.audioutils.frames2times(tracks, channel.get_framerate())
Make the doc
The API documentation is available in the docs
folder. Click the file index.html
to browse throw the documented classes.
To re-generate the doc, install the required external programs, then launch the doc generator:
>python -m pip install ".[docs]"
>python makedoc.py
Projects using AudiooPy
AudiooPy was initially developed within SPPAS https://sppas.org; it was extracted from its original software by the author to lead its own life as standalone package.
The developer's corner
Create a wheel
AudiooPy is no system dependent. Information to build its wheel are stored into the file pyproject.toml
.
The universal wheel is created with: python -m build
How to contribute
If you plan to contribute to the code, please send an e-mail to the author.
Author/Copyright
Copyright (C) 2024 - Brigitte Bigi - contact@sppas.org Laboratoire Parole et Langage, Aix-en-Provence, France.
Changes
-
Version 0.1:
- Initial version, extracted from SPPAS 4.17.
- A few self-implemented functions into AudioFrames() instead of using 'audioop' standard library.
-
Version 0.2:
- Self-implemented functions into AudioFrames(), except for resample() which is only partially self-implemented.
- Added function clip() in AudioFrames().
- Added 2090: NumberFramesError.
- Updated scripts
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.