Clip auto-trim: the three layers and the VAD detector (#145)
Every sentence clip is cut from a window that three layers narrow in turn. The layers are unchanged by #145; only which detector layer 2 asks changed, plus a wider tail search for ASR-origin cues and a per-clip edge audit so the result stops being a silent success.
| Layer | What it asks | Setting (DB settings table, default ON) |
|---|---|---|
0 word_bounds |
Measured words (words.py): where are this sentence’s words? |
— (present or not) |
1 clamp_tail |
Subtitle arithmetic: never cut into the next cue | assets.trim_tail |
2 trim_silence |
The audio: where are the gaps? | assets.trim_silence |
3 speech_seek |
The envelope: where is the utterance seam? | assets.trim_speech |
Every failure mode of layers 2 and 3 returns the window it was handed, exactly. Manual editor drag pads and the ±0.5 s adjustment pin their edge and are never seeked.
Layer 0: word timestamps win outright (#166)
Section titled “Layer 0: word timestamps win outright (#166)”Layers 1–3 all reason from the cue’s own t0/t1, and those are
display timing. The #145 audit measured the population none of them can
reach: 43 clips continuous to the edge, where the next line’s audio has
already started at the boundary — no gap for layer 2 to find, no level
step for layer 3 to measure.
The probe recognizer has already measured what those layers infer
(words.py: the dense pass after a verified judgement, or one read of
the line and its neighbours when a cut finds it unmeasured — see
subtitle-sync.md).
When segment_word has trusted rows for the candidate’s segments,
clip start = first word start and clip end = last word end; the layers
below then run on that window exactly as they would on a cue’s, keeping
their own pads and margins, and an editor handle still pins its edge.
Layer 1’s neighbour clamp may not cut into a word-derived end — that
clamp exists to undo the seg.t1 == next.t0 convention, and measured
speech is not that convention. A merged continuation run (#38) reads its
start from the anchor segment’s words and its end from the run’s END
segment’s.
Per edge, and only when a span still overlaps the cue it claims to
describe: no words (or a span that has drifted off its cue) is the
pre-#166 behaviour, unchanged. The cut job’s trim payload carries
source — words or cue — plus word_edges when the words decided
one.
Word rows are stated on the video timeline, and every door that moves
what that timeline says about a segment owns them: an applied block shift
(subsync.apply_to_segments) and its revert shift them by the same
amount, a sub_offset_s change shifts them by its delta, and any door
that replaces segment rows (store_segments, store_asr_segments,
subcache.restore, a media delete) deletes them, because a replacement
cannot shift a word onto a row that did not exist when it was measured.
Why the detector changed
Section titled “Why the detector changed”Measured on 104 live clips across 19 media (2026-09-16), with layers 1 and 2 both at their defaults:
| symptom | definition | baseline |
|---|---|---|
cut_end |
speech within 50 ms of the clip’s end | 59/104 (57%) |
hot_start |
speech within 50 ms of the clip’s start | 14 (13%) |
drag_tail |
> 1 s of trailing non-speech | 15 (14%) |
late_start |
> 1 s of leading non-speech | 9 (9%) |
next_line_bleed |
a distinct later utterance at the clip end after a ≥ 0.6 s gap | 12 (12%) |
no_speech |
no speech anywhere in the clip | 12 (12%) |
The design was not the problem. Anime and stream BGM keeps the energy
floor above −35 dB, so ffmpeg silencedetect finds no qualifying
silence, layer 2 returns the layer-1 window exactly as documented, and
that boundary is display timing which routinely sits inside speech. On
5 of 6 spot-checked clips silero hears a 0.52–2.37 s inter-utterance gap
where silencedetect reports nothing at all — twice, nothing in the
whole clip.
Settings
Section titled “Settings”| Key | Default | Meaning |
|---|---|---|
assets.trim_silence_detector |
vad |
vad = silero-vad; energy = the original silencedetect behaviour, exactly |
assets.vad_model |
$AUTOMINER_HOME/models/silero_vad.onnx |
Where the ONNX model lives |
assets.vad_threshold |
0.5 |
Speech probability, clamped to 0.05–0.95 |
assets.vad_min_silence_ms |
200 |
Gap length that separates utterances (matches layer 2’s own SILENCE_MIN_S) |
assets.vad_speech_pad_ms |
0 |
Extra air kept on the speech side. 0 because SILENCE_MARGIN_S (0.1 s) is unchanged and already keeps some there |
assets.trim_asr_tail_window_s |
6.0 |
Tail search width for origin='asr' cues only, clamped to 2–30 s |
SENTENCE_PAD_S, SILENCE_MARGIN_S, MIN_TRIMMED_CLIP_S, the 2 s edge
windows and the editor’s drag pads are untouched.
Installing the model (one operator step)
Section titled “Installing the model (one operator step)”onnxruntime and the model are optional. Without them the detector
falls back to energy with the reason on the job payload, and the cut
still happens — the job never fails for this.
core/.venv/bin/pip install -e 'core[vad]' # onnxruntime (CPU) + numpymkdir -p "$AUTOMINER_HOME/models"curl -Lo "$AUTOMINER_HOME/models/silero_vad.onnx" \ https://raw.githubusercontent.com/snakers4/silero-vad/master/src/silero_vad/data/silero_vad.onnxBoth the v5 (512-sample window + 64-sample context) and v4 (1536) graphs are recognised from the graph’s own input names. Nothing here needs another machine and nothing calls the network at runtime.
The edge audit
Section titled “The edge audit”Each cut measures the window it produced on the same audio the trimmer
read, and stores it on candidate.clip_audit_json: leading/trailing
non-speech, the six symptom flags above, and which detector produced
them. NULL means never measured — not “measured and clean”.
- Per media:
GET /v1/media/{media_id}/clip_audit→ counts, rates and detector mix.measuredcounts clips with an audit. - Per asset job:
trim_detectors,trim_fallbackand theedge_audittallies on the job summary. - A re-cut from the editor re-measures, or clears the numbers when the media has no local audio track to measure against.
These are the regression numbers. The 2026-09-16 run above is the baseline; any future change to trimming is judged against a re-run of the same audit, not against an impression.