commit 1bc406ec77e3bbe867f24587eabaeb6e68b57d7e
parent 238001603c25a2d40f961d572cd2a51e886f31f7
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Sun, 18 Oct 2026 17:07:14 -0400
docs: the voice match — umtool report-video and cli docs, the changelog, ENVIRONMENT.md (VOICE_MATCH_PYTHON / _SCRIPT / _MODEL declared), .diarize's note; the run's scratch moves beside the project, never /tmp
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
7 files changed, 61 insertions(+), 2 deletions(-)
diff --git a/.diarize/README.md b/.diarize/README.md
@@ -74,6 +74,10 @@ Absolute paths. `diarize.mjs` records only the BASENAME into the sidecar, becaus
the corpus is rsynced between shards and a full path would make records
non-portable.
+The same `python` and `embModel` run umtool's montage **voice match**
+(`umtool voice-match`, `scripts/speaker-embed.py`: WAV segments in, TitaNet
+embeddings out), so nothing more needs installing for it.
+
## Checking a rebuild reproduces the record on disk
Read-only, writes nothing to the corpus. `ObviousRises-rumble/v6z1o2g` is the one
diff --git a/ENVIRONMENT.md b/ENVIRONMENT.md
@@ -106,6 +106,9 @@ Tokens, credentials and knobs a running process reads. Most configuration is not
| `DIARIZE_ENGINE_KIND` | `sherpa-onnx` | The diarization engine: `sherpa-onnx` or `sortformer`. | scripts/diarize.mjs |
| `DIARIZE_ENGINE_CMD` | the bundled sherpa script | The engine command the wrapper runs. | scripts/diarize.mjs |
| `DIARIZE_PYTHON` | `python3` | The python for the default engine. | scripts/diarize.mjs |
+| `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`) |
| `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
@@ -142,6 +142,9 @@ const DECLARED: EnvVarDecl[] = [
{ name: "DIARIZE_ENGINE_KIND", audience: "runtime", default: "`sherpa-onnx`", readBy: "scripts/diarize.mjs", doc: "The diarization engine: `sherpa-onnx` or `sortformer`." },
{ name: "DIARIZE_ENGINE_CMD", audience: "runtime", default: "the bundled sherpa script", readBy: "scripts/diarize.mjs", doc: "The engine command the wrapper runs." },
{ name: "DIARIZE_PYTHON", audience: "runtime", default: "`python3`", readBy: "scripts/diarize.mjs", doc: "The python for the default engine." },
+ { 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: "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 scores who is speaking in each montage clip.** A report video's Cut tab has **Score the voices**: each clip's phrase (and a second either side, its speech only) is compared with the host's voice, and every row then reads `voice 0.43 · unsure` — likely, unsure or unlikely him. 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.
- **Report videos cut clips from Rumble windows on the right second.** Some downloaded windows (Rumble's) keep their source's clock, so their picture starts a second or two in, and every cut from one landed that much late — in the slow-news montage, one clip's "slow news week" fell into the pause after it. The build now reads where such a window's picture starts and cuts on its own clock (and says so in the build log). In a montage with even loudness, a clip or wall tile that measures near-silent is taken for a phrase looked for in the wrong place: it is found again by the sound — the speech nearest where it was expected — recorded, said in the log, and never boosted from silence.
- **Montages are level, and their walls don't repeat themselves side by side.** With `render.montage.loudness` (every montage style has it, at −16 LUFS), each clip and each wall tile is measured and brought to the same loudness, with a limiter so a quiet clip raised up cannot clip — an old upload and a recent stream no longer jump in level at the cut. `wall.spread: "stream"` keeps two clips of one stream, or a stream and its mirror on another platform, from touching in the wall's grid, and `wall.distinct` takes one clip per stream when there are enough. `wall.label` puts each tile's year, its number or both in its corner. Build to the wall uses all three. Manifests without them render exactly as before.
- **A montage can build to its wall.** The closing wall can fill in groups of 1, 1, 2, 4, 8 … tiles, each group sliding in on a beat that comes a little sooner than the last; a group says the phrase together, with every tile's first syllable placed on the beat (from whisper's word timings, or from the captions checked against the sound), and at the end every tile says it on the same frame. The wall can take the latest clips instead of a spread (`wall.clips: "tail"`) and take them out of the run before it (`wall.exclusive`), so it condenses the repetition instead of repeating it; the count before it then stops where the wall begins. A ramp can end at the wall's first beat (`ramp.into: "wall"`), so the cuts speed straight into it. A seventh style, **Build to the wall**, puts these together: whip cuts getting shorter, tally marks, then the latest twenty-five in synced groups. Manifests without the new keys render exactly as before.
diff --git a/umtool/docs/cli.md b/umtool/docs/cli.md
@@ -42,6 +42,7 @@ Inbox cannot disagree about what is wrong with one.
| `take <project> --id <id> --label L [--group G] [--kind similar\|different] [--summary S] [--style NAME] [--patch FILE \| --patch-json JSON \| --set path=value …] [--at S --dur S \| --full] [--quick] [--force] [--progress ndjson]` | one **take**: the manifest with a montage style's patch, then the take's own, rendered into `takes/<id>/` (the Takes page's New take); `--id <id> --rebuild` makes one again from its own `take.json` ([report-video.md](report-video.md#making-takes)) |
| `takes make <project> [--recipe FILE] [--only ID,ID] [--force]` · `takes make <project> --all-styles [--group G] [--at S --dur S \| --full]` | a recipe's takes, one at a time (default `takes/recipe.json`); every montage style, one take each (Make all styles); **exit 1** if any failed |
| `takes styles [--json]` · `takes pick <project> <take> [--anyway] [--json]` | the montage styles; **Use this take** — refused (exit 1) when the project changed since the take was made, until `--anyway` |
+| `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)) |
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.
diff --git a/umtool/docs/report-video.md b/umtool/docs/report-video.md
@@ -819,6 +819,51 @@ into a wall of the latest 25: they are taken out of the run (`wall.exclusive`,
beats, each group saying it in unison with its onsets synced to the beat, then
all 25 at once.
+### Who is speaking: the voice match
+
+A montage of one phrase is also a montage of everyone who said it near the host:
+a co-host's "slow news day", a guest's answer, a post read aloud. **Score the
+voices** on the Cut tab (or `umtool voice-match <project>`) scores every clip's
+voice against the host's, locally, and writes `voice-match.json` beside the
+manifest; each row then shows `voice 0.43 · unsure`. It is an aid to the ear:
+the audition deck puts the doubtful clips first and the ruling is still yours.
+Nothing here is a model you talk to, and nothing leaves the machine.
+
+- **What is scored:** the clip's phrase ± 1 s — found the way the montage
+ render finds it (whisper's word timings, else the captions) — read from the
+ file the render would cut from, voiced frames only. When the phrase's
+ seconds hold under 1.5 s of speech (word timing on a pause, a window whose
+ sound runs late) the clip's cut ± 1 s is scored instead (`fallback: true`).
+- **The host's voice (the reference):** the clips you ruled **keep** in the
+ audition deck (`montage-rulings.json`), once there are three — each of them
+ scored against the others. Before that, solo recordings found on disk: the
+ first 60 s of speech of up to 8 uploads of the project's channels with their
+ sound or video on disk, spread over the years, each a captioned upload (only
+ captions mark a speaker change) with no `>>` in its captions, not a
+ livestream, and no second voice in its title ("with", "ft.", "interview",
+ "debate", "podcast", …). Ten-second pieces far from the rest (a clip played in
+ the video, an intro) are dropped before the reference is made. The reference
+ picker (auto / the clips ruled keep / solo recordings) beside the button, or
+ `--reference`, chooses; `--reference-video <channel>/<id>` names the
+ recordings yourself.
+- **The labels:** `likely` at 0.42 or over, `unlikely` under 0.30, `unsure`
+ between (cosine similarity to the reference, 0–1). Measured on the slow-news
+ montage: the solo uploads all came out likely, the two lines the operator
+ ruled another speaker came out at 0.24 and 0.005. `--likely` / `--unlikely`
+ move them for a run.
+- **The engine:** TitaNet-small through sherpa-onnx, the diarization lane's own
+ venv and model (`settings.diarization.python` / `.embModel`, else
+ `.diarize/`), one process for the whole project, nice'd; the 73-clip
+ slow-news project takes about 35 s and 300 MB. `VOICE_MATCH_PYTHON`,
+ `VOICE_MATCH_SCRIPT` and `VOICE_MATCH_MODEL` override it.
+
+`voice-match.json`: `{version: 1, model: "titanet-small", reference: {kind:
+"rulings" | "recordings", …how it was built}, thresholds, counts, clips: {
+"<channel>/<video>@<cutStart>": {score, label, speechSeconds, best, id, via,
+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.
+
## Operator notes, timed notes and the generated-manifest guard
Notes on a project live in `<project>/notes.json` (shape and CLI:
diff --git a/umtool/lib/report/voiceMatch.mjs b/umtool/lib/report/voiceMatch.mjs
@@ -21,7 +21,6 @@
// button and a terminal do one thing. Nothing here calls a model but the
// local speaker-embedding one; nothing touches the network.
import { readdir, readFile } from "node:fs/promises";
-import os from "node:os";
import path from "node:path";
import {
PHRASE_PAD_S,
@@ -351,7 +350,10 @@ export async function voiceMatchCommand(args, { reportsRoot = REPORTS_ROOT, log
settings = null;
}
const engine = resolveEngine({ repoRoot: REPO_ROOT, settings, ...engineOpts });
- const scratch = path.join(process.env.VOICE_MATCH_SCRATCH ?? os.tmpdir(), `umtool-voice-match-${process.pid}`);
+ // Beside the project, never /tmp (a RAM tmpfs on the box this runs on):
+ // a few MB of 16 kHz wavs, removed when the run ends (and by the next run,
+ // when one was cancelled).
+ const scratch = path.join(/* turbopackIgnore: true */ project.dir, ".voice-match-work");
const t0 = Date.now();
const doc = await runVoiceMatch({
clips: clips.map((c) => (c.file ? { key: c.key, id: c.id, file: c.file, start: c.start, dur: c.dur, fallback: c.fallback ?? null } : { key: c.key, id: c.id, file: null, start: 0, dur: 0, missing: c.missing })),