Skip to content

Add Earshot VAD (native C++ port) - #1095

Merged
0xShug0 merged 1 commit into
0xShug0:mainfrom
Etherll:earshot-vad
Oct 26, 2026
Merged

0xShug0 merged 1 commit into
0xShug0:mainfrom
Etherll:earshot-vad

Conversation

@Etherll

@Etherll Etherll commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

This PR adds Earshot 1.2.2 by pyke.io (MIT OR Apache-2.0) as earshot_vad, a community VAD family with the alias earshot. Earshot is a small streaming VAD: a 40 KB network scoring 16 ms frames at 16 kHz. This is a native C++ port with no Rust toolchain and no ggml graph. It uses SSE2, AVX2 (picked at runtime) or NEON kernels and a fixed-size real FFT. The weights are bundled as a 48 KB safetensors file, so there is nothing to download.

Letting the other ASR models use any VAD family (and so Earshot) for VAD chunking is a separate PR, #1096. The two PRs do not depend on each other and merge without conflicts.

What changed

  • The code is in src/community_models/earshot_vad, registered through audiocpp_add_model(earshot_vad … ALIASES earshot). The weights are in assets/framework/models/earshot_vad, with upstream's MIT notice. It is a bundled family without a spec, like silero_vad and marblenet_vad, and is listed in BUNDLED_LOADERS_WITHOUT_SPEC. Nothing outside the new family, its docs, its tests and those registrations changes.
  • Offline and streaming VAD sessions:
    • Offline accepts any sample rate and channel count. It converts to 16 kHz mono and maps spans back to input samples.
    • Streaming takes 16 kHz mono chunks of any size and emits SpeechStart / SpeechEnd events. Every segment in the final result has its SpeechStart event.
  • Offline scoring spreads the front end and the convolutions over --threads. The int16 minGRU runs in order.
  • The segmenter is a port of upstream segments.rs, and its defaults match SegmenterOptions::default(). It takes Silero-style option names (threshold, neg_threshold, min_speech_duration_ms, min_silence_duration_ms, speech_pad_ms), plus smoothing_factor, start_delay_ms and keep_trailing_segment. It differs from upstream in two deliberate ways:
    • It keeps a segment that is still open when the audio ends. Upstream drops it, which would lose the last words of an ASR input. keep_trailing_segment=false restores the upstream behaviour.
    • Upstream's iterator skips its frame counter on each frame that returns a segment, so later segments drift 16 ms earlier for each earlier segment. Here every frame is counted.
  • It loads through the model registry, so gigaam_asr, which already loads its VAD that way, can use it today with gigaam_asr.vad_model_path=assets/framework/models/earshot_vad.
  • Docs: docs/models/earshot_vad.md, a README row, a speech-analysis row and a licenses row.
  • Tests and tools:
    • tests/unittests/test_earshot_vad.cpp, registered as earshot_vad_test and as earshot_vad_baseline_test with the SSE2 kernel forced.
    • tests/earshot_vad/probe.cpp.
    • tests/earshot_vad/convert_earshot.py, which regenerates the safetensors byte-for-byte.
    • tests/earshot_vad/reference_rs, a Cargo program pinned to upstream. It is not part of the CMake build.
    • tests/earshot_vad/check_parity.py.

Review follow-ups

A two-lane review of the first version found two issues in this code, both fixed here:

  • A streamed segment could reach finalize() without a SpeechStart event when the stream ended exactly at the minimum duration. The start event now fires on the same rule finish() uses. A new test sweeps the stream end over frames 30–50; it fails on the old code at 41 frames and passes now.
  • check_parity.py --cli crashed on input with no speech, because the CLI writes no segments file then. It now treats a missing file as no segments.

Validation

Build and tests

Platform Build Result
Windows 11, MSVC 19.44 scripts/build_windows.ps1 -Preset windows-cpu-release -RunTests (custom set including earshot_vad) earshot_vad_test and earshot_vad_baseline_test pass. 2 other tests fail: lfm2_audio_assets_test and disk_expert_weight_store_test. They run no VAD code and pass on Linux.
Windows 11, CUDA 12.9, RTX 5090 -Preset windows-cuda-release -RunTests Earshot tests pass. disk_expert_weight_store_test also fails, as above.
WSL Ubuntu 24.04, gcc 13 Same as Linux CI: Debug, full model set, ENGINE_BUILD_TESTS=ON, full ctest All tests pass
Colab, clang 18 Debug, ENGINE_BUILD_TESTS=ON Builds with no warnings in the new code; all tests pass
Colab, gcc 13, CUDA 13, L4 Release, CPU and CUDA builds Earshot tests pass on both

tools/check_loader_catalog_sync.py --self-test and tools/check_loader_catalog_sync.py both pass. The clang and Colab rows are for the first version of this PR; the follow-up changes above touch only the segmenter's start-event rule, a test and the parity script.

Parity with upstream

The upstream Rust reference at pykeio/earshot@ffd32d4 reports the 1.2.2 weights and code, with segments only on main. On every file below, the scores and segments match after allowing for upstream's counter lag. The CLI offline and streaming segments also match the probe.

Files Max per-frame score diff vs Rust
30 TEN VAD test clips 4.4e-05
4 LibriSpeech clips + 2086-149220-0033.wav 3.0e-05
10 min synthetic long-form, 5 dB SNR 6.1e-05
3 s digital silence 0

