Skip to main content

Audio Helper

🇫🇷 · 🇬🇧

CI License: BSD-3-Clause Python Local-first

Audio Helper belongs to a collection of libraries called AI Helpers developed for building Artificial Intelligence.

🌍 AI Helpers

logo

Audio Helper is a Python library that provides utility functions for processing audio files. It includes features like loading audio, converting formats, separating audio sources, and splitting and concatenating audio files.

Audio Helper is battle-tested: every change ships through automated tests and continuous integration before it reaches PyPI, versions follow Semantic Versioning, and two other published packages in the suite, youtube-helper and vocal-helper, build directly on top of it in production. Audio Helper itself depends on os-helper, the shared foundation package every library in the suite uses for logging and file management. That is what "battle-tested" means here: not a claim, but a dependency graph other shipped code actually stands on, on both sides of this package.

The Promise

Audio Helper is local-first by design. Three honest cases:

  1. Guaranteed local. Every operation, including the browser GUI at GET /gui, runs on your machine via ffmpeg and local Demucs (Meta's AI model for splitting a mixed track into its component sounds: vocals, drums, bass, everything else). Your audio is never uploaded to any third party. There is no telemetry, no account, no SaaS dependency.
  2. The one caveat: model weights. Source separation downloads the Demucs model weights once, on first run (a normal Hugging Face / PyTorch cache fetch). After that it is fully offline. Nothing else needs the network.
  3. Your decision. Nothing here forces the cloud. If you ever want to run behind a proxy or in a container, the FastAPI surface makes that easy, but that is a choice you make, not a default we impose.

Documentation

💻 Documentation

🗺️ Landscape

📋 Examples

Features

  • Audio Loading: load files with optional resampling and mono downmix.
  • Sound Conversion: ffmpeg-backed format/sample-rate/channels conversion.
  • Source Separation: vocals / drums / bass / other via Demucs (optional [demucs] extra).
  • Audio Splitting: fixed-duration chunks and arbitrary [start, end] slices.
  • Concatenation: head-to-tail join into any ffmpeg-supported container.
  • Silent Audio Generation: write silence of a specified duration.
  • Room-Tone Mixing: pink/white/brown ambient noise to mask edits between cuts.
  • Similarity: sound_resemblance score for A/B comparison, based on Mel-Frequency Cepstral Coefficients (MFCCs), a standard way of boiling a clip's spectrum down to a compact set of numbers that captures how it sounds rather than its raw waveform, so two recordings of the same voice score close together even if the takes differ slightly.
  • Feature Extraction: scipy-based Mel / MFCC primitives.

Five surfaces, one toolkit. Every operation above is reachable as:

  • Library: import audio_helper as ah.
  • CLI: audio-helper — one command line, built with click, always installed.
  • HTTP API: FastAPI app ([api] extra), OpenAPI docs at /docs.
  • MCP: the same FastAPI app exposed through the Model Context Protocol (MCP), a standard that lets an AI agent call a program's functions as tools instead of a human clicking through a UI (audio-helper-mcp, [mcp] extra) for any MCP-aware agent host.
  • GUI: a build-step-free browser Recipe Canvas served at GET /gui. Chain the eight verbs into a sequential pipeline, hear every intermediate step (WaveSurfer waveforms), bypass any step for instant A/B, use the ear-first before/after comparator (Space bar toggles), and export the pipeline as a committable recipe.yaml. See GUI.md.

For the exhaustive trigger catalogue, see TRIGGERS.md.

Installation

Prerequisites: Python 3.10–3.13, git, ffmpeg, cross-platform:

  • 🍎 macOS (Homebrew): brew install python git ffmpeg
  • 🐧 Ubuntu/Debian: sudo apt update && sudo apt install -y python3 python3-pip git ffmpeg
  • 🪟 Windows (PowerShell): winget install Python.Python.3.12 Git.Git Gyan.FFmpeg

We recommend using Python environments. Check this link if you're unfamiliar with setting one up: 🥸 Tech tips.

# Core audio utilities only (load, convert, split, concatenate, silent audio, chunks)
pip install audio-helper

# Add source separation (pulls in torch + torchaudio, ~2 GB)
pip install "audio-helper[demucs]"

# Optional surfaces
pip install "audio-helper[api]"       # FastAPI HTTP surface

From source (no PyPI)

git clone https://github.com/warith-harchaoui/audio-helper.git
cd audio-helper
pip install -e .

# Add source separation (pulls in torch + torchaudio, ~2 GB)
pip install -e ".[demucs]"

# Optional surfaces
pip install -e ".[api]"

If you call separate_sources without the [demucs] extra, the function raises an ImportError pointing you back here.

Usage

For the full catalog of recipes, see 📋 EXAMPLES.md.

Here's an example of how to use Audio Helper to load, convert, and split an audio file:

(download example.mp3 )

It is part of a JFK speech that is badly recorded

import audio_helper as ah

# Load an audio file
audio_file = "example.mp3"
audio, sample_rate = ah.load_audio(audio_file)

# Convert the audio file to a different format
output_audio = "audio_tests/example.wav"
ah.sound_converter(audio_file, output_audio)

# Split the audio file into chunks of 30 seconds
chunks = ah.split_audio_regularly(
    audio_file, "audio_tests/chunks_folder", split_time=30.0, overwrite=True
)
# Concatenate the chunks back together
new_concatenated_audio = "audio_tests/concatenated.wav"
concatenated_audio = ah.audio_concatenation(chunks, output_audio_filename=new_concatenated_audio)

Another cool example is about source separation (DEMUCS from META) with AI separating one audio track into 4 tracks:

  • vocals
  • drums
  • bass
  • other

It works with speech and songs

import audio_helper as ah

audio_path = "input_audio.m4a"

sources = ah.separate_sources(
    audio_path,
    output_folder="audio_tests",
    device="cpu",  # or "cuda" if GPU or nothing to let it decide
    nb_workers=4,  # ignored if not cpu
    output_format="mp3",
)

print(sources)
# {'vocals': 'audio_tests/vocals.mp3', 'drums': 'audio_tests/drums.mp3', 'bass': 'audio_tests/bass.mp3', 'other': 'audio_tests/other.mp3'}

Multi-surface exposure

audio-helper is not just a library: the same functions are exposed as a CLI and a FastAPI HTTP surface:

# Python library (default)
import audio_helper as ah

# CLI (installed automatically)
audio-helper convert --input in.mp3 --output out.wav --freq 44100
audio-helper split --input in.mp3 --output-dir chunks/ --seconds 30
audio-helper separate --input mix.mp3 --output-dir stems/
audio-helper resemblance --a a.mp3 --b b.mp3


# FastAPI HTTP surface (needs the [api] extra)
pip install "audio-helper[api]"
# or from source:
pip install "audio-helper[api]"
uvicorn audio_helper.api:app --port 8000
# → OpenAPI docs at http://localhost:8000/docs

# MCP tools for any MCP-aware agent host (needs the [mcp] extra)
pip install "audio-helper[mcp]"
audio-helper-mcp
# → same app + an /mcp endpoint (fastapi-mcp)

Docker image (light, without Demucs by default):

docker build -t audio-helper .
docker run --rm -p 8000:8000 audio-helper
# with Demucs:
docker build --build-arg WITH_DEMUCS=1 -t audio-helper:demucs .

The Recipe Canvas GUI ships today: it is served by the FastAPI app at GET /gui (open http://localhost:8000/gui after starting the server), and already covers the sequential pipeline builder, the ear-first before/after comparator, and recipe.yaml export/import. Batch triage across many files (a drop-zone contact sheet, an MFCC-cluster view) is the part still on the roadmap. See GUI.md for the full split between what ships and what is planned.

The page speaks French and English. GET /gui?lang=fr|en picks one, a flag in the header toggles between them, and a code the locale file does not carry falls back to the default rather than failing. Every string lives in audio_helper/locales/fr/LC_MESSAGES/audio_helper.po, a standard gettext catalogue read through os_helper.Catalog — the loader shared across the suite — so translating the page never means opening a Python file. Two things stay in one language on purpose, and the file says why: the per-verb parameter labels name the form fields the request carries, and the comment header of an exported recipe.yaml belongs to a committable artifact rather than to the UI.

Use it as an agent skill

skills/audio-helper/ packages audio-helper as a Claude Skill and an OpenCode skill, so an agent can reach for it on your behalf. See skills/README.md to install it (symlink into ~/.claude/skills/ and ~/.opencode/skills/), and TRIGGERS.md for the exhaustive trigger catalogue — scripts/check_triggers.py keeps the skill's description in sync with it, and the test suite fails if a capability stops being named.

Rust rewrite

A companion crate, audio-helper-rs, rewrites the file-level surface (probe, convert, load-to-PCM, chunk, silence, concatenate, room tone, split) in idiomatic Rust. It is not a port and not a replacement: separate_sources (Demucs) and sound_resemblance (MFCC) stay Python-only, disproportionate for a Rust crate to reimplement. The payoff of reaching for it instead of this package: a dependency that compiles straight into your own Rust binary, with no Python interpreter, pip install, or virtualenv on the target machine — useful when audio-helper's job is a small piece of a larger Rust program, or the deployment target can't carry a Python runtime at all.

Author

Acknowledgements

Special thanks to Mohamed Chelali and Bachir Zerroug for fruitful discussions.

License

This project is licensed under the BSD-3-Clause License: see the LICENSE file for details.

Metadata

Release files for audio-helper 2.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for audio-helper 2.5.0
File Size Uploaded Provenance Actions
audio_helper-2.5.0.tar.gz 85.2 kB Without provenance Details for audio_helper-2.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for audio-helper 2.5.0
File Interpreter ABI Platform Actions
audio_helper-2.5.0-py3-none-any.whl Python 3 none any Details for audio_helper-2.5.0-py3-none-any.whl

Total release size: 148.0 kB

Release files / audio_helper-2.5.0.tar.gz

Download URL audio_helper-2.5.0.tar.gz
Size 85.2 kB
Tags Source
SHA-256 checksum
How to use checksums
eb734c04f456209a986c5fe03ef1e97cde31a3956a9457cabaa6f666c0cdedfa
BLAKE2b-256 checksum
How to use checksums
49014a7f4a6548c08d0f25040468c8b59af53e92769f148ddbd4b02cc4a07b4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / audio_helper-2.5.0-py3-none-any.whl

Download URL audio_helper-2.5.0-py3-none-any.whl
Size 62.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
325a26993d744c240fcc0ed2a5b7a538f4717e656983d4eaf6156d72e2babe41
BLAKE2b-256 checksum
How to use checksums
0ff372bd1d9e1986392b0ec349630abfdd99c4e64c3f90d7473304886e56d00a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Security for audio-helper 2.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page