Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 18dca1004ec5e824cbb5b5aadd1e3620ea8a2f1d
parent 99e80022bb69fb2f6eb28f0fa2ca6eada4d8b826
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Tue, 17 Nov 2026 17:08:03 -0500

the bench's take ask: one builder for the route and the parity test; a speed only when it is a number (review 1 nits)

benchTakeAskOf (postTakeAsk.mjs) builds the take op's ask from the POST's body; the route calls it and
benchQueueParity.test.mjs compares the queue's read with it. A falsy or NaN speed is left out, as the
bench always left it; a new test pins the untuned bench ask byte for byte against the route's old
body (Orpheus with no speed, Kokoro with the item's, a speed that is no number).

Co-Authored-By: Claude <noreply@anthropic.com>

Diffstat:
Mumtool/app/api/report/post-narration/route.ts | 10++--------
Mumtool/lib/report/benchQueueParity.test.mjs | 24+++++++++++++++++++++---
Mumtool/lib/report/postTakeAsk.mjs | 23++++++++++++++++++++++-
3 files changed, 45 insertions(+), 12 deletions(-)

diff --git a/umtool/app/api/report/post-narration/route.ts b/umtool/app/api/report/post-narration/route.ts @@ -19,7 +19,7 @@ import { withTakeScope } from "@/lib/report/takeScope.mjs"; import { isTakeId } from "@/lib/report/takes.mjs"; import { keepRecording, RECORD_LABEL_RE } from "@/lib/report/postRecord.mjs"; import { fitPostItem } from "@/lib/report/postFit.mjs"; -import { askBody, benchSlurVoice, postTakeAskOf } from "@/lib/report/postTakeAsk.mjs"; +import { askBody, benchSlurVoice, benchTakeAskOf } from "@/lib/report/postTakeAsk.mjs"; import { readAgainArgv } from "@/lib/report/readAgainArgv.mjs"; import { projectRedaction } from "@/lib/report/postRedaction.mjs"; import { spokenRead } from "umtool-report-to-video/post-redact"; @@ -435,13 +435,7 @@ async function postHere(request: Request) { // tuning asks as it always did) and what the voice SAYS (the redaction, the slurs, the lexicon; the script kept // as written). The bench cannot word-time a take as it is made, so a beep falls back to skip (benchSlurVoice). const red = await projectRedaction(r.project.dir, m); - const A = await postTakeAskOf(r.project, e, { - render: (m.render ?? {}) as Record<string, unknown>, script, - engine: typeof body.engine === "string" && body.engine ? body.engine : null, - voice: typeof body.voice === "string" && body.voice ? body.voice : null, - speed: body.speed === undefined || body.speed === null ? null : Number(body.speed), - tuning: tuned?.ok ? tuned.value : null, reading: reading === null ? null : Number(reading), red, slurVoice: benchSlurVoice(red), - }); + const A = await benchTakeAskOf(r.project, e, { manifest: m, script, body, tuning: tuned?.ok ? tuned.value : null, reading: reading === null ? null : Number(reading), red }); const { engine, voice, tuning, tuningAsked } = A; const pid = postIdOf(e); const dir = path.join(r.project.dir, ...takesDirOf(pid).split("/")); diff --git a/umtool/lib/report/benchQueueParity.test.mjs b/umtool/lib/report/benchQueueParity.test.mjs @@ -12,7 +12,7 @@ import { after, test } from "node:test"; import { encodeWav16 } from "yt-dlp-transcript-common/lib/montage/voiceMatch.mjs"; import { VOICE_B, syntheticVoice, withSilence } from "yt-dlp-transcript-common/testing/audio/syntheticVoice.mjs"; import { makeTake } from "./postNarrationCli.mjs"; -import { askBody, benchSlurVoice, postTakeAskOf } from "./postTakeAsk.mjs"; +import { askBody, benchTakeAskOf } from "./postTakeAsk.mjs"; import { projectRedaction } from "./postRedaction.mjs"; const LIST = JSON.parse(readFileSync(new URL("../../report-to-video/slurs.json", import.meta.url), "utf8")); @@ -37,12 +37,12 @@ const asker = (asked) => async (body) => { await writeFile(body.out, encodeWav16(withSilence(syntheticVoice({ ...VOICE_B, seconds: 0.6 }), { before: 0.1, after: 0.1 }))); return { jobId: `job-${asked.length}`, result: { wav: body.out, engine: body.engine, voice: body.voice } }; }; -/** The bench's take op's body for one press (the route builds it with these very calls). */ +/** The bench's take op's body for one press: through the route's OWN builder (benchTakeAskOf, from the POST's body). */ async function benchBody(p, press) { const m = await manifest(p); const e = m.timeline[0]; const red = await projectRedaction(p.dir, m); - const a = await postTakeAskOf(p, e, { render: m.render, script: String(press.script ?? e.narration.script), speed: press.speed ?? null, tuning: press.tuning ?? null, reading: press.reading ?? null, red, slurVoice: benchSlurVoice(red) }); + const a = await benchTakeAskOf(p, e, { manifest: m, script: String(press.script ?? e.narration.script), body: { ...(press.speed !== undefined ? { speed: press.speed } : {}) }, tuning: press.tuning ?? null, reading: press.reading ?? null, red }); return askBody(a, "OUT"); } async function queueBody(p, press) { @@ -71,3 +71,21 @@ test("THE SLUR CASE: a cut that beeps -- the bench leaves the slur out, and so d assert.equal(got.take.slurs, "skip"); assert.equal(got.take.words, undefined); }); + +// REVIEW 1, a nit: the UNTUNED bench ask is byte-identical to the one the route made before this lane -- its keys in +// their order, a speed only when it is a number (never NaN, never 0), none for Orpheus. +test("the untuned bench ask, byte for byte as before: Orpheus (no speed), Kokoro with the item's speed, a speed that is no number", async () => { + const p = await project("bytes", [item({ narration: { script: "The ferry runs at noon." } })]); + // No character for a handle that is not the cast's: the narrator, Orpheus zac. + const m = await manifest(p); + const e = { ...m.timeline[0], handle: "invented_nobody" }; + const red = await projectRedaction(p.dir, m); + const old = (spoken, engine, voice, speed, tuning, reading) => JSON.stringify({ text: spoken, engine, voice, out: "OUT", ...(speed ? { speed } : {}), ...(tuning ? { tuning } : {}), ...(reading !== null ? { reading } : {}) }); + let a = await benchTakeAskOf(p, e, { manifest: m, script: e.narration.script, body: {}, red }); + assert.equal(JSON.stringify(askBody(a, "OUT")), old("The ferry runs at noon.", "orpheus", "zac", undefined, null, null)); + const k = { ...e, narration: { ...e.narration, engine: "kokoro", voice: "af_heart", speed: 1.1 } }; + a = await benchTakeAskOf(p, k, { manifest: m, script: k.narration.script, body: {}, red }); + assert.equal(JSON.stringify(askBody(a, "OUT")), old("The ferry runs at noon.", "kokoro", "af_heart", 1.1, null, null)); + a = await benchTakeAskOf(p, k, { manifest: m, script: k.narration.script, body: { speed: "fast" }, red }); + assert.equal(JSON.stringify(askBody(a, "OUT")), old("The ferry runs at noon.", "kokoro", "af_heart", undefined, null, null), "a speed that is no number is left out"); +}); diff --git a/umtool/lib/report/postTakeAsk.mjs b/umtool/lib/report/postTakeAsk.mjs @@ -36,7 +36,9 @@ export async function postTakeAskOf(project, e, { render = {}, script, engine = const vox = String(v.voice ?? k.voice); // Its speed: the press's, else the item's own (`narration.speed`), else its character's -- none for Orpheus. const asked = speed ?? e.narration?.speed ?? v.speed ?? null; - const spd = asked === null || asked === undefined || eng === "orpheus" ? null : Number(asked); + // A speed only when it is a number other than 0 (a falsy or NaN one left out, as the bench always left it). + const n = asked === null || asked === undefined || eng === "orpheus" ? null : Number(asked); + const spd = n !== null && Number.isFinite(n) && n ? n : null; const speedAsked = spd === null ? undefined : speed !== null && speed !== undefined ? true : e.narration?.speed != null ? "item" : "preset"; // Its tuning: the line's own values over its character's, field by field; whose it is; the line's own as asked. const ta = tuningAskOf({ own: tuning, preset: v.tuning ?? null, engine: eng }); @@ -49,3 +51,22 @@ export const askBody = (a, out, text = a.said.text) => ({ text, engine: a.engine, voice: a.voice, out, ...(a.speed !== null ? { speed: a.speed } : {}), ...(a.tuning ? { tuning: a.tuning } : {}), ...(a.reading !== null ? { reading: a.reading } : {}), }); + +/** + * THE BENCH's TAKE OP's ASK (app/api/report/post-narration, op "take"): from the POST's body -- its engine and voice + * when named, its speed when given -- with the press's tuning and reading (checked by the route) and the bench's slur + * rule. The route builds with this; the parity test compares the queue's read with it. + * + * @param {{ id: string, dir: string }} project + * @param {Record<string, any>} e + * @param {{ manifest: any, script: string, body: Record<string, unknown>, tuning?: Record<string, number> | null, reading?: number | null, red: any }} o + */ +export function benchTakeAskOf(project, e, { manifest, script, body, tuning = null, reading = null, red }) { + return postTakeAskOf(project, e, { + render: manifest?.render ?? {}, script, + engine: typeof body.engine === "string" && body.engine ? body.engine : null, + voice: typeof body.voice === "string" && body.voice ? body.voice : null, + speed: body.speed === undefined || body.speed === null ? null : Number(body.speed), + tuning, reading: reading === null || reading === undefined ? null : Number(reading), red, slurVoice: benchSlurVoice(red), + }); +}