The PyPI wheel (earshot==1.2.2) differs from the port by at most 4.4e-05 on the TEN set. The frame-by-frame streaming detector gives bit-identical scores to batched offline scoring. Streaming segments match offline for chunk sizes 1, 100, 256 and 4000.

cargo build --release --manifest-path tests/earshot_vad/reference_rs/Cargo.toml
python tests/earshot_vad/check_parity.py --probe build/<preset>/bin/earshot_vad_probe \
  --reference tests/earshot_vad/reference_rs/target/release/earshot_reference \
  --cli build/<preset>/bin/audiocpp_cli <16 kHz mono wavs>

Accuracy

This is frame accuracy on the TEN VAD test set (30 labelled clips) at 10 ms resolution, with every model at its default settings through audiocpp_cli --task vad.

Model Precision Recall F1
silero_vad 0.900 0.974 0.935
earshot_vad 0.893 0.962 0.926
marblenet_vad 0.892 0.948 0.919
firered_vad 0.863 0.978 0.917
pulsevad 0.922 0.905 0.914

Speed

These figures are for 43.7 min of audio on Colab (12-vCPU Xeon @ 2.2 GHz, gcc 13, Release). Each is session.wall_ms from audiocpp_cli --task vad, CPU backend.

Model Threads ms x real time
earshot_vad 1 1,201 2,185
earshot_vad 4 484 5,421
Upstream Rust crate (frame loop) 1 2,311 1,135
marblenet_vad 4 4,586 572
pulsevad 4 5,327 492
firered_vad 4 6,694 392
silero_vad 4 19,526 134

Windows (MSVC, AVX2), 10 min of audio through earshot_vad_probe --bench 5:

Path ms
Upstream Rust, 1 thread 147
Offline, 1 thread 111
Offline, 8 threads 32
Streaming, frame by frame 119

Run commands

audiocpp_cli --task vad --model assets/framework/models/earshot_vad --audio speech.wav --segments-out segments.json
audiocpp_cli --task vad --mode streaming --model assets/framework/models/earshot_vad --audio speech_16k.wav --segments-out segments.json

On the server, a "task": "vad" entry with "family": "earshot_vad" answers POST /v1/tasks/run with segments. This was tested on Windows, including request options.

Known limitations

  • Streaming needs 16 kHz mono chunks, like Silero. Offline handles any rate and channel count.
  • /v1/tasks/stream does not work for VAD models, Silero included. The server's TTFT and event logic only counts text and audio output. This is unchanged here and could be a follow-up.
  • Earshot always runs on the CPU; the selected backend is ignored. It is cheap enough that this does not matter.

Port Earshot 1.2.2 (pykeio/earshot, MIT OR Apache-2.0) as the earshot_vad
community model, alias earshot. Plain C++ with SSE2/AVX2/NEON kernels and a
fixed-size real FFT; no ggml graph. Weights (48 KB safetensors) are bundled
in assets/framework/models/earshot_vad.

- Offline and streaming VAD sessions with an upstream-compatible segmenter;
  keeps a segment still open at the end of the audio and fixes upstream's
  per-segment frame-counter drift. Every streamed segment is announced by a
  SpeechStart event.
- Offline scoring parallelises the front end and convolutions over --threads.
- Loads through the model registry, so gigaam_asr can use it for VAD chunking.
- Converter, upstream Rust reference, parity script, probe and unit tests.

Per-frame scores match the Rust crate and PyPI wheel within 7.5e-5 and
segments match upstream; 1.3-1.9x faster than upstream single-threaded.
@Etherll Etherll changed the title Add Earshot VAD (native C++ port) and let ASR VAD chunking use any VAD family Add Earshot VAD (native C++ port) Oct 25, 2026
@0xShug0

0xShug0 commented Oct 26, 2026

Copy link
Copy Markdown
Owner

@Etherll Thanks for contributing Earshot VAD! PR merged.

I actually tested whether rewriting such a tiny model as a GGML graph could beat native C++, and native C++ won :)

Audio length Native CPU GGML CPU GGML CUDA GGML Vulkan
7.44 s 0.50 ms 1.58 ms 0.59 ms 0.67 ms
59.48 s 3.94 ms 12.37 ms 4.43 ms 4.53 ms

A follow-up PR could use the framework’s FFT helpers with batching to reduce duplicated code and provide a small CPU performance gain. For short requests, the absolute difference is tiny on my machine, but it could be more noticeable on slower CPUs.

Audio Threads Native C++ Framework FFT, batch 8 Performance
7.44 s 1 1.233 ms 1.172 ms 5.2% faster
7.44 s 4 0.502 ms 0.503 ms 0.2% slower
59.48 s 1 10.020 ms 9.454 ms 6.0% faster
59.48 s 4 4.010 ms 3.868 ms 3.7% faster
297.4 s 1 50.779 ms 48.057 ms 5.7% faster
297.4 s 4 20.678 ms 19.638 ms 5.3% faster
594.8 s 1 101.709 ms 96.188 ms 5.7% faster
594.8 s 4 40.820 ms 39.643 ms 3.0% faster

@0xShug0
0xShug0 merged commit 1bbd851 into 0xShug0:main Oct 26, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants