Skip to main content

Cross-platform audio capture, playback, and voice activity detection

Project description

Decibri

Cross-platform audio capture, playback, and processing for Python.

PyPI version Python versions License

Decibri is a native Python package that delivers microphone capture, speaker output, local voice activity detection, device enumeration, and sample format conversion. It is written in Rust (via PyO3 / abi3) and ships pre-built wheels for Linux, macOS Apple Silicon, and Windows.

Install

Recommended with uv:

uv pip install decibri

Or with pip:

pip install decibri

Quickstart

Capture audio

import decibri

with decibri.Microphone(sample_rate=16000, channels=1) as mic:
    for chunk in mic:
        print(f"Got {len(chunk)} bytes")
        break  # exit after first chunk for demo

Record one second to a WAV file

import decibri

decibri.record_to_file("output.wav", duration_seconds=1.0, sample_rate=16000)

Capture with Silero VAD

import decibri

with decibri.Microphone(sample_rate=16000, vad="silero") as mic:
    for chunk in mic:
        print(f"Got {len(chunk)} bytes; VAD score {mic.vad_score}; speaking={mic.is_speaking}")
        break  # exit after first chunk for demo

Async capture

import asyncio
import decibri

async def main():
    async with await decibri.AsyncMicrophone.open(sample_rate=16000, vad="silero") as mic:
        async for chunk in mic:
            print(f"Got {len(chunk)} bytes; VAD score {mic.vad_score}")
            break  # exit after first chunk for demo

asyncio.run(main())

Speaker output

import decibri

with decibri.Speaker(sample_rate=24000, channels=1) as spk:
    audio_bytes = b"\x00\x00" * 24000  # 1 second of silence at 24kHz int16
    spk.write(audio_bytes)  # int16 PCM
    spk.drain()

Public API

Core classes

  • Microphone: synchronous audio capture
  • Speaker: synchronous audio output
  • AsyncMicrophone: async-await audio capture
  • AsyncSpeaker: async-await audio output

Module-level functions

  • decibri.input_devices(): enumerate available input devices
  • decibri.output_devices(): enumerate available output devices
  • decibri.version(): version + audio backend info
  • decibri.record_to_file(path, duration_seconds, ...): record N seconds to a WAV file
  • decibri.async_record_to_file(path, duration_seconds, ...): async equivalent

Value types

MicrophoneInfo, SpeakerInfo, VersionInfo, Chunk.

Exceptions

The full hierarchy lives at decibri.exceptions. Top-level catch-targets surfaced at the package root:

  • DecibriError: base of the hierarchy
  • DeviceError: input / output device problems
  • OrtError: ONNX Runtime issues
  • OrtPathError: ORT dylib path resolution issues
  • ForkAfterOrtInit: Linux fork-after-ORT-init detection

Voice Activity Detection

Decibri ships with two VAD modes: a lightweight RMS energy threshold (opt-in via vad="energy") and a Silero ONNX model (~2.3 MB, bundled in the wheel; no API keys required). Pass the mode as the vad="silero" / vad="energy" shorthand (which uses the default threshold and a 300 ms holdoff) or as a decibri.Vad(model=, threshold=, holdoff_ms=) config object to tune them.

# Energy mode (lightweight, no model)
mic = decibri.Microphone(vad=decibri.Vad(model="energy", threshold=0.01))

# Silero mode (ML-based, more accurate in noisy environments)
mic = decibri.Microphone(vad=decibri.Vad(model="silero", threshold=0.5))

Use mic.vad_score (a value in [0, 1]) to gate downstream processing. mic.is_speaking returns the boolean above-threshold view.

decibri ACE (audio conditioning)

decibri ACE (Audio Capture Engine) is decibri's opt-in audio front-end for speech: a conditioning chain applied to the captured audio before it is delivered. Every stage is off by default, runs on-device, and needs no API key. Leave the options unset and the capture path is unchanged.

The stages run in this order. Pass any subset on the Microphone constructor:

Stage Keyword Value
DC removal dc_removal=True bool, default False
Denoise denoise="fastenhancer-t" the one bundled model
High-pass highpass=80 or 100 Hz, second-order Butterworth
AGC agc=-18 int dBFS, -40 to -3
Limiter limiter=-1.0 float dBFS, -3.0 to 0.0
import decibri

with decibri.Microphone(
    sample_rate=16000,
    denoise="fastenhancer-t",  # bundled speech-enhancement model
    highpass=80,               # remove low-frequency rumble
    agc=-18,                   # target level in dBFS
    limiter=-1.0,              # peak ceiling in dBFS
    vad=decibri.Vad(model="silero", threshold=0.5),
) as mic:
    for chunk in mic:
        if mic.is_speaking:
            handle(chunk)      # conditioned int16 PCM bytes

The denoise model is bundled in the wheel (the same way the Silero VAD model is), so denoise="fastenhancer-t" needs no download. VAD reads the signal before the chain, so mic.vad_score and mic.is_speaking are unaffected by which conditioning stages you enable. The same options are available on AsyncMicrophone.

Compatibility

