Skip to main content

LibSpeech Logo

LibSpeech

Lightweight Speech Processing Library

C++ library with Python bindings for audio I/O, DSP, and ONNX-based speech models -- built to install with nothing but pip, no system dependencies (libcurl, OpenSSL, ...) required.

GitHub release License Python Versions C++ Standard

Build Status Code Quality CodeFactor snyk.io PyPI Downloads

✨ Key Features

  • 🚀 ONNX Runtime powered models, without a heavy LibTorch dependency
  • 🎙️ Audio I/O (speech::io): load/save WAV/MP3/FLAC, playback, resample, mono-mixing
  • 🧮 DSP (speech::dsp): Resample, window functions, FFT/IFFT, DCT/IDCT, STFT/ISTFT, MFCC -- all with their own C++ unit tests and Python bindings
  • 🔊 Speech models (speech::models): a Denoiser interface (Facebook/SpeechBrain backends) and Silero VAD
  • 🖥️ Cross-platform: Windows, Linux, macOS
  • 🐍 Python bindings (nanobind) mirroring the C++ API 1:1
  • 📦 Zero system dependencies: no apt install libcurl-dev / OpenSSL needed -- HTTPS model downloads go through a vendored cpp-httplib + Mbed TLS built from source

📦 Installation

Python package

pip install libspeech

From source (C++/CMake)

git clone https://github.com/MohammadRaziei/libspeech.git
cd libspeech
git submodule update --init src/third_party/miniaudio src/third_party/dr_libs src/third_party/indicators

# Mbed TLS is pinned to v3.6.2 and kept as a shallow submodule (see .gitmodules):
git submodule update --init src/third_party/mbedtls
git submodule update --init --depth 1 src/third_party/mbedtls/framework

mkdir build && cd build
cmake ..                      # downloads ONNX Runtime automatically on first configure
cmake --build . -j$(nproc)
ctest                         # runs the full test suite (see "Testing" below)

Only want the DSP layer (no ONNX Runtime/network access needed at all)?

cmake .. -DBUILD_MODELS=OFF
cmake --build . -j$(nproc)

🚀 Quick Start

Python

import libspeech

# --- Audio I/O ---
audio = libspeech.Audio()
audio.load("sample.wav")
mono = audio.to_mono()
resampled = mono.resample(16000)
resampled.save("sample_16k_mono.wav")

# --- DSP ---
mfcc = libspeech.MFCC(libspeech.MFCCParams())
coefficients = mfcc.compute(resampled.data(0))   # [num_frames][num_coefficients]

# --- Speech models ---
denoiser = libspeech.Denoiser.create("facebook", "facebook_denoiser.onnx")
clean = denoiser.process(resampled.data(0))

vad = libspeech.SileroVad()
vad.process(resampled.data(0))
for segment in vad.get_speech_timestamps():
    print(f"speech from {segment.start_s:.2f}s to {segment.end_s:.2f}s")

C++

#include "libspeech/audio.h"
#include "libspeech/dsp/mfcc.h"
#include "libspeech/models/denoiser.h"

speech::io::Audio audio;
audio.load("sample.wav");
auto resampled = audio.to_mono().resample(16000);

speech::dsp::MFCC::Params params;
params.sampleRate = 16000;
speech::dsp::MFCC mfcc(params);
auto coefficients = mfcc.compute(resampled.data(0));

auto denoiser = speech::models::Denoiser::Create("facebook", "facebook_denoiser.onnx");
auto clean = denoiser->process(resampled.data(0));

See examples/ for complete, runnable programs.

🧪 Testing

Tests are organized by language and module (speech_test_<language>_<module>), all discoverable via cmake --build build --target help:

speech_test                       # everything
├── speech_test_cpp
│   ├── speech_test_cpp_dsp       # speech::dsp (C++), no network/ONNX needed
│   └── speech_test_cpp_models    # speech::models (C++)
└── speech_test_python
    ├── speech_test_python_audio  # libspeech.Audio
    ├── speech_test_python_dsp    # libspeech.Resample/FFT/STFT/MFCC/...
    └── speech_test_python_models # libspeech.Denoiser/SileroVad

Run everything with cmake --build build --target speech_test, or just ctest for the same suites without the extra build-tool chatter.

🔧 Architecture

libspeech is split into three independent C++ libraries (each with its own CMake target/namespace/Python module), aggregated by an umbrella speech library:

Namespace CMake target Python module Depends on
speech::dsp speech_dsp speech_dsp_py nothing but a vendored subset of AudioFlux's C sources
speech::io speech_io speech_io_py speech::dsp (for resampling), miniaudio, dr_libs
speech::models speech_models speech_models_py ONNX Runtime, httplib+Mbed TLS (for downloading model weights)

See checklist.md for the detailed, up-to-date state of the project (what's done, what's in progress, known issues), and audioflux_issues.md for a couple of real bugs found in AudioFlux while vendoring it (with repro steps and fixes, in case they're useful upstream).

📊 Benchmarking

benchmarks/ is a fully standalone CMake project (no relationship to the repository root) that fetches libspeech from GitHub via FetchContent, exactly like it would fetch any competitor library -- libspeech is never a special case in there. Mirrors the layout of tests/: one folder per language.

cd benchmarks
cmake -S . -B build-bench -DCMAKE_BUILD_TYPE=Release
cmake --build build-bench --target libspeech_benchmarks

benchmarks/cpp/bench_stft.cpp measures speech::dsp::STFT, specifically to A/B test whether enabling OpenMP's parallel-frame path (LIBSPEECH_ENABLE_OPENMP, on by default) actually helps -- STFT frames are independent so this should scale with core count, but this couldn't be verified in this project's own single-core development sandbox (see checklist.md). If you have a multi-core machine, please run this and report back:

cmake -S . -B build-bench -DCMAKE_BUILD_TYPE=Release -DLIBSPEECH_ENABLE_OPENMP=ON
cmake --build build-bench --target bench_stft && ./build-bench/cpp/bench_stft

cmake -S . -B build-bench -DLIBSPEECH_ENABLE_OPENMP=OFF
cmake --build build-bench --target bench_stft && ./build-bench/cpp/bench_stft

Compare the two avg=...ms numbers -- that's the real effect of enabling OpenMP on your hardware.

🤝 Contributing

We welcome contributions! Please see CONTRIBUTING.md.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

Stars

Metadata

Release files for libspeech 0.2.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 libspeech 0.2.0
File Size Uploaded Provenance
libspeech-0.2.0.tar.gz 169.5 kB Without provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for libspeech 0.2.0
File
libspeech-0.2.0-cp312-abi3-win_amd64.whl CPython 3.12 abi3 Windows x86-64 Details
libspeech-0.2.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 abi3 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
libspeech-0.2.0-cp312-abi3-macosx_13_0_universal2.whl CPython 3.12 abi3 macOS 13.0+ universal2 (ARM64, x86-64) Details
libspeech-0.2.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
libspeech-0.2.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
libspeech-0.2.0-cp311-cp311-macosx_13_0_universal2.whl CPython 3.11 CPython 3.11 macOS 13.0+ universal2 (ARM64, x86-64) Details
libspeech-0.2.0-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
libspeech-0.2.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
libspeech-0.2.0-cp310-cp310-macosx_13_0_universal2.whl CPython 3.10 CPython 3.10 macOS 13.0+ universal2 (ARM64, x86-64) Details
libspeech-0.2.0-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
libspeech-0.2.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
libspeech-0.2.0-cp39-cp39-macosx_13_0_universal2.whl CPython 3.9 CPython 3.9 macOS 13.0+ universal2 (ARM64, x86-64) Details

Total release size: 145.7 MB

Release files / libspeech-0.2.0.tar.gz

Download URL libspeech-0.2.0.tar.gz
Size 169.5 kB
Tags Source
SHA-256 checksum
How to use checksums
4f70825cbf3f2f4e9f9cfe3726b5edcf6f7ee98548987c630aae49b0647e519c
BLAKE2b-256 checksum
How to use checksums
8cd036cc3ff7656618c3ab464121647ec3aa1d6eee3c7fca545d2f220744c802
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / libspeech-0.2.0-cp312-abi3-win_amd64.whl

Download URL libspeech-0.2.0-cp312-abi3-win_amd64.whl
Size 5.7 MB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
707a3aa56d6b92c72582eb82abda43f9cacc72ecc4a104a127811dbc74dd0cfa
BLAKE2b-256 checksum
How to use checksums
19d38f5534438f8531e13500f2a54b07d59457f4cdd99838ff90cdbe64bcbb3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / libspeech-0.2.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL libspeech-0.2.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 9.2 MB
Tags CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
c40395bcbed09fc08db51456073b0a3f80db9790ccd88135eef0ac5929ec1d2f
BLAKE2b-256 checksum
How to use checksums
c3f034858d47719318ae70b17f16670debb92d29be62a79de8a95b34c8f74857
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / libspeech-0.2.0-cp312-abi3-macosx_13_0_universal2.whl

Download URL libspeech-0.2.0-cp312-abi3-macosx_13_0_universal2.whl
Size 21.5 MB
Tags CPython 3.12 abi3 macOS 13.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
55e9e9a3c95b864f13a3e0c09a00e3506e85082b03fc0a874d704267e9132af2
BLAKE2b-256 checksum
How to use checksums
e8e8664fe0a5e1a5c2089ed31c77e00016ef436bd7cd579571223775fca5b8b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / libspeech-0.2.0-cp311-cp311-win_amd64.whl

Download URL libspeech-0.2.0-cp311-cp311-win_amd64.whl
Size 5.7 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
a34fe7a2570228a6a15d11d225afb266f16a22c177b41743386d500a65c0f91a
BLAKE2b-256 checksum
How to use checksums
e450c927fcdcee1d449b33dbaea83c06a84fefc97a6de47fd17519fadcd5c777
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / libspeech-0.2.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL libspeech-0.2.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 9.2 MB
Tags CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
21a8a8fa40a8c19604dff97a8c1ffa4a3d06062b7c5f60850fffca0792d95df5
BLAKE2b-256 checksum
How to use checksums
2faeb2240c0f9998ac4a4d7952f33dbf5c10c61542975edc3c7bb09c3ce592e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / libspeech-0.2.0-cp311-cp311-macosx_13_0_universal2.whl

Download URL libspeech-0.2.0-cp311-cp311-macosx_13_0_universal2.whl
Size 21.5 MB
Tags CPython 3.11 macOS 13.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
2c4f76d4ecd9d3463d5a0a6ead398e86ec55ce14cdeef0aa00781e852a919b55
BLAKE2b-256 checksum
How to use checksums
1f4ff85d745b40f491caf9ab989513aff90b50503cf0a4258dd6584bcb5f7a50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / libspeech-0.2.0-cp310-cp310-win_amd64.whl

Download URL libspeech-0.2.0-cp310-cp310-win_amd64.whl
Size 5.7 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
6a689c5062353a6b11838eca6cccb90ef51b2ce2b3c0ca2f833e4b52b6065849
BLAKE2b-256 checksum
How to use checksums
cd3d945435bb8e225b533b9dc35b964d422c453addbd1c19392d00c770a5ca7f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / libspeech-0.2.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL libspeech-0.2.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 9.2 MB
Tags CPython 3.10 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
a60065795fbd4da1f8d70402b09a9c5fb3fcfe43fa9966c3f96160fae037a852
BLAKE2b-256 checksum
How to use checksums
d1b01c361c9f3d16a2d71872f0f34cedcfc2d5ac41c61b794e8ea692ab375ba3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / libspeech-0.2.0-cp310-cp310-macosx_13_0_universal2.whl

Download URL libspeech-0.2.0-cp310-cp310-macosx_13_0_universal2.whl
Size 21.5 MB
Tags CPython 3.10 macOS 13.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
364052324ec242f3cce2ad8f56a514b92868e466b1286e79647f691374daecb9
BLAKE2b-256 checksum
How to use checksums
9036e94d2fad7f88dea7769923942f07bc657dc214e9e45c6aa69fbc2ea37e2f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / libspeech-0.2.0-cp39-cp39-win_amd64.whl

Download URL libspeech-0.2.0-cp39-cp39-win_amd64.whl
Size 5.5 MB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
a99533f6ff33ef900d98d7c7e528610e01478277cd66bc37c101786511a4a031
BLAKE2b-256 checksum
How to use checksums
b53784956c5e2a04d5ffae6e2697b5adb1fa80dc059fee0b57764ae5948fa5c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / libspeech-0.2.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL libspeech-0.2.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 9.2 MB
Tags CPython 3.9 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
a98c531e4a1c9d1d921a17758f382b24f24b38dcfe5f4f61a65bf07fe8419c01
BLAKE2b-256 checksum
How to use checksums
70a3dff82f8ebee76dfd618be5e6d6071eb2b2ceacf63ab5289268b47eb7d6ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / libspeech-0.2.0-cp39-cp39-macosx_13_0_universal2.whl

Download URL libspeech-0.2.0-cp39-cp39-macosx_13_0_universal2.whl
Size 21.5 MB
Tags CPython 3.9 macOS 13.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
e72e8749e15c44bf4292a0e2765b25ca0f4251295688a58c973f829cba3ffe11
BLAKE2b-256 checksum
How to use checksums
43de1151f2da27b9c29c0a05a960b97a8cf6f3abfddf2db3aa3b9a937ac44470
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for libspeech 0.2.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