Jasper VAD v3 — fixed-log frontend, optimized CPU ONNX
Compact ordinary speech VAD, accepting mono 16 kHz audio and producing speech/non-speech logits every 20 ms. This is not speaker-conditioned PVAD, a diarization model, or a speech recognizer. No speaker vector is required.
audio_to_logits.onnx is the complete waveform-input model. It includes the
fixed Fourier frontend as native ONNX STFT plus the optimized FP32 Jasper encoder.
For the separately measured CPU optimization, encoder.onnx and window.npy
also support an external SciPy FFT frontend. Both paths accept raw samples through
infer.py; the standalone encoder graph alone accepts features.
Quick start
Python 3.12 was used for validation. Download the repository, then:
hf download notaneimu/jasper-vad-v3-fixed-log-onnx --local-dir jasper-vad
cd jasper-vad
python -m pip install -r requirements.txt
python verify.py
python infer.py --audio mono_16k.wav --mode offline --backend onnx --output offline.npz
python infer.py --audio mono_16k.wav --mode r320 --backend onnx --output streaming.npz
The CLI rejects stereo or other sample rates; explicitly downmix/resample first. Use floating-point PCM at its normal amplitude scale (approximately -1 to 1), not integer PCM cast to floats without scaling. Do not peak-normalize individual windows. No automatic gain control, denoising, or resampling is included.
Outputs contain probabilities, boolean speech, start_sec, end_sec,
sample_rate, frame_sec, mode, backend, and threshold. The default threshold
is 0.5. These are raw frame decisions, with no duration filtering, gap merging,
hysteresis, or speech padding. For application-level segment settings, see
Recommended postprocessing.
Direct ONNX Runtime, no Python frontend
import numpy as np
import onnxruntime as ort
options = ort.SessionOptions()
options.intra_op_num_threads = 1
options.inter_op_num_threads = 1
options.execution_mode = ort.ExecutionMode.ORT_SEQUENTIAL
options.graph_optimization_level = ort.GraphOptimizationLevel.ORT_ENABLE_ALL
session = ort.InferenceSession(
"audio_to_logits.onnx", sess_options=options,
providers=["CPUExecutionProvider"],
)
# audio: mono float32 array, 16 kHz; N >= 160; all samples valid.
logits, length = session.run(None, {"audio": audio[None].astype(np.float32)})
z = logits[0, :int(length[0])]
e = np.exp(z - z.max(axis=-1, keepdims=True))
speech_probability = e[:, 1] / e.sum(axis=-1)
No Torch or SciPy is needed when directly executing the waveform graph. A runtime
must implement ONNX opset 17, including STFT and reflection Pad. CPU execution
is validated; GPU/mobile execution is not established by this release.
Streaming API
from infer import CpuJasper
model = CpuJasper(backend="onnx", threads=1)
stream = model.stream("r320")
for pcm in packets: # mono float arrays at 16 kHz; arbitrary packet sizes
frame_indices, probabilities = stream.push(pcm)
# Only newly committed frames; timestamps = frame_indices * 0.02.
frame_indices, probabilities = stream.finish() # flush real tail exactly once
Call finish() at end of input. Clip the final frame's end to the real duration
(stream.total / 16000). Create a new session per recording or discontinuity;
never reuse a closed session. Sessions retain a bounded PCM history, without
recurrent state or cached encoder activations. Different transport packet sizes
are internally repacketed to the selected inference step. Actual delivery delays
still depend on how promptly the application supplies packets.
Use backend="fft" / --backend fft for the split FFT-plus-encoder route.
The encoder weights, frame semantics, modes, and postprocessing remain the same.
Recommended postprocessing
For speech segments from recordings, start with the balanced preset below. For live frame decisions or reproducing the quality/latency tables, use raw threshold 0.50. If preserving quiet speech and word edges matters more than false alarms, try threshold 0.40 with the same segment smoothing.
| Use case | Speech threshold | Minimum speech | Merge silence gaps up to | Padding on each side | Short-speech rescue |
|---|---|---|---|---|---|
| Raw / measured baseline | 0.50 | 0 ms | 0 ms | 0 ms | Off |
| Balanced speech segments — starting point | 0.50 | 80 ms | 100 ms | 80 ms | Off |
| Higher-recall speech segments — alternative | 0.40 | 80 ms | 100 ms | 80 ms | Off |
Evidence: the published fixed-log quality table uses the raw preset. The 80/100/80 ms segment recipe and the 0.40 threshold come from earlier original-v3 and fixed-raw evaluations. They are practical starting points for this fixed-log checkpoint, not a newly optimized or fully evaluated fixed-log preset. Lower thresholds and padding can recover speech but also include more nonspeech.
Existing app/decoder parameter names (values in seconds):
{
"threshold": 0.5,
"min_speech_sec": 0.08,
"min_gap_sec": 0.10,
"speech_pad_sec": 0.08,
"short_speech_rescue_frames": 0
}
min_gap_sec is the Dataset processor name; the interval decoder calls the same
setting merge_gap_sec. The raw baseline sets all duration fields to zero. For
the higher-recall alternative, change only threshold to 0.4. Rescue is disabled,
so no rescue threshold needs to be selected. No maximum segment duration is imposed;
add application-specific chunking separately if an ASR backend requires it.
Apply in this order
- Mark frames with
speech_probability >= thresholdand form consecutive runs. A frame is 20 ms; clip timestamps to the real recording duration. - Merge runs separated by silence gaps no longer than 100 ms.
- Remove merged runs shorter than 80 ms. With rescue disabled, brief isolated events are discarded even if their probabilities are high.
- Extend retained runs by 80 ms at each side, bounded by the recording. When adjacent retained runs have a gap shorter than twice the padding, split that gap at its midpoint so padded intervals touch without overlapping.
These settings operate after inference. They do not change logits, model weights, window size, or the 20 ms output cadence. Segment metrics after smoothing must not be presented as the raw frame metrics in the quality table.
Using the supplied runner
infer.py currently writes probabilities and thresholded frame labels; it does
not apply the minimum-duration, gap-merging, or padding rules. For example:
python infer.py --audio mono_16k.wav --mode offline --threshold 0.40 --output frames.npz
This changes the frame threshold only. Apply the segment recipe to the complete
probability sequence in your application. There are no --min-speech, --gap,
or --pad flags in this release. audio_to_logits.onnx also emits raw logits;
postprocessing is an application responsibility and requires no extra neural model.
Streaming and added delay
Do not independently smooth each inference batch: speech and short gaps can cross
batch boundaries. Keep decoder state across push() outputs and flush at
finish(), or concatenate all output frames and apply the recording recipe once.
A live implementation of the segment recipe must wait for speech confirmation and gap closure: an 80 ms minimum corresponds to four consecutive positive frames for an uninterrupted onset; a 100 ms merge gap requires roughly 100 ms of subsequent silence to finalize an offset. These decisions occur when their containing inference batch arrives. A continuing segment with gaps needs corresponding state; the offline merge-before-filter recipe is not equivalent to simply requiring four consecutive positive frames for every segment.
Padding changes reported timestamps; it cannot make the underlying event arrive earlier. Retain pre-roll audio if you need the padded onset. The model's mode table excludes these decoder waits and transport delay. For the lowest extra decoder latency, keep the raw preset; this release has no separately tuned fixed-log causal hysteresis preset, so do not silently inherit Silero's offset threshold or silence rules.
Inference modes
L = real left context, A = newly accepted predictions, R = real future
context, Z = artificial zero samples. Figures are milliseconds, not to scale.
offline: [ whole clip ]
r320: [ L1260 ][ A380 ][ R320 ][ Z940 ] advance 380 ms
r160: [ L1260 ][ A380 ][ R160 ][ Z1100 ] advance 380 ms
lr160: [ L160 ][ A2580 ][ R160 ] advance 2580 ms
| Mode | Step | Nominal input | Real right context | Right zero fill | Steady buffering typical / max | Startup at step-sized packets |
|---|---|---|---|---|---|---|
offline | Whole clip | Whole clip | Whole clip | 0 | Wait for clip | Wait for clip |
r320 | 380 ms | 2900 ms | 320 ms | 940 ms | 510 / 700 ms | 2280 ms |
r160 | 380 ms | 2900 ms | 160 ms | 1100 ms | 350 / 540 ms | 1900 ms |
lr160 | 2580 ms | 2900 ms | 160 ms | 0 | 1450 / 2740 ms | 5160 ms |
These are calculated buffering delays, before CPU inference, transport, and postprocessing. Typical assumes uniformly phased event arrival: step/2 + real right context; the bound is step + real right context. The 20 ms prediction cadence is not the inference-call cadence or end-to-end latency.
offline: one forward over the entire input. Best suited to recorded audio; memory grows with duration. Do not claim chunked processing is identical.r320: the best measured quality/latency balance on the meeting test below.r160: less lookahead; measured error is 0.287 percentage points higher.lr160: compute-saving large batches; suitable when response delay is acceptable. Full meeting-set accuracy has not been measured for this mode.
Machine-readable equivalents of the existing app settings are in
inference_modes.json. In the apps, r320/r160 use nominal left/right contexts
1260/1260 ms, step 380 ms, and right-zero sizes 940/1100 ms. lr160 uses left/right
160/160 ms, step 2580 ms, zero sizes 0/0. These modes do not alter model weights.
First and final windows
Boundary policy is first_last_full, matching the corrected app scheduler:
- Wait for left + step + real right context, rounded up to the next internal packet. The first inference accepts the real left edge rather than discarding it.
- Subsequent calls accept only new centre frames, once each. Startup inputs can exceed 2.9 seconds: 3.22 s for r320, 3.00 s for r160, 5.16 s for lr160.
- At end, recrop the final real window and accept through the recording end. Zero fill must never erase accepted boundary audio. The final incomplete 20 ms cell is zero-padded to the frame boundary; its reported end is clipped.
- Short streams infer once at end. Empty streams return no predictions.
The supplied stream runner covers every real frame exactly once, including
clips shorter than startup and partial final packets. It does not require an
extra all-zero audio packet. Call finish() to signal end of input.
GroupNorm and context
GroupNorm computes statistics across channels within each group and time in that inference window. This is a noncausal model. Its nominal convolutional receptive field does not mean all context outside that field is irrelevant. Changing windows, cropping, zeros, or tail padding can change probabilities. The zeros preserve nominal tensor size but do not reduce encoder FLOPs. They reduce the future audio that must be acquired. lr160 saves compute by forwarding less often, not by shortening its steady input tensor.
Graph and frontend contract
- Batch size 1, float32, all input samples/feature frames valid. There is no lengths input for variable-length batches and no padding mask. Do not batch unequal clips by padding them into a larger tensor.
audio_to_logits.onnx:audiofloat32[1, N], dynamicN >= 160.encoder.onnx:featuresfloat32[1, 129, T], dynamicT >= 1.- Both return
logitsfloat32[1, ceil(T/2), 2]andencoded_lengthint64[1]. Speech class index is 1. Apply softmax across the final axis. - Frontend
T = floor(N/160): 256-sample periodic Hann window, 160-sample hop, 128 samples of reflection padding on each side. Use the shippedwindow.npyfor an external implementation. Keep only the firstfloor(N/160)STFT frames. - Features are
log(sqrt(real² + imag² + 2^-24) + 2^-24)for 129 one-sided bins. No mel projection, dither, or feature normalization. - Native offline output length is
ceil(floor(N/160)/2). For arbitrary nonaligned endings this can omit a sub-10 ms remainder, or the last frame can extend beyond real audio. Clip timestamps to the audio duration. The streaming runner explicitly fills its final 20 ms cell and returnsceil(N/320)frames instead.
Encoder: six Jasper convolutional blocks, depthwise-separable convolutions,
residual connections, GroupNorm with 32 groups, and a two-class decoder. Full
checkpoint configuration is in model_config.json (some fields are inactive).
The training checkpoint reports 164,237 parameters, including the fixed Fourier
frontend; this count is not a trainable-encoder-only count.
CPU optimizations preserve FP32 inference: replace redundant all-valid masks and length-masked GroupNorm bookkeeping; express Conv1d kernels as height-one Conv2d for CPU kernels; use FFT instead of dense Fourier convolution. There is no INT8/ternary quantization. The waveform graph uses ONNX STFT; the split route uses blocked SciPy real FFT. Floating-point arithmetic can differ slightly from the checkpoint's saved Fourier filters.
Quality evidence
Meeting test: 215 held-out YouTube meeting clips, 9664.6427 seconds, with Pyannote speech references (not MFA labels), threshold 0.5, no postprocessing. These are original Torch evaluations through the app, not a full ONNX rerun of all 215 clips.
| Mode | VAD error | Error with 40 ms collar | Speech recall |
|---|---|---|---|
| Offline | 7.2471% | 5.9859% | 91.5446% |
| r320 | 7.2431% | 6.0037% | 91.6122% |
| r160 | 7.5300% | 6.2860% | 91.3160% |
| lr160 | Not measured | Not measured | Not measured |
Error is (false positive seconds + false negative seconds) / scored seconds,
pooled over duration. This is not speaker error rate or diarization error rate.
The small difference between offline and r320 does not establish an improvement.
These modes were explored on this collection, so the collection is not an unseen
final confirmation of the selected operating settings. References are automatic
labels, not a claim of perfect human annotation. Test on your own microphones,
noise, languages, gain levels, and latency requirements.
Both shipped backends were rechecked against PyTorch on all 76 DSR v3 test rows / 85,113 frames: each changed one threshold-0.5 decision (0.0012% of frames). Maximum probability difference was 0.0017621 for split FFT and 0.0017499 for waveform ONNX. On the three-minute recording, waveform ONNX versus the validated split app replay changed zero threshold decisions in r320, r160, and lr160 (maximum probability difference below 0.0000081). These are numerical parity checks, not a new full meeting-set accuracy claim.
validation.json records numerical export checks separately from label quality:
full DSR v3 test checkpoint comparisons, the three-minute streaming comparison,
ONNX structural checks, partial-frame coverage, and packetization tests.
verify.py checks downloaded file hashes and reproducible synthetic reference
outputs. Synthetic checks validate execution/parity, not speech recognition quality.
CPU measurements
The accompanying benchmark.json contains measurements of both shipped backends
on the same resident 180-second mono signal, AMD Ryzen 9 5950X under WSL2, pinned
CPU 2, one inference thread. Three warmups and nine measured replays, interleaved
order. Model loading and file IO are excluded; streaming includes this standalone
runner's buffering and probability assembly. These timings should not be confused
with latency or the earlier app-wrapper timing.
| Mode | Single waveform ONNX CPU | Split FFT + ONNX CPU |
|---|---|---|
| offline | 168.69 ms | 64.41 ms |
| r320 | 1458.04 ms | 717.60 ms |
| r160 | 1462.02 ms | 719.29 ms |
| lr160 | 232.49 ms | 122.06 ms |
The single graph is simpler to deploy; the split FFT route was approximately
2× faster for the streaming modes on this CPU. Both expose waveform input through
the runner. Default backend is onnx; select fft explicitly for the faster path.
For reference, the earlier optimized split-frontend app experiment measured frontend + model CPU totals of 684.34 ms (r320), 683.03 ms (r160), and 104.93 ms (lr160) over three minutes; native stateful Silero ifless ONNX measured 736.71 ms. Those totals exclude differing replay-wrapper overhead and used 17 repetitions. They are not measurements of the new waveform-input ONNX graph.
Apple Silicon Core ML candidates
Core ML packages and native Accelerate frontend are available as an experimental alternative. Flexible encoder-only FP32/FP16 packages keep windowing, context and scheduling in application code; waveform-input packages are also included. Mac compilation, prediction parity and speed are pending; these candidates do not inherit the ONNX validation or timing claims below.
Files, provenance, and scope
audio_to_logits.onnx: waveform-input FP32 ONNX, opset 17.encoder.onnx,window.npy: optimized encoder and window for external FFT.infer.py: standalone offline/streaming implementation and CLI.inference_modes.json,bundle.json,model_config.json: contracts/configuration.provenance.json: checkpoint identity, hashes, epoch, export transformations.validation.json,benchmark.json: validation and timing evidence.verify.py,verification.npz,SHA256SUMS: local download checks.build_waveform_graph.py: deterministically rebuilds the waveform graph from the shipped encoder and window; requiresonnxin addition to runtime deps.
Source: train_dsr_v3_fe20_fixed_log_30ep_20261101/best_vad_error.pt, checkpoint
epoch 30, 74,820 optimizer steps, trained on the internal DSR v3 composition.
The exact checkpoint SHA-256 is recorded in provenance.json. Model selection
used the run's best-VAD-error checkpoint. This release contains inference weights,
not the optimizer state or training audio. It does not alter app defaults.
A redistribution/use license has not been specified for this release.