commit 238001603c25a2d40f961d572cd2a51e886f31f7
parent 4664fa246c860d26c74b0bf08c2e6c8837a53724
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Sun, 18 Oct 2026 16:55:20 -0400
umtool: e2e for Score the voices — the job writes voice-match.json (keyed by the source moment) and every Cut-tab row shows its score; the fixture's engine is the test kit's fake embedder
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
3 files changed, 99 insertions(+), 0 deletions(-)
diff --git a/umtool/e2e/fixtures/make-fixture.mjs b/umtool/e2e/fixtures/make-fixture.mjs
@@ -1035,6 +1035,41 @@ writeProject(
]),
);
+// THE VOICE-MATCH FIXTURE (release 34): who is speaking, per clip. Four clips
+// of one "voice" (a 150 Hz tone with its octave) and one of another (a
+// 1.1 kHz tone), each window already in the corpus under its own channel so no
+// other spec's fetch can touch it; three of the first four are ruled `keep` in
+// montage-rulings.json, so the reference is the keeps. The app's job runs the
+// test kit's fake embedder (VOICE_MATCH_PYTHON / VOICE_MATCH_SCRIPT in
+// playwright.config.ts), which tells the two spectra apart.
+{
+ const chan = "voicechan";
+ const voices = { host: "0.3*sin(2*PI*150*t)+0.15*sin(2*PI*300*t)", guest: "0.3*sin(2*PI*1100*t)+0.1*sin(2*PI*2300*t)" };
+ const clips = [["v01", "voice1", "host"], ["v02", "voice2", "guest"], ["v03", "voice3", "host"], ["v04", "voice4", "host"], ["v05", "voice5", "host"]];
+ const timeline = [];
+ for (const [id, vid, who] of clips) {
+ const dir = path.join(CHANNELS, chan, "data", vid);
+ mkdirSync(path.join(dir, "clips"), { recursive: true });
+ writeFileSync(
+ path.join(dir, "transcript.cues.json"),
+ JSON.stringify({ title: `Voice ${vid}`, uploadDate: "20250101", channel: "Voice Channel", webpageUrl: `https://example.invalid/watch?v=${vid}`, duration: 20, cues: [{ start: 2, end: 4.5, text: "slow news day" }] }, null, 1),
+ );
+ ff([
+ "-f", "lavfi", "-i", "color=c=gray:size=160x90:rate=15:duration=6",
+ "-f", "lavfi", "-i", `aevalsrc=${voices[who]}:s=48000:d=6`,
+ "-map", "0:v", "-map", "1:a", "-t", "6",
+ "-c:v", "libx264", "-pix_fmt", "yuv420p", "-c:a", "aac", "-ar", "48000", "-ac", "2",
+ path.join(dir, "clips", "0.00-6.00.mp4"),
+ ]);
+ timeline.push({ type: "clip", id, channel: chan, video: vid, start: 0.5, end: 5.5, cutStart: 2, cutEnd: 4.5, cite: 2, section: 0, lock: true, quote: "slow news day", montage: { match: "slow news day" } });
+ }
+ const dir = writeProject("voice-fixture", manifest("voice-fixture", "The Voice Fixture", { siteOrigin: "https://archive.example", channelSlug: chan }, timeline));
+ writeFileSync(
+ path.join(dir, "montage-rulings.json"),
+ JSON.stringify({ version: 1, rulings: Object.fromEntries(["voice1", "voice3", "voice4"].map((v) => [`${chan}/${v}@2.00`, { verdict: "keep", reason: "", at: "2026-10-18T00:00:00.000Z" }])) }, null, 1),
+ );
+}
+
// A RECORD THAT STORES ITS MEDIA URL (release 32 R6): an Odysee record whose
// metadata.info.json names its one CDN format, so "Cut from the stored media
// URL" is offered beside its fetch (lib/clips/stored.ts). Its own channel and a
diff --git a/umtool/e2e/voice-match.spec.ts b/umtool/e2e/voice-match.spec.ts
@@ -0,0 +1,59 @@
+import { test, expect } from "@playwright/test";
+import { readFileSync } from "node:fs";
+import path from "node:path";
+import { fileURLToPath } from "node:url";
+import * as urls from "./urls";
+
+// ---------------------------------------------------------------------------
+// Who is speaking, per montage clip (release 34): the Cut tab's "Score the
+// voices" runs `umtool voice-match` as a job and every row then carries its
+// score. The engine is the test kit's fake embedder (playwright.config.ts), so
+// nothing here needs python or a model.
+//
+// voice-fixture WRITES voice-match.json. Five clips with their windows in
+// the corpus: four of one voice (three ruled keep), one of
+// another (v02)
+// ---------------------------------------------------------------------------
+
+const HERE = path.dirname(fileURLToPath(import.meta.url));
+const PROJECT = "reports/voice-fixture";
+const FILE = path.join(HERE, "..", ".e2e-song", "reports", "voice-fixture", "voice-match.json");
+
+test("Score the voices: a job writes voice-match.json and each clip row shows its score", async ({ page }) => {
+ await page.goto(urls.section(PROJECT, "cut"));
+ const panel = page.locator("[data-voice-match]");
+ await expect(panel).toBeVisible();
+ await expect(page.locator("[data-voice-summary]")).toHaveCount(0);
+ await expect(page.locator("[data-entry] [data-voice]")).toHaveCount(0);
+
+ await panel.locator("[data-voice-reference]").selectOption("auto");
+ await panel.getByRole("button", { name: "Score the voices" }).click();
+ await expect(page.locator("[data-voice-summary]")).toContainText("4 likely · 0 unsure · 1 unlikely of 5 scored", { timeout: 60_000 });
+ await expect(page.locator("[data-voice-summary]")).toContainText("against 3 clips ruled keep");
+
+ await expect(page.locator("[data-entry='v02'] [data-voice]")).toHaveAttribute("data-voice", "unlikely");
+ await expect(page.locator("[data-entry='v01'] [data-voice]")).toHaveAttribute("data-voice", "likely");
+ await expect(page.locator("[data-entry='v05'] [data-voice]")).toContainText(/voice \d\.\d\d · likely/);
+
+ // The file, in the shape the audition deck reads: keyed by the source moment.
+ const doc = JSON.parse(readFileSync(FILE, "utf8"));
+ expect(doc.version).toBe(1);
+ expect(doc.model).toBe("titanet-small");
+ expect(doc.reference.kind).toBe("rulings");
+ expect(Object.keys(doc.clips).sort()).toEqual(["voicechan/voice1@2.00", "voicechan/voice2@2.00", "voicechan/voice3@2.00", "voicechan/voice4@2.00", "voicechan/voice5@2.00"]);
+ const guest = doc.clips["voicechan/voice2@2.00"];
+ expect(guest.label).toBe("unlikely");
+ expect(guest.id).toBe("v02");
+ expect(typeof guest.score).toBe("number");
+ expect(guest.speechSeconds).toBeGreaterThan(1);
+
+ // Run again: the button says so, and the same input scores the same.
+ await expect(panel.getByRole("button", { name: "Score the voices again" })).toBeVisible();
+});
+
+test("the route refuses what is not a report video, and a project that does not exist", async ({ request }) => {
+ expect((await request.post("/api/report/voice-match", { data: { project: "reports/no-such-project" } })).status()).toBe(404);
+ expect((await request.post("/api/report/voice-match", { data: "nope", headers: { "content-type": "application/json" } })).status()).toBe(400);
+ const r = await request.get(`/api/report/voice-match?project=${encodeURIComponent(PROJECT)}`);
+ expect(r.status()).toBe(200);
+});
diff --git a/umtool/playwright.config.ts b/umtool/playwright.config.ts
@@ -176,6 +176,11 @@ export default defineConfig({
// would otherwise enumerate every fixture article's corpus and add cards
// other specs count. refresh.spec runs the check itself, through its route.
`UMTOOL_REFRESH_CHECK=0 ` +
+ // The voice match's engine (release 34): the test kit's fake embedder,
+ // run by this node, in the place of scripts/speaker-embed.py and the
+ // TitaNet venv -- the same command line and JSON, no python, no model.
+ `VOICE_MATCH_PYTHON=${process.execPath} ` +
+ `VOICE_MATCH_SCRIPT=${path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "common", "testing", "audio", "fakeSpeakerEmbed.mjs")} VOICE_MATCH_MODEL=fake.onnx ` +
APP_SERVER,
port: PORT,
reuseExistingServer: false,