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 httpp (pip install httpp), a separately-installed package with its own prebuilt HTTP(S) client and progress bar

📦 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

# speech::models (BUILD_MODELS=ON, the default) needs httpp on
# CMAKE_PREFIX_PATH for model downloads (HTTPS client + progress bar) --
# no more Mbed TLS/libcurl to build, just:
pip install httpp

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.

Docs & coverage

cmake .. -DBUILD_DOCS=ON && cmake --build . --target speech_docs   # Doxygen HTML -> build/docs/out/html

Coverage follows the same layout as ctoon: one target per component, a merged total, and a dashboard tying the reports together.

cmake .. -DBUILD_PYTHON=ON -DBUILD_COVERAGE=ON   # + `pip install coverage`, lcov/genhtml on PATH
cmake --build . --target speech_coverage         # everything below, then the merge + dashboard
Target Covers Output (under build/coverage/)
speech_coverage_cpp_dsp speech::dsp (utest.h suite) cpp_dsp/
speech_coverage_cpp_models speech::models + download utils cpp_models/
speech_coverage_python the Python package's .py files (coverage.py) python/
speech_coverage_total lcov merge of all of the above total/

Open build/coverage/index.html for the dashboard. Each component (and the total) also leaves a plain coverage.lcov next to its HTML, which is what CI uploads to Codecov. BUILD_COVERAGE is off by default: it instruments speech_dsp/speech_models with --coverage, which you don't want in a normal build. Without BUILD_PYTHON you just get the C++ components.

🔧 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
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.3.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.3.0
File Size Uploaded Provenance
libspeech-0.3.0.tar.gz 190.5 kB Without provenance Details

Built distributions (wheels)

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

Release files / libspeech-0.3.0.tar.gz

Download URL libspeech-0.3.0.tar.gz
Size 190.5 kB
Tags Source
SHA-256 checksum
How to use checksums
4af05a3413af23816f31a1a29962486965f7546ee1727ce9a1340875eb3f0533
BLAKE2b-256 checksum
How to use checksums
cd9abe53800fe3c7f0cccfed9e4fdc3964fca93961a674a6129345bfe4ae7f02
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.3.0-cp312-abi3-win_amd64.whl

Download URL libspeech-0.3.0-cp312-abi3-win_amd64.whl
Size 5.6 MB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
ec4691125a35060cb1afde8ef47634daa65f267ede163bca524010fca22e6862
BLAKE2b-256 checksum
How to use checksums
5b29a5d5791f2bfed6a8711dafe3a86e24a4af916f664dd28df514b106115ce9
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.3.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL libspeech-0.3.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 9.0 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
052faa6beaf041cab9529f7fe5f069c7270713e1cb7579cc9f690967b86fa776
BLAKE2b-256 checksum
How to use checksums
be12127ebc2ecb1324e2f3b90f23621a56c0d1ff42d2f5ff9e3e88a531a01754
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.3.0-cp312-abi3-macosx_13_0_universal2.whl

Download URL libspeech-0.3.0-cp312-abi3-macosx_13_0_universal2.whl
Size 21.2 MB
Tags CPython 3.12 abi3 macOS 13.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
a05d6a34d53eeaabdbfd35be009d8ad64653c20723f7e43cb3d0631d9add293c
BLAKE2b-256 checksum
How to use checksums
a3fe8acd909738f99197e2b0256deb920163f350125f7ddaf3ee358a66c86c8a
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.3.0-cp311-cp311-win_amd64.whl

Download URL libspeech-0.3.0-cp311-cp311-win_amd64.whl
Size 5.7 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
bb4a3dec5399d28811a40c9a5937be1621142c7fe86a1676447c744567db2305
BLAKE2b-256 checksum
How to use checksums
7fe02d5a9cb4657c23d1c0b5dea98e3ab5bbb85fa8ba90cf683692be5194b4ff
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.3.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL libspeech-0.3.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 9.1 MB
Tags CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
8c30793be8881b6fab4e252c453c659c0ebaeb8dcf7e2ccb96df91f6ea31eed1
BLAKE2b-256 checksum
How to use checksums
73292700ffc6c7fd87fb122cdabe1fbadea34c7281c834608f50c06801d6af78
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.3.0-cp311-cp311-macosx_13_0_universal2.whl

Download URL libspeech-0.3.0-cp311-cp311-macosx_13_0_universal2.whl
Size 21.2 MB
Tags CPython 3.11 macOS 13.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
2bd5a89a0595bf1adaa8e8f85c7e30640eceb1307bb90d70e4d71cf0572fc947
BLAKE2b-256 checksum
How to use checksums
aaab87448b9f6ce881dda64321b3eb212cbc8b81d15eb113665d613adac137d6
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.3.0-cp310-cp310-win_amd64.whl

Download URL libspeech-0.3.0-cp310-cp310-win_amd64.whl
Size 5.6 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
620f4d7e36a539a663260b00b56b13f94b01c763038b41e45c27f7991f1d5757
BLAKE2b-256 checksum
How to use checksums
add599341f46abd5c7400955ebc5b4289dac23a2e67ed1588641d5315e479d32
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.3.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL libspeech-0.3.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 9.1 MB
Tags CPython 3.10 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
be107bc5bc3671a87a71c773b757607ff6b005b4ecadc4af631495fc7a4b61c5
BLAKE2b-256 checksum
How to use checksums
b2eacfdb9307036fb3ddb8d46115714152b234db6a21b46dfd917aa06c9e30a3
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.3.0-cp310-cp310-macosx_13_0_universal2.whl

Download URL libspeech-0.3.0-cp310-cp310-macosx_13_0_universal2.whl
Size 21.2 MB
Tags CPython 3.10 macOS 13.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
344f828690fad491a68fdeff2e3daa250fc9c1bbdc2e5f32f2044701e58f69f6
BLAKE2b-256 checksum
How to use checksums
6db092bf41161a59f8195e529b66102a60eb4848a03bfbd7a246740636c83400
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.3.0-cp39-cp39-win_amd64.whl

Download URL libspeech-0.3.0-cp39-cp39-win_amd64.whl
Size 5.5 MB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
8e2f6f9edb89785693535bdaf1a69819fe0405d1d87b88b4617c6101fc3d66bc
BLAKE2b-256 checksum
How to use checksums
c64d931e061286aaf27815aefa0a9f6e62d1437d5207c17bec51f48934b11bb6
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.3.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL libspeech-0.3.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 9.0 MB
Tags CPython 3.9 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
6f43a862f166826c2dc0b65fa8fe61cfbef856a94d3fdbcdd6f25ed954ab5dbb
BLAKE2b-256 checksum
How to use checksums
74428cc9715c28cabb7a4b4464d4bb0f9ddccce6c2b5deed18a6f8bda27760e7
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.3.0-cp39-cp39-macosx_13_0_universal2.whl

Download URL libspeech-0.3.0-cp39-cp39-macosx_13_0_universal2.whl
Size 21.1 MB
Tags CPython 3.9 macOS 13.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
d63afca0c1948be2de0f4c318982ff8d08368bfc1e4d829e81045f45a2f74ff0
BLAKE2b-256 checksum
How to use checksums
5892f9de02dcb1fce11b94d853012d077289818b874e37186fb5c4dd47ad1c2c
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.3.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