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.
✨ 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): aDenoiserinterface (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.
Release files for libspeech 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| libspeech-0.1.0.tar.gz | 167.0 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| libspeech-0.1.0-cp312-cp312-win_amd64.whl | CPython 3.12 | CPython 3.12 | Windows x86-64 | Details |
| libspeech-0.1.0-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.0-cp312-cp312-macosx_13_0_universal2.whl | CPython 3.12 | CPython 3.12 | macOS 13.0+ universal2 (ARM64, x86-64) | Details |
| libspeech-0.1.0-cp311-cp311-win_amd64.whl | CPython 3.11 | CPython 3.11 | Windows x86-64 | Details |
| libspeech-0.1.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.1.0-cp311-cp311-macosx_13_0_universal2.whl | CPython 3.11 | CPython 3.11 | macOS 13.0+ universal2 (ARM64, x86-64) | Details |
| libspeech-0.1.0-cp310-cp310-win_amd64.whl | CPython 3.10 | CPython 3.10 | Windows x86-64 | Details |
| libspeech-0.1.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.1.0-cp310-cp310-macosx_13_0_universal2.whl | CPython 3.10 | CPython 3.10 | macOS 13.0+ universal2 (ARM64, x86-64) | Details |
| libspeech-0.1.0-cp39-cp39-win_amd64.whl | CPython 3.9 | CPython 3.9 | Windows x86-64 | Details |
| libspeech-0.1.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.1.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: 175.5 MB
Release files / libspeech-0.1.0.tar.gz
| Download URL | libspeech-0.1.0.tar.gz |
|---|---|
| Size | 167.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c74826d582ebccfea06974b07d253d6b56af284ced2b0a949ead60cd09455bde
|
|
BLAKE2b-256 checksum How to use checksums |
21e1f2b3164d4b7cc34b7217c7f8c2f37f5a39aadaff728672ab8f866b48ed07
|
| 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.0-cp312-cp312-win_amd64.whl
| Download URL | libspeech-0.1.0-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 5.7 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
06670a4d33c948219e6517cb449328825eba3d0e9442226242a6eda441054e85
|
|
BLAKE2b-256 checksum How to use checksums |
0bbea56595768a2ed71c92269e9a27e4a2fb0b63204745e094f0c2c66afe9512
|
| 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.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | libspeech-0.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 16.6 MB |
| Tags | CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
4706e36c52ebd9d0522889c9e88f9cefe8e4d3eef1c1c9dd039160f5c85aea7b
|
|
BLAKE2b-256 checksum How to use checksums |
050c29b266b2982a76f8fc532cf2e0cdf7bc7cf95c0acaa80022e47832aa2568
|
| 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.0-cp312-cp312-macosx_13_0_universal2.whl
| Download URL | libspeech-0.1.0-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 |
fbb5c87b14680a7803e8b4f6f145212ce526c18f1b888f07189733df89eeaac4
|
|
BLAKE2b-256 checksum How to use checksums |
22c598610c8c06701b50289bca76b5706f36c8a9fcea744553ae9fa14f63e1f0
|
| 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.0-cp311-cp311-win_amd64.whl
| Download URL | libspeech-0.1.0-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 5.7 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
f50d3b07e83fa745d0cabc8298bfe389a1f186bd2f786d697e9fb6ebcbfb30d5
|
|
BLAKE2b-256 checksum How to use checksums |
5b4b80d56d32a3e304efc23d2c93bb5c846e8fcb622c3d1e2f3877962c1a7624
|
| 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.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | libspeech-0.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 16.7 MB |
| Tags | CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
b89c13d50640b7c8e3c28adaa12b89ce7c14dd77347a83af5b778d0640f4c551
|
|
BLAKE2b-256 checksum How to use checksums |
fb962b9ec482807cbda32ee232da82df509298186a993ea3ec4ed467f1d93b4b
|
| 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.0-cp311-cp311-macosx_13_0_universal2.whl
| Download URL | libspeech-0.1.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 |
4d6c7bdf3481f4ca50cea41c69f528b19b05a05e722095557a1562fe6b5e5a28
|
|
BLAKE2b-256 checksum How to use checksums |
ecda2d6f6d01459a709ac8853def0841d9a4b9914254eea87a840391090fe0fc
|
| 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.0-cp310-cp310-win_amd64.whl
| Download URL | libspeech-0.1.0-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 5.7 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
a26d440802fe77411f9f89dffc6d59417dbeeb363fc426eba4ffc2dc87afaad2
|
|
BLAKE2b-256 checksum How to use checksums |
58245711447e16c79c3611d43d43742aff0c26d787e5af142eddcc55653403f3
|
| 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.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | libspeech-0.1.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 16.7 MB |
| Tags | CPython 3.10 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
e5d2dfb195f2cb82512d1bac515510abd177ac1f0fbc467a9b04c4a4feaceb8f
|
|
BLAKE2b-256 checksum How to use checksums |
d5fee1d5cd8ea1dfb0326c1ed88b1339468d53edc536b5159d13b90731e642bf
|
| 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.0-cp310-cp310-macosx_13_0_universal2.whl
| Download URL | libspeech-0.1.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 |
8245d16b98b9d22aa9972be27b7edc010e698a101df1df41c931465778c8d820
|
|
BLAKE2b-256 checksum How to use checksums |
b8c6eebc0e32aa96228ad6c876749181164a9c8ddc5cc99ed23c170ab50ab721
|
| 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.0-cp39-cp39-win_amd64.whl
| Download URL | libspeech-0.1.0-cp39-cp39-win_amd64.whl |
|---|---|
| Size | 5.5 MB |
| Tags | CPython 3.9 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
4f7d8118b000031226571407e566dcef884731ec606ad4798b75dd14cba6b030
|
|
BLAKE2b-256 checksum How to use checksums |
44b98feeb17d2239234fc8d3a0ef8589471377accf2b18c89767be6cf2e647ba
|
| 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.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | libspeech-0.1.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 16.6 MB |
| Tags | CPython 3.9 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
095316d1594739b3fc90178e5a4668ee3028d9ddb51076dfe09cb51e047724af
|
|
BLAKE2b-256 checksum How to use checksums |
bfe5c957da08bd8facd4906e035d06d5b0e1ca56ca8c3b66f44ee823ed50894f
|
| 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.0-cp39-cp39-macosx_13_0_universal2.whl
| Download URL | libspeech-0.1.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 |
1d11c40efe26435080de4a5fb5b2c4d576fbc3c4b910473b6b9c30971f78b6d2
|
|
BLAKE2b-256 checksum How to use checksums |
01bcd1e72346e86ae348b285f533e968921c8e8dfc7e115653ce61d9da2b6bee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|