Python Platforms
3.10, 3.11, 3.12, 3.13, 3.14 Linux x64, Linux ARM64, macOS Apple Silicon, Windows x64

Bundled assets

The wheel includes:

  • Silero VAD ONNX model (~2.3 MB): no downloads or API keys required for vad="silero".
  • ONNX Runtime dylib (~15-20 MB platform-specific): no system dependency on pip install onnxruntime.

First ORT load on vad="silero" initialization is ~100 to 500 ms (amortized across subsequent calls).

Async usage

For Silero VAD in async code, use the open() factory to dispatch the synchronous ORT init off the event loop:

async with await decibri.AsyncMicrophone.open(vad="silero") as mic:
    async for chunk in mic:
        ...

Synchronous constructors (AsyncMicrophone(...)) remain supported and unchanged; open() is the recommended pattern when ORT load cost matters.

Multiprocessing

Linux multiprocessing with Silero VAD requires set_start_method('spawn'). Calling fork() after ORT initialization raises ForkAfterOrtInit:

import multiprocessing as mp

mp.set_start_method('spawn')  # required on Linux for Silero

See the ecosystem guides under bindings/python/docs/ecosystem/ (jupyter, docker, multiprocessing) for environment-specific details.

Documentation

License

Apache-2.0. See LICENSE for details.

Copyright (c) 2026 Decibri.

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

decibri-0.5.0.tar.gz (2.5 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

decibri-0.5.0-cp310-abi3-win_amd64.whl (8.2 MB view details)

Uploaded CPython 3.10+Windows x86-64

decibri-0.5.0-cp310-abi3-manylinux_2_28_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ x86-64

decibri-0.5.0-cp310-abi3-manylinux_2_28_aarch64.whl (3.2 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ ARM64

decibri-0.5.0-cp310-abi3-macosx_14_0_arm64.whl (12.5 MB view details)

Uploaded CPython 3.10+macOS 14.0+ ARM64

File details

Details for the file decibri-0.5.0.tar.gz.

File metadata

  • Download URL: decibri-0.5.0.tar.gz
  • Upload date:
  • Size: 2.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for decibri-0.5.0.tar.gz
Algorithm Hash digest
SHA256 e4db0dab5e5eb4123e5a1713ba3e4fb4779c9d0cf6d87aaf1fc8b210ef1452c4
MD5 d004aaf1cb0eb3ed84bdcc1ddb00f9bc
BLAKE2b-256 47c937a75245e9a2271f3c40b9ab64c5f6f7ba47ea288ed880003a3d2a3be88e

See more details on using hashes here.

Provenance

The following attestation bundles were made for decibri-0.5.0.tar.gz:

Publisher: publish-pypi.yml on decibri/decibri

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file decibri-0.5.0-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: decibri-0.5.0-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 8.2 MB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for decibri-0.5.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 189644ee4b79280fd0fce301de447efb4f0e56a6fd1215153cbef71085514807
MD5 0ba6c0ef9a7e11f207eb32e3ad15a7fb
BLAKE2b-256 dad4f85fbb27072c5af3f5b89c5e425bb91ae03da19aed7557f259e8b1bb2116

See more details on using hashes here.

Provenance

The following attestation bundles were made for decibri-0.5.0-cp310-abi3-win_amd64.whl:

Publisher: publish-pypi.yml on decibri/decibri

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file decibri-0.5.0-cp310-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for decibri-0.5.0-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3a3e7a4e6b39df35884eedf34696989f5e07f56e243c0ca9a96e9962017d63d7
MD5 b4d7183ac5e2e89f2999cb1222f61cdc
BLAKE2b-256 2ad80dc547cbf481d4430a95b526740edc8fae0cddbaa9d34ac606db036a1cd2

See more details on using hashes here.

Provenance

The following attestation bundles were made for decibri-0.5.0-cp310-abi3-manylinux_2_28_x86_64.whl:

Publisher: publish-pypi.yml on decibri/decibri

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file decibri-0.5.0-cp310-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for decibri-0.5.0-cp310-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 a53739d67dfc0f053f05b7cfe064002fec71517d16a6c5879fd2672fb1096698
MD5 8e4696ccd3ad683970ab0e79db1a1089
BLAKE2b-256 42c4eead9a5f8c223cfa9a95c52509fc2c5f77df3b205e3e97b0e5fe36b95c32

See more details on using hashes here.

Provenance

The following attestation bundles were made for decibri-0.5.0-cp310-abi3-manylinux_2_28_aarch64.whl:

Publisher: publish-pypi.yml on decibri/decibri

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file decibri-0.5.0-cp310-abi3-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for decibri-0.5.0-cp310-abi3-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 b5aa45105835eea440d106d306138fdff38b3b971fef96f06abd229db9d73c70
MD5 58414ef293565fe7a6b2765309d6801a
BLAKE2b-256 888d41b03c0aa27f7f6f4e3a26fb8237ca0456d033edc4a0fe21033e393e7368

See more details on using hashes here.

Provenance

The following attestation bundles were made for decibri-0.5.0-cp310-abi3-macosx_14_0_arm64.whl:

Publisher: publish-pypi.yml on decibri/decibri

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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