Repository navigation
Add Earshot VAD (native C++ port) - #1095
Merged
Merged
Conversation
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.
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 :)
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.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds Earshot 1.2.2 by pyke.io (MIT OR Apache-2.0) as
earshot_vad, a community VAD family with the aliasearshot. 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
src/community_models/earshot_vad, registered throughaudiocpp_add_model(earshot_vad … ALIASES earshot). The weights are inassets/framework/models/earshot_vad, with upstream's MIT notice. It is a bundled family without a spec, likesilero_vadandmarblenet_vad, and is listed inBUNDLED_LOADERS_WITHOUT_SPEC. Nothing outside the new family, its docs, its tests and those registrations changes.SpeechStart/SpeechEndevents. Every segment in the final result has itsSpeechStartevent.--threads. The int16 minGRU runs in order.segments.rs, and its defaults matchSegmenterOptions::default(). It takes Silero-style option names (threshold,neg_threshold,min_speech_duration_ms,min_silence_duration_ms,speech_pad_ms), plussmoothing_factor,start_delay_msandkeep_trailing_segment. It differs from upstream in two deliberate ways:keep_trailing_segment=falserestores the upstream behaviour.gigaam_asr, which already loads its VAD that way, can use it today withgigaam_asr.vad_model_path=assets/framework/models/earshot_vad.docs/models/earshot_vad.md, a README row, a speech-analysis row and a licenses row.tests/unittests/test_earshot_vad.cpp, registered asearshot_vad_testand asearshot_vad_baseline_testwith 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:
finalize()without aSpeechStartevent when the stream ended exactly at the minimum duration. The start event now fires on the same rulefinish()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 --clicrashed 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
scripts/build_windows.ps1 -Preset windows-cpu-release -RunTests(custom set including earshot_vad)earshot_vad_testandearshot_vad_baseline_testpass. 2 other tests fail:lfm2_audio_assets_testanddisk_expert_weight_store_test. They run no VAD code and pass on Linux.-Preset windows-cuda-release -RunTestsdisk_expert_weight_store_testalso fails, as above.ENGINE_BUILD_TESTS=ON, fullctestENGINE_BUILD_TESTS=ONtools/check_loader_catalog_sync.py --self-testandtools/check_loader_catalog_sync.pyboth 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@ffd32d4reports the 1.2.2 weights and code, with segments only onmain. 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.2086-149220-0033.wavThe 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.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.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_msfromaudiocpp_cli --task vad, CPU backend.Windows (MSVC, AVX2), 10 min of audio through
earshot_vad_probe --bench 5:Run commands
On the server, a
"task": "vad"entry with"family": "earshot_vad"answersPOST /v1/tasks/runwithsegments. This was tested on Windows, including request options.Known limitations
/v1/tasks/streamdoes 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.