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.1.1

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.1.1
File Size Uploaded Provenance
libspeech-0.1.1.tar.gz 167.7 kB Without provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for libspeech 0.1.1
File
libspeech-0.1.1-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
libspeech-0.1.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
libspeech-0.1.1-cp312-cp312-macosx_13_0_universal2.whl CPython 3.12 CPython 3.12 macOS 13.0+ universal2 (ARM64, x86-64) Details
libspeech-0.1.1-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
libspeech-0.1.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
libspeech-0.1.1-cp311-cp311-macosx_13_0_universal2.whl CPython 3.11 CPython 3.11 macOS 13.0+ universal2 (ARM64, x86-64) Details
libspeech-0.1.1-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
libspeech-0.1.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
libspeech-0.1.1-cp310-cp310-macosx_13_0_universal2.whl CPython 3.10 CPython 3.10 macOS 13.0+ universal2 (ARM64, x86-64) Details
libspeech-0.1.1-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
libspeech-0.1.1-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
libspeech-0.1.1-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.1.1.tar.gz

Download URL libspeech-0.1.1.tar.gz
Size 167.7 kB
Tags Source
SHA-256 checksum
How to use checksums
7ad7cc5d2657d42216f623c04e62064bebc141521182eb12927c4f971c2b3f44
BLAKE2b-256 checksum
How to use checksums
4d9256a96adef4a14355d83d7542c5e022f912a3feba9fb9c9c85d0d956be6ae
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.1.1-cp312-cp312-win_amd64.whl

Download URL libspeech-0.1.1-cp312-cp312-win_amd64.whl
Size 5.7 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
0fc58a16c4c1ca0cfad0ae8dd07273d5f7544405d49d85f8d1d2eaffc8289a5e
BLAKE2b-256 checksum
How to use checksums
8bfbd58522ae47a093ebff0d947241f8fbc678abe89f905612e38b8dbec4b753
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.1.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL libspeech-0.1.1-cp312-cp312-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
SHA-256 checksum
How to use checksums
8d7b4848100f88595a4185c457e3662a3264d50f98d945ad14ba83859aa9e8fc
BLAKE2b-256 checksum
How to use checksums
1cacbfa8c5484c1f3cbbd8984462ac3405e3ac9804a4fcd3b54d22be4dcda594
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.1.1-cp312-cp312-macosx_13_0_universal2.whl

Download URL libspeech-0.1.1-cp312-cp312-macosx_13_0_universal2.whl
Size 21.5 MB
Tags CPython 3.12 macOS 13.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
511733288f6ebec224d5dc10e48714cb529eac395416d0292594af431df27b9c
BLAKE2b-256 checksum
How to use checksums
f30cf7166cac9e5fa4d2f2eef1e98777b089d4e02bfa841738b20cb625b02cfc
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.1.1-cp311-cp311-win_amd64.whl

Download URL libspeech-0.1.1-cp311-cp311-win_amd64.whl
Size 5.7 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
6a44c380d6fc54f209731b81362cf9012b891a10f25c8e166142790912be5fba
BLAKE2b-256 checksum
How to use checksums
445eed1c518cd3efaa1967c3f187fbd35339f5e615edc6d72e12f7cf7611cf32
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.1.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL libspeech-0.1.1-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
9d8b9328e6ebec6a9e8452b0e1b918b5a31681b538705a38778f0c41e889fad7
BLAKE2b-256 checksum
How to use checksums
e4250a6e3bcbe95560b573ab51f5e8aecaaabb003c90c597ef0e120ee3712766
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.1.1-cp311-cp311-macosx_13_0_universal2.whl

Download URL libspeech-0.1.1-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
b28a2e14518df48d5b935337ca997903e3b94db2d06be10067656bff00d7b664
BLAKE2b-256 checksum
How to use checksums
8cbd8859db4cec550cee88369737370fcb3aba492499b4b3afc54764b00aee5c
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.1.1-cp310-cp310-win_amd64.whl

Download URL libspeech-0.1.1-cp310-cp310-win_amd64.whl
Size 5.7 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
0833da12bfa66c8913f6a0f426880454589e66920079658cc753678c758f3efd
BLAKE2b-256 checksum
How to use checksums
d37fd84f19861b5c6fc02601256fe672c042fa20f1c7de2220e9e3d5e1ff1574
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.1.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL libspeech-0.1.1-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
82cd6635b37d81325b949a3bf39fe30f693fb800808d488819f60f97d05197b9
BLAKE2b-256 checksum
How to use checksums
0884d7f792329e0c9d53bf75d6053f53eeb3e20ae11748c73475ce065943b51c
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.1.1-cp310-cp310-macosx_13_0_universal2.whl

Download URL libspeech-0.1.1-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
0385fc0d8ce07c3ae76e08e56b05578a3733e15348cdac14e76793ed5731e834
BLAKE2b-256 checksum
How to use checksums
eabd500a520c87254d3cac8cc5ef06e3692389edbb4eef44d72c4b54fd5f443c
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.1.1-cp39-cp39-win_amd64.whl

Download URL libspeech-0.1.1-cp39-cp39-win_amd64.whl
Size 5.5 MB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
68909b100c56e266f62046f1070da02cc2a9db436c037e41f75594ab42373441
BLAKE2b-256 checksum
How to use checksums
ac17275ad8062315b9fa9b046476e02429f346afc9c8e2b6ade52c81d5119fcd
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.1.1-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL libspeech-0.1.1-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
ac51536d4ea99aa42793be747c82619cb077767163a7fba5f1ea62c790a427ef
BLAKE2b-256 checksum
How to use checksums
438b11125f8c3c1f59c60fff288fc09a73539de320faaef1dddec44815724b6b
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.1.1-cp39-cp39-macosx_13_0_universal2.whl

Download URL libspeech-0.1.1-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
115634157df93368e60d8f122bc5544da5df12e922f759f62caec73bab1913ef
BLAKE2b-256 checksum
How to use checksums
a09891a6aabd54ec30d598102df86d192882579abdec082f8d7b328a09f744bb
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.1.1

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