commit c9eb780daf142d39a0b89f026d5ebd69eb6338ea
parent e2c1a9c767b9e9fe27512701f1f5d5927baec926
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Mon, 19 Oct 2026 00:59:35 -0400
docs: the clip finder -- cli.md (clips, --seed reactions), report-video.md "Highlights", FACTS (reactions.json, assist, scans), AUDIO_TAG_* in ENVIRONMENT.md, CHANGELOG (release 35 C1)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
6 files changed, 175 insertions(+), 1 deletion(-)
diff --git a/ENVIRONMENT.md b/ENVIRONMENT.md
@@ -109,6 +109,10 @@ Tokens, credentials and knobs a running process reads. Most configuration is not
| `VOICE_MATCH_PYTHON` | `settings.diarization.python`, else `<repo>/.diarize/env/bin/python` | The program that runs the speaker-embedding script for a montage's voice match: the diarization venv's python. Any program that takes the script's arguments will do; the e2e suite runs the test kit's fake embedder with `node`. | common/lib/montage/voiceMatch.mjs (`umtool voice-match`) |
| `VOICE_MATCH_SCRIPT` | `<repo>/scripts/speaker-embed.py` | The speaker-embedding script (WAV segments in, L2-normalised embeddings out, JSON). The e2e suite points it at `common/testing/audio/fakeSpeakerEmbed.mjs`. | common/lib/montage/voiceMatch.mjs (`umtool voice-match`) |
| `VOICE_MATCH_MODEL` | `settings.diarization.embModel`, else `<repo>/.diarize/models/titanet.onnx` | The speaker-embedding ONNX model for the voice match: TitaNet-small, the same file the diarization lane loads. | common/lib/montage/voiceMatch.mjs (`umtool voice-match`) |
+| `AUDIO_TAG_PYTHON` | `settings.diarization.python`, else `<repo>/.diarize/env/bin/python` | The program that runs the audio-tagging script for the clip finder's laugh scan: the diarization venv's python (sherpa-onnx). Any program that takes the script's arguments will do; the tests run the test kit's fake tagger with `node`. | common/lib/clips/scan.mjs (`umtool clips analyze`) |
+| `AUDIO_TAG_SCRIPT` | `<repo>/scripts/audio-tag.py` | The audio-tagging script (WAV files in, per-window class probabilities out, JSON). The tests point it at `common/testing/audio/fakeAudioTag.mjs`. | common/lib/clips/scan.mjs (`umtool clips analyze`) |
+| `AUDIO_TAG_MODEL` | `<repo>/.diarize/models/sherpa-onnx-ced-mini-audio-tagging-2024-04-19/model.int8.onnx` | The audio-tagging ONNX model for the laugh scan: CED-mini (AudioSet's 527 classes). Absent, the scan keeps each window's level only and the laughs come from the transcript and the host's wordless bursts. | common/lib/clips/scan.mjs (`umtool clips analyze`) |
+| `AUDIO_TAG_LABELS` | `class_labels_indices.csv` beside the model | The model's class labels file. | common/lib/clips/scan.mjs (`umtool clips analyze`) |
| `DIARIZE_SEG_MODEL` | — (required) | Segmentation model. The editor passes the settings' value as a flag. | scripts/diarize.mjs |
| `DIARIZE_EMB_MODEL` | — (required) | Speaker-embedding model. The editor passes the settings' value as a flag. | scripts/diarize.mjs |
| `DIARIZE_THRESHOLD` | `0.5` | Clustering threshold. | scripts/diarize.mjs |
diff --git a/common/lib/envVars.ts b/common/lib/envVars.ts
@@ -145,6 +145,10 @@ const DECLARED: EnvVarDecl[] = [
{ name: "VOICE_MATCH_PYTHON", audience: "runtime", default: "`settings.diarization.python`, else `<repo>/.diarize/env/bin/python`", readBy: "common/lib/montage/voiceMatch.mjs (`umtool voice-match`)", doc: "The program that runs the speaker-embedding script for a montage's voice match: the diarization venv's python. Any program that takes the script's arguments will do; the e2e suite runs the test kit's fake embedder with `node`." },
{ name: "VOICE_MATCH_SCRIPT", audience: "runtime", default: "`<repo>/scripts/speaker-embed.py`", readBy: "common/lib/montage/voiceMatch.mjs (`umtool voice-match`)", doc: "The speaker-embedding script (WAV segments in, L2-normalised embeddings out, JSON). The e2e suite points it at `common/testing/audio/fakeSpeakerEmbed.mjs`." },
{ name: "VOICE_MATCH_MODEL", audience: "runtime", default: "`settings.diarization.embModel`, else `<repo>/.diarize/models/titanet.onnx`", readBy: "common/lib/montage/voiceMatch.mjs (`umtool voice-match`)", doc: "The speaker-embedding ONNX model for the voice match: TitaNet-small, the same file the diarization lane loads." },
+ { name: "AUDIO_TAG_PYTHON", audience: "runtime", default: "`settings.diarization.python`, else `<repo>/.diarize/env/bin/python`", readBy: "common/lib/clips/scan.mjs (`umtool clips analyze`)", doc: "The program that runs the audio-tagging script for the clip finder's laugh scan: the diarization venv's python (sherpa-onnx). Any program that takes the script's arguments will do; the tests run the test kit's fake tagger with `node`." },
+ { name: "AUDIO_TAG_SCRIPT", audience: "runtime", default: "`<repo>/scripts/audio-tag.py`", readBy: "common/lib/clips/scan.mjs (`umtool clips analyze`)", doc: "The audio-tagging script (WAV files in, per-window class probabilities out, JSON). The tests point it at `common/testing/audio/fakeAudioTag.mjs`." },
+ { name: "AUDIO_TAG_MODEL", audience: "runtime", default: "`<repo>/.diarize/models/sherpa-onnx-ced-mini-audio-tagging-2024-04-19/model.int8.onnx`", readBy: "common/lib/clips/scan.mjs (`umtool clips analyze`)", doc: "The audio-tagging ONNX model for the laugh scan: CED-mini (AudioSet's 527 classes). Absent, the scan keeps each window's level only and the laughs come from the transcript and the host's wordless bursts." },
+ { name: "AUDIO_TAG_LABELS", audience: "runtime", default: "`class_labels_indices.csv` beside the model", readBy: "common/lib/clips/scan.mjs (`umtool clips analyze`)", doc: "The model's class labels file." },
{ name: "DIARIZE_SEG_MODEL", audience: "runtime", default: "— (required)", readBy: "scripts/diarize.mjs", doc: "Segmentation model. The editor passes the settings' value as a flag." },
{ name: "DIARIZE_EMB_MODEL", audience: "runtime", default: "— (required)", readBy: "scripts/diarize.mjs", doc: "Speaker-embedding model. The editor passes the settings' value as a flag." },
{ name: "DIARIZE_THRESHOLD", audience: "runtime", default: "`0.5`", readBy: "scripts/diarize.mjs", doc: "Clustering threshold." },
diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md
@@ -1,6 +1,7 @@
# Changelog
## [Unreleased]
+- **umtool proposes highlights from a long recording.** Create → **Highlights from a recording** (or the new-project form's seed "highlights", or `umtool new <slug> --seed reactions --from <channel>/<id> --target 600`) takes a stream or podcast whose speakers the editor has found (its diarization) and proposes clips: each runs from the line that set it up, through the host's laugh or comment, to the next pause. The host is the speaker who interjects all the way through (you can say otherwise: `--host N`, or the clip editor's "This is the host"). Laughs are heard by a small local sound model (CED-mini, installed under `.diarize/models/`), and without it read from the transcript ("[laughter]", "haha") and the host's loud wordless moments. The clips are ranked into the target length, put in the video manifest in time order with hard cuts, and each is marked as proposed by the assistant, with its score and why; the rest stay listed in `reactions.json` beside the manifest to bring in by hand. `umtool clips analyze <project>` runs the scans on the recording's sound (a few minutes for a 2.5-hour stream, kept for the next run) and proposes again; `umtool clips propose` proposes again after a change of host or length, and never moves or removes a clip you edited, ruled, locked or added. A recording with no diarization is refused with the command that makes it. Nothing calls an AI model, and nothing leaves the machine. Needs a restart of umtool.
- **The report-video test suite passes in the Docker image.** Run inside `archilyzer:r33-umtool` (Debian's ffmpeg 7.1), six report-to-video tests failed that pass on a newer ffmpeg. Four came from how the tests drove ffmpeg, not from the videos it renders: they now run the graphs the way a build does. One compared against an older ffmpeg's timing drift, which 7.1 does not show; it is now only checked where the drift happens. The sixth needs a git checkout, which an image does not include, and now says so and skips. Nothing a build renders changed.
- **umtool scores who is speaking in each montage clip.** A montage's clip deck and its Cut tab have **Score the voices**: each clip's phrase (and a second either side, its speech only) is compared with the host's voice, and every Cut-tab row then reads `voice 0.43 · unsure` — likely, unsure or unlikely him — and the deck puts the doubtful clips first with their scores. The host's voice is the clips you ruled keep in the audition deck once there are three, or before that solo uploads of the channel found on disk (captioned, no speaker change in the captions, not a stream, no guest in the title, spread over the years); the picker beside the button chooses. It runs on this machine with the speaker model the diarization lane already uses — no network, no AI model — and takes about half a minute for 73 clips. It sorts and flags; whether it is him is still decided by ear. The scores are kept in `voice-match.json` beside the manifest, by the source moment, so a re-seeded montage keeps them. The same from a terminal: `umtool voice-match <project>`. Needs a restart of umtool.
- **A montage's closing wall is the right length on older ffmpeg.** With ffmpeg 7.1 (the umtool Docker image), a tile did not hold its last frame after saying its phrase and did not wait for its turn, so the wall came out short of the length its plan gives (23 frames on the test cut) and, with groups, tiles vanished instead of freezing. The tiles now hold and wait on ffmpeg 7.1 as they do on newer versions; renders on the newer ffmpeg are unchanged.
diff --git a/plans/FACTS.md b/plans/FACTS.md
@@ -10600,3 +10600,55 @@ parsed to 0 cues, indexing the video textless) is CLOSED by `200a3105` (transcri
run and by the next. Engine: `VOICE_MATCH_PYTHON` / `_SCRIPT` / `_MODEL` (ENVIRONMENT.md), else
`settings.diarization.python` / `.embModel` (read from `SETTINGS_FILE` or `<repo>/settings.json`), else `.diarize/`.
The e2e runs `common/testing/audio/fakeSpeakerEmbed.mjs` with node.
+
+## Release 35 lane C1: the clip finder — reactions.json, the assist key (verified 2026-10-19, branch `r35/clip-analysis`)
+
+- **`<project>/reactions.json`** `{version: 1, source {channel, video, duration, words: "words.json" | null, wordsFrom
+ "words.json"|"transcript.json"|"cues"|<--words basename>, diarization {generatedAt, engine}, audio?, audioKind?},
+ params {target 600, laughMin 0.25, mergeGap 6, setupMax 20, clipMax 75}, speakers [{index, role "host"|"subject"|
+ "other", label "Host"|"Subject"|"Speaker N+1", seconds, turns, how "auto"|"operator", sameAs?}], turns [{start, end,
+ speaker}], laughs [{start, end, score, speaker: n|null, src? "text"|"energy"}], moments [{id m001…, t, end, kind
+ "laugh"|"comment", score, speaker: n|null, text}], proposals [{id p001…, start, end, score, moments[], used, clipId
+ "r001"|null, why}], laughSource "model"|"text"|"text+energy", scans {laughs {model, windows, madeAt} | null, voices
+ {model, madeAt} | null}, madeAt, proposedAt, rolesChangedAt?}`. The plan's shape (plans/release-35/clip-finder.md)
+ plus the optional keys `wordsFrom`, `audio*`, `sameAs`, `src`, `laughSource`, `scans`, `madeAt`, `proposedAt`,
+ `rolesChangedAt`, and `speaker: null` on a laugh/moment heard in no turn. Writers: `writeReactions` (tmp + rename,
+ whole) from the analysis, and `setSpeakerRole(dir, index, role|null)` (the clip editor's only write): role +
+ `how: "operator"`, every OTHER speaker that held that host/subject role → "other"/auto (one host, one subject; a
+ `sameAs` of this one keeps it); null hands it back (`how: "auto"`); stamps `rolesChangedAt`. Module
+ `yt-dlp-transcript-common/lib/clips/reactions.mjs` (also `readReactions`, `operatorRoles`, `REACTIONS_FILE`).
+- **The manifest clip's `assist`** `{by "assistant"|"operator", proposal?, score? 0..1, why?, original? {start, end,
+ cutStart, cutEnd}, edits? [{at ISO, by, what "trim"|"split"|"merge"|"add"|"restore", from?, to?}]}`;
+ `validateAssist(manifest)` (`lib/clips/assist.mjs`) runs in report-to-video's build validators and lint
+ (`validatorErrors`) and in umtool's manifest writer's structure checks; unknown keys inside `assist` are allowed, the
+ known ones typed; `by: "assistant"` needs `proposal`. The renderer ignores it. A seeded clip: `{type, id r<NNN>,
+ channel, video, start = cutStart − 1.5, end = cutEnd + 1.5 (clamped), cutStart, cutEnd (= the proposal), cite =
+ floor(cutStart), quote (the cut's words ≤ 160 chars), assist {by: "assistant", proposal, score, why, original,
+ edits: []}}`.
+- **A proposal pass** (`applyProposals`): movable = an assistant clip of the recording with no ruling (clipMomentKey in
+ montage-rulings.json) and no `lock*`. Movable clips are updated in place (same id) when their proposal is still used,
+ removed when not; new used proposals become `r<next>`; everything else is untouched. A proposal overlapping a fixed
+ clip by ≥ 50 % (of either) is that clip (`used`, `clipId` = it), and fixed clips' seconds count toward the target
+ first. The recording's clips are sorted by cut in the slots they hold; other entries do not move. Proposal ids:
+ overlap ≥ 50 % of the longer with a previous proposal → its id; else the next number.
+- **The scans** (`lib/clips/scan.mjs`): `runAudioScan` decodes 300 s chunks (`decodeSpan`), windows 1 s / hop 0.5 s,
+ each window's dBFS (mean power of 20 ms frames, 1 dp) and, with the tagger, its laugh score = Σ CED probs of classes
+ 16, 18, 19, 20, 21 clamped to 1 (3 dp); one `scripts/audio-tag.py` process per 4 chunks (wav per chunk, deleted after).
+ `speakerCentroids`: ≤ 12 turns ≥ 2 s per cluster overlapping no other cluster, spread by start, first 8 s each, voiced
+ frames (`voicedSamples`), `embedWavs`, `robustCentroid` (5 dp). Cache `<project>/scans/<channel>--<video>.audio.json`
+ `{…scan, source {path, size, mtimeMs}, clock, kind, madeAt}` (reused while source key, `model.file`, clock match) and
+ `.voices.json` `{version, model, speakers {i: {centroid, pieces, kept}}, engineModel, source, diarization, madeAt}`
+ (reused while source key, diarization `generatedAt`, engine model basename match). Scratch `<project>/.clips-work`.
+ Tagger: `AUDIO_TAG_PYTHON|SCRIPT|MODEL|LABELS`, else `settings.diarization.python`, `scripts/audio-tag.py`,
+ `.diarize/models/sherpa-onnx-ced-mini-audio-tagging-2024-04-19/model.int8.onnx` + its `class_labels_indices.csv`
+ (gitignored; the orchestrator installed it). Measured: ~11 ms per 1 s window on one thread (CED-mini int8), so a
+ 2.5 h stream ≈ 18,500 windows ≈ 3–4 min.
+- **The sound** (`umtool/lib/report/reactions.mjs` `recordingAudio`): the video dir's `audio.m4a|mp3|opus|wav|flac`
+ first, else `resolveLocalSource(0..duration, audio: true)`; `clock` = windowStart + `clockOffset`. **Words**:
+ `<project>/words.json` (`{words: [...]}` as `pnpm ops transcribe {words: true, out}` writes, or a bare array) >
+ corpus `transcript.json` (whisper tokens via montage.mjs `whisperWords`) > `transcript.cues.json` spread by length.
+ **Duration**: diarization `audioSeconds` > metadata `duration` > cues doc `duration` > the last turn's end.
+- **Job**: `/api/report/clips` POST `{project, mode? "analyze"|"propose", from?, target?, host?}` → `clipsSteps` → one
+ lib/jobs.ts step `nice -n 10 node umtool/bin/umtool.mjs clips <mode> <id> … --progress ndjson` (events `{ev: "clips",
+ phase: load|laughs|voices|propose|done, …}`), timeout 90 min (analyze) / 5 min (propose). GET `?project=` summarizes
+ reactions.json. The new-project form posts `mode: "analyze"` right after creating a reactions project.
diff --git a/umtool/docs/cli.md b/umtool/docs/cli.md
@@ -25,7 +25,7 @@ Inbox cannot disagree about what is wrong with one.
| `window <project> <clip> [--start S] [--end E] [--lock] [--lock-end] [--no-lock-end] [--note …]` | edit a window |
| `build <project> [--preset preview\|fast\|final] [--only ID]` | **prints** the chain |
| `index [--rebuild] [--prune] [--since MS] [--json]` | the cache |
-| `new <slug> [--from <report.md>\|<share URL>\|<channel>/<id>] [--site-origin URL] [--seed chapters\|frames [--target S]]` · `new <slug> --seed phrase --phrase <regex> --channels a,b [--prefer <slug>] [--exclude <regex>]` | scaffold |
+| `new <slug> [--from <report.md>\|<share URL>\|<channel>/<id>] [--site-origin URL] [--seed chapters\|frames [--target S]]` · `new <slug> --seed phrase --phrase <regex> --channels a,b [--prefer <slug>] [--exclude <regex>]` · `new <slug> --seed reactions --from <channel>/<id> [--target S] [--no-analyze]` | scaffold |
| `doctor [--json]` | which tools are on this machine and where the roots are; **exit 1** if the report pipeline is missing one, or `UMTOOL_MEDIA_DIR` is set and not there |
| `storage [<project>] [--json]` | where each project's `out/` lives: dir, link, DANGLING, none — and a report's deliverables (`clips/`, `share-*/`) and its switch |
| `storage move-out\|move-back <project>\|--all [--dry-run] [--json]` | `out/` to the media root (a link left behind) and back — copied, mirrored, verified first; run when nothing is building |
@@ -45,6 +45,7 @@ Inbox cannot disagree about what is wrong with one.
| `rulings <project> [--json]` · `rulings <project> import [--dry-run] [--json]` · `rulings <project> set <clip\|key> keep\|cut\|not-him\|read-aloud [--reason R] [--match M]` · `rulings <project> clear <clip\|key>` | a montage's **clip rulings** (`montage-rulings.json`, the clip deck's): each clip and its ruling and the next render's kept clips; the earlier rulings in the seed's `edits.json`, once; one ruling set or cleared. A render leaves out every clip ruled cut, not-him or read-aloud ([report-video.md](report-video.md#ruling-the-clips)) |
| `phrases "<phrase>" ["<phrase>" …] --channels a,b [--prefer c] [--exclude RE] [--words \| --regex] [--samples N] [--no-cache] [--json \| --full]` | the phrase finder's search ([tools.md](tools.md#the-phrase-finder-toolsphrases)): every phrase in one pass, each with its count once folded, by year, the preferred channel's share or Rumble's, speaker changes, sample contexts. Plain words become a tolerant pattern unless the phrase holds a regular expression's characters. `--json` the numbers, `--full` every instance; `--spec FILE --out FILE --progress` is the page's job form. **Exit 1** on a bad phrase |
| `voice-match <project> [--reference auto\|rulings\|recordings] [--reference-video <channel>/<id> …] [--reference-channel <slug> …] [--instances FILE] [--span phrase\|cut] [--pad S] [--likely X --unlikely Y] [--out FILE] [--dry] [--json] [--progress ndjson]` | who is speaking, per montage clip: a local speaker-similarity score (TitaNet-small) against the host's voice → `<project>/voice-match.json` (the Cut tab's **Score the voices**); `--instances` also scores a phrase scan's instances not in the manifest; `--dry` prints the plan ([report-video.md](report-video.md#who-is-speaking-the-voice-match)) |
+| `clips analyze <project> [--from <channel>/<id>] [--rescan] [--no-laughs] [--no-voices] [params] [--words FILE] [--progress ndjson] [--json]` · `clips propose <project> [--from <channel>/<id>] [--host N] [params] [--words FILE] [--dry] [--json]` · `clips show <project> [--json]` | the **clip finder** on a long recording ([report-video.md](report-video.md#highlights-the-clip-finder)): `analyze` runs the laugh scan (CED-mini) and a voice centroid per speaker on the recording's sound (cached in `<project>/scans/`), then proposes; `propose` proposes again from what is there (after a role flip, a param change, new words); `show` prints the speakers, laughs and the cut. Params `--target S` (600) `--laugh-min X` (0.25) `--merge-gap S` (6) `--setup-max S` (20) `--clip-max S` (75), kept in `reactions.json`; `--host N` is your word on the host, kept. A clip you edited, ruled, locked or added is never moved. **Exit 2** with no `diarization.json` (the message names the `archilyzer diarize backfill` to run) |
A project argument is an exact id, a directory, or a **unique** basename. Two
projects answering to one name is reported, never resolved by picking one.
@@ -209,3 +210,27 @@ umtool new quartering-slow-news --seed phrase \
--channels the-quartering,jeremy-hambly,quartering-live,cornbreadman \
--prefer the-quartering-rumble --exclude 'slow news \w+,? jeremy'
```
+
+**`--seed reactions`** (release 35) is the clip finder's first pass over a long
+recording — a stream, a podcast, a reaction video — and needs its speakers:
+`diarization.json` beside it (`archilyzer diarize backfill --scope
+video:<channel>/<id>`; the refusal names it). The host is the speaker with the
+most short turns spread across the whole recording, the subject the one with
+the most seconds among the rest; every host laugh and every host comment of
+1.5 s of words or more is a moment; a clip runs from the start of the subject's
+sentence that set it up (at most 20 s back) through the reaction to the next
+pause, merged with its neighbours, ranked into `--target` seconds (default 600).
+The used proposals become clips `r001…`, each with `assist: {by: "assistant",
+proposal, score, why, original}`, chronological, hard cuts
+(`render.transition: 0`); `reactions.json` beside the manifest keeps the whole
+analysis and every proposal, used or not. The seed reads laughs from the
+transcript alone; `umtool new` then runs `umtool clips analyze` (the laugh scan
+and the voices on the sound) unless `--no-analyze`. The new-project form's seed
+"highlights" (and Create's **Highlights from a recording**) does the same and
+starts the scan as a job.
+
+```sh
+archilyzer diarize backfill --scope video:some-channel/abc123
+umtool new some-stream-highlights --seed reactions --from some-channel/abc123 --target 600
+umtool clips propose some-stream-highlights --host 1 # the other speaker is the host
+```
diff --git a/umtool/docs/report-video.md b/umtool/docs/report-video.md
@@ -50,6 +50,7 @@ travel. umtool never reorders as a side effect of a window edit.
"note": "…", // why it is in the cut (editorial, for humans)
"correction": "…", // what the REPORT got wrong here; never rendered
"verdict": "confirmed", // or "incorrect"; absent = nobody has looked yet
+ "assist": { "by": "assistant", … }, // the clip finder's provenance (see "Highlights"); never rendered
"chapter": "…", // chapter title; falls back to date + title
"section": 2, "sectionEnter": true,
"lock": true, "lockStart": true, "lockEnd": true }
@@ -905,6 +906,93 @@ fallback?, inReference?, why?}}}` — keyed by the source moment, as the
rulings are, so a re-seed keeps it. A clip with no window on disk, or no
speech in it, has `score: null` and says why.
+## Highlights: the clip finder
+
+A long recording cut down to its best moments — a stream, a podcast, a host
+reacting to a narrated video — starts as clips **proposed** from the recording
+itself, never as a finished cut. `umtool new <slug> --seed reactions --from
+<channel>/<id>` (or Create → **Highlights from a recording**) writes the first
+proposals; `umtool clips analyze <project>` runs the scans and proposes again;
+`umtool clips propose` proposes again from what is there. Every step is local
+signal processing and two small local models; nothing calls a model you talk
+to, and the whole loop can be done by hand in the clip editor.
+
+What it reads, and what it does without:
+
+- **Speakers** — `diarization.json` beside the recording (the editor's diarize
+ job, or `archilyzer diarize backfill --scope video:<channel>/<id>`). Required.
+- **Words** — `<project>/words.json` (`pnpm ops transcribe {path, words: true,
+ out: "<project>/words.json"}`), else whisper.cpp's word offsets in the corpus
+ `transcript.json`, else the cues with each cue's words spread over it.
+- **The sound** — the recording's `audio.*`, else a local source that covers it
+ (a saved video). Without it, laughs come from the transcript alone.
+- **The laugh model** — CED-mini (sherpa-onnx `AudioTagging`, AudioSet's 527
+ classes) at `.diarize/models/sherpa-onnx-ced-mini-audio-tagging-2024-04-19/`
+ (`AUDIO_TAG_MODEL`). Without it: the transcript's laugh markers (`[laughter]`,
+ `haha`, `lol`, `lmao`) and the host's loud wordless bursts.
+
+The steps:
+
+1. **Roles.** The host is the speaker with the most turns under 8 s times the
+ widest spread over the recording (a reaction stream's host interjects all the
+ way through; the narrated video talks in long runs); the subject is the one
+ with the most seconds among the rest; a speaker under 1 % of the speech is
+ never either by itself. A third cluster whose voice centroid (TitaNet-small,
+ a few clean turns each) is 0.6 or more like the host's or the subject's takes
+ that role (`sameAs`). Your word beats all of it: **This is the host** in the
+ clip editor, or `--host N`, is kept (`how: "operator"`) until you change it.
+2. **Laughs.** CED-mini over 1 s windows every 0.5 s; the laughter family
+ (Laughter, Giggle, Snicker, Belly laugh, Chuckle — not Baby laughter) summed,
+ at most 1; runs at or over `laughMin` (0.25) are laughs, joined across a 0.5 s
+ gap, each the speaker's who was talking (a host turn that overlaps makes it
+ the host's — he laughs over the video).
+3. **Moments.** Every laugh (its strength × its length, squashed to 0–1, weighed
+ by who laughed: the host 1, nobody 0.8, another speaker 0.6, the subject 0.5)
+ and every host turn with 1.5 s of words or more (half its length, half the
+ strongest laugh around it).
+4. **Proposals.** From the start of the subject's sentence that set the moment
+ up (the latest sentence start at least 3 s before it, at most `setupMax` 20 s
+ back) through the reaction (the host's turn, at most 12 s past a laugh) to
+ the next pause (at most 1.5 s), edges in the gaps between words; overlapping
+ spans merged, spans closer than `mergeGap` (6 s) merged while the whole fits
+ `clipMax` (75 s); a longer one keeps its end and starts on the latest
+ sentence that fits. Ranked by score into `target` seconds (600, 3 % over
+ allowed); the rest stay in `reactions.json` with `used: false`, for the
+ clip editor's unused list.
+5. **Clips.** Each used proposal is a clip `r001…` — the cut is the proposal,
+ the window 1.5 s wider each side for trimming, `quote` its words — with
+ `assist: {by: "assistant", proposal, score, why, original, edits: []}`, in
+ time order, hard cuts (`render.transition: 0`).
+
+**A proposal pass never touches your work.** A clip whose `assist.by` is
+`"operator"` (the first edit flips it), a clip with no `assist`, one ruled in
+`montage-rulings.json` and one with a `lock*` stays exactly as it is; a
+proposal that covers half of one is that clip, and its seconds count toward the
+target first. Untouched assistant clips are moved in place (the same id) or
+removed; new ones take the next `r` numbers. A proposal keeps its id from pass
+to pass while it overlaps its old self by half. The manifest is written through
+its writer (an undo point, `auto-before-clips-propose`), `reactions.json`
+whole. Params and your roles are kept in `reactions.json` for the next pass.
+
+The scans are cached in `<project>/scans/<channel>--<video>.audio.json` (each
+window's level and laugh score) and `.voices.json` (a centroid per speaker),
+reused while the sound file, the model and the diarization are the same
+(`--rescan` makes them again). A 2.5-hour stream's laugh scan is about 18,500
+windows, a few minutes on one CPU thread.
+
+`reactions.json`: `{version: 1, source: {channel, video, duration, words:
+"words.json" | null, wordsFrom, diarization: {generatedAt, engine}, audio?,
+audioKind?}, params: {target, laughMin, mergeGap, setupMax, clipMax},
+speakers: [{index, role: "host"|"subject"|"other", label, seconds, turns, how:
+"auto"|"operator", sameAs?}], turns: [{start, end, speaker}], laughs: [{start,
+end, score, speaker: n|null, src?: "text"|"energy"}], moments: [{id, t, end,
+kind: "laugh"|"comment", score, speaker: n|null, text}], proposals: [{id, start,
+end, score, moments, used, clipId: "r001"|null, why}], laughSource:
+"model"|"text"|"text+energy", scans: {laughs, voices}, madeAt, proposedAt,
+rolesChangedAt?}`. The clip editor changes only a speaker's role, through
+`setSpeakerRole` (`yt-dlp-transcript-common/lib/clips/reactions.mjs`), which
+records `rolesChangedAt` so the page can offer Re-propose.
+
## Operator notes, timed notes and the generated-manifest guard
Notes on a project live in `<project>/notes.json` (shape and CLI: