Archilyzer · Source

archilyzer

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

commit 52d5cc8b08e7013afb5d9a1dec7b5a8ea94fc9d3
parent 1ba7c6bd915f94ae55f37625979f73ae5e99bdcf
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Tue, 17 Nov 2026 12:12:41 -0500

umtool bench: Keep this tuning for <character> on every Read again with a character

The Tune's keep runs character-set for the character whose synthetic preset
reads that piece (GET post-narration ?reads=<role>: a post's script, a thread
read, a screen line), its layer the cast or this video's own, then says what
was kept and what that leaves made with other settings (GET voices
?stale=<who>). No character, no button; a card's narration has none.

e2e: the bench test -- Read again asks the character's Lively ("preset"),
the Tune's numbers beat it (true), Keep writes the character, the card is
drawn as it was. The fixture's line-tuned take now says tuningAsked: true.
Docs: knobs.md, the changelog bullet.

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

Diffstat:
Meditor/CHANGELOG.md | 11++++++++++-
Mumtool/app/api/report/voices/route.ts | 8++++++++
Mumtool/components/projects/PostNarrationPanel.tsx | 10+++++++---
Mumtool/components/projects/PostThreadPanel.tsx | 5+++++
Mumtool/components/projects/ScreenLineVoice.tsx | 7++++++-
Aumtool/components/projects/read/keepForCharacter.ts | 63+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/docs/knobs.md | 11+++++++++++
Mumtool/e2e/character-tuning.spec.ts | 67+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/e2e/fixtures/tuning-fixture.mjs | 2+-
9 files changed, 178 insertions(+), 6 deletions(-)

diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md @@ -45,7 +45,16 @@ are asked with, the editor's takes when the character names none. - The reads made with other settings than the character's tuning now are counted and listed on the preset and the characters table, and by `umtool cast stale <p> [<character>]`. They are never re-made by themselves. - - `umtool cast try <p> <character>` is the Read it twin (`--reading N`, `--another`, `--list`, `--clear`). + - `umtool cast try <p> <character>` is the Read it twin (`--reading N`, `--another`, `--list`, `--clear`, + `--scope cast|project`). + - Every Orpheus read the character's preset answers for asks its tuning: a post's take (the CLI and the bench's Read + again), a thread read's pieces and its screen lines. A line's own numbers (flags, the bench's Tune) beat it field + by field. The take, and each thread part, records where its tuning came from: `tuningAsked` `"preset"` (the + character's: stale when that changes) or `true` (its own). A character with no tuning asks, keys and records + exactly as before (pinned against main). + - On the bench, the Tune's **Keep this tuning for <character>** keeps the numbers as the character's (the cast's, or + this video's own) and says what that leaves made with other settings. A re-read of a take whose tuning was the + character's asks the character's tuning as it is then. - **An Orpheus line can be read again differently: the tts op takes a `tuning` and a `reading`.** `pnpm ops tts` (`POST /api/ops/tts`) takes `tuning` (any of temperature 0.1–1.5, top_p 0.05–1, top_k 0–200, min_p 0–0.5, repeat_penalty 1–2, takes 1–6) and `reading` (0–99,999; reading r reads with seed base 1234 + 9973 × r). A value out diff --git a/umtool/app/api/report/voices/route.ts b/umtool/app/api/report/voices/route.ts @@ -29,6 +29,7 @@ export const dynamic = "force-dynamic"; // engines and their stock voices, the job running // GET ?project&who&voices=a,b[&text|&item] an audition as it is kept (auditionView: nothing asked) // GET ?job=<id>[&since&sinceEvent] that job +// GET ?project&stale=<who> the reads made with other settings than its tuning now (cast stale) // GET ?project&tries=<who>[&scope=cast|project] a character's TRIES (umtool cast try <p> <who> --list): its tuning, // the line the page prefills, the tries kept (newest first) // POST { project, op: "try", who, scope?, text, tuning: { temperature, top_p, repeat_penalty, takes? }, reading | another: true } @@ -179,6 +180,13 @@ export async function GET(request: Request) { const who = url.searchParams.get("who"); const tries = url.searchParams.get("tries"); try { + // The reads a character's tuning leaves stale (umtool cast stale <p> <who>): the bench's Keep for <character> says them. + const staleOf = url.searchParams.get("stale"); + if (staleOf) { + if (!whoOk(staleOf)) return Response.json({ error: "a character's id, or @handle" }, { status: 400 }); + const r = await cli(["stale", project.id, staleOf]); + return Response.json(r.code === 0 ? r.json : { error: r.error }, { status: r.code === 0 ? 200 : 400, headers }); + } if (tries) { if (!whoOk(tries)) return Response.json({ error: "a character's id, or @handle" }, { status: 400 }); const r = await cli(["try", project.id, tries, ...scopeArgs(url.searchParams.get("scope")), "--list"]); diff --git a/umtool/components/projects/PostNarrationPanel.tsx b/umtool/components/projects/PostNarrationPanel.tsx @@ -17,6 +17,7 @@ import type { PostPlan } from "./review/PostItemPlayer"; import { wordZoomTimes, zoomSpan } from "umtool-report-to-video/word-zoom"; import PostAttachmentLane from "./PostAttachmentLane"; import ReadAgain, { madeWithText, playNow, useAutoPlay, type KeepForCharacter, type Tuning } from "./read/ReadAgain"; +import { useKeepForCharacter } from "./read/keepForCharacter"; import { LEGACY_EDIT_TEXT, legacyReadOf } from "umtool-report-to-video/post-item"; // --------------------------------------------------------------------------- @@ -357,8 +358,11 @@ export default function PostNarrationPanel({ // What a convert of THIS post defaults to: its author's character in the cast (else the narrator) -- the engine, the // stock voice and the pitch every recording made that character's lands on (`umtool cast set <id> --convert-pitch …`). const [castConvert, setCastConvert] = useState<{ name: string; engine?: string | null; voice?: string | null; pitch?: string; semitones?: number } | null>(null); - // The character this item's read is made with (the convert's answer): S2 keeps a Tune for it. + // The character this item's read is made with (the convert's answer). const [character, setCharacter] = useState<{ id: string; name: string; layer?: string } | null>(null); + void character; + // The character whose SYNTHETIC preset reads his words now (lane character-tuning): a Tune is kept for it. + const readsAs = useKeepForCharacter(project, entry.id, "post"); useEffect(() => { let live = true; setCastConvert(null); @@ -819,8 +823,8 @@ export default function PostNarrationPanel({ onReadAgain={(t) => void press(() => readAgain(n.script ?? "", t))} onReadEdited={(t) => void press(() => readEdited(t))} madeWith={madeWith} - character={character} - keepForCharacter={keepForCharacter} + character={readsAs.character ?? null} + keepForCharacter={keepForCharacter ?? readsAs.keepForCharacter} autoplay={autoplay} onAutoplay={setAutoplay} /> diff --git a/umtool/components/projects/PostThreadPanel.tsx b/umtool/components/projects/PostThreadPanel.tsx @@ -2,6 +2,7 @@ import { useEffect, useMemo, useRef, useState } from "react"; import ReadAgain, { playNow, useAutoPlay, type Tuning } from "./read/ReadAgain"; +import { useKeepForCharacter } from "./read/keepForCharacter"; import { THREAD_DEFAULTS, THREAD_LIMITS, THREAD_MODES, partRoles, readPieces, threadKnobs, threadLayout, threadReadErrors } from "umtool-report-to-video/post-thread"; import { followKnobs } from "umtool-report-to-video/read-follow"; import { pickedTake } from "umtool-report-to-video/post-narration"; @@ -43,6 +44,8 @@ export default function PostThreadPanel({ onEntry?: (e: Entry, token: string | null) => void; }) { const own = (entry.thread ?? undefined) as Thread | undefined; + // The character whose synthetic preset reads his words (lane character-tuning): the thread's Tune is kept for it. + const readsAs = useKeepForCharacter(project, entry.id, "post"); const k = threadKnobs(entry, render) as Required<Thread>; const layout = useMemo(() => threadLayout(entry, render, { prev: before, scene }), [entry, render, before, scene]); const roles = useMemo(() => partRoles(entry) as Array<{ role: string | null; source: string }>, [entry]); @@ -170,6 +173,8 @@ export default function PostThreadPanel({ waiting={again?.state === "running" ? again.waiting ?? null : null} onReadAgain={(t) => void readThreadAgain(t)} madeWith={playing.parts?.find((p) => p.tuning)?.tuning ?? null} + character={readsAs.character} + keepForCharacter={readsAs.keepForCharacter} error={again?.state === "failed" ? again.error ?? "failed" : null} note={again?.said ?? null} autoplay={autoplay} diff --git a/umtool/components/projects/ScreenLineVoice.tsx b/umtool/components/projects/ScreenLineVoice.tsx @@ -3,6 +3,7 @@ import { useCallback, useEffect, useRef, useState } from "react"; import { useMic, ls } from "./useMic"; import ReadAgain, { playNow, useAutoPlay, type Tuning } from "./read/ReadAgain"; +import { useKeepForCharacter } from "./read/keepForCharacter"; // --------------------------------------------------------------------------- // A SCREEN LINE IN THE OPERATOR's VOICE, on the post bench's screens section (lib/report/screenLineRecord.mjs; the @@ -175,7 +176,7 @@ export function useScreenVoice({ project, id, onEntry, unsaved }: { project: str } follow({ id: j.job.id, what: "read", state: j.job.state }); }; - return { mic, at, phase, takes, job, status, prompts, record, stop, redo, keep, makeRead, readLine, pickTake, landed, autoplay, setAutoplay, project }; + return { mic, at, phase, takes, job, status, prompts, record, stop, redo, keep, makeRead, readLine, pickTake, landed, autoplay, setAutoplay, project, id }; } export type ScreenVoice = ReturnType<typeof useScreenVoice>; @@ -199,6 +200,8 @@ export function lineReadings(entry: Record<string, unknown>, role: string): Line /** ONE READ LINE's voice cell: Record / Stop / play back / Redo / Keep, and the take chosen for it. */ export function ScreenLineVoice({ role, n, voice, dirty, options, chosen, onChoose, readings = [], edited = false }: { role: string; n: number; voice: ScreenVoice; dirty: boolean; options: LineTakeOption[]; chosen: string | undefined; onChoose: (id: string | undefined) => void; readings?: LineReading[]; edited?: boolean }) { const mine = voice.at === role && voice.phase === "recording"; + // The character whose synthetic preset reads this line (its speaker's; lane character-tuning): a Tune is kept for it. + const readsAs = useKeepForCharacter(voice.project, voice.id, role); const t = voice.takes[role]; const busy = voice.job?.state === "running"; const other = voice.phase === "recording" && voice.at !== role; @@ -244,6 +247,8 @@ export function ScreenLineVoice({ role, n, voice, dirty, options, chosen, onChoo onReadAgain={(t) => void voice.readLine(role, t)} onReadEdited={(t) => void voice.readLine(role, t)} madeWith={readings.find((x) => x.picked)?.tuning ?? null} + character={readsAs.character} + keepForCharacter={readsAs.keepForCharacter} autoplay={voice.autoplay} onAutoplay={voice.setAutoplay} /> diff --git a/umtool/components/projects/read/keepForCharacter.ts b/umtool/components/projects/read/keepForCharacter.ts @@ -0,0 +1,63 @@ +"use client"; + +import { useEffect, useMemo, useState } from "react"; +import type { KeepForCharacter, Tuning } from "./ReadAgain"; + +// --------------------------------------------------------------------------- +// "KEEP FOR <CHARACTER>" (lane character-tuning; ReadAgain.tsx's seam): a Tune's numbers kept as the CHARACTER's -- +// the one whose synthetic preset reads this piece of the item now (GET /api/report/post-narration?reads=<role>), +// through its command (`umtool cast set <id> …` for a cast character, `cast project <p> set <id> …` for this video's +// own: /api/report/voices op "character-set"), then what that leaves stale (`umtool cast stale <p> <id>`). Every read +// of the character asks it from then on, unless its own line asks another; nothing is re-read by itself. +// --------------------------------------------------------------------------- + +export type ReadCharacter = { id: string; name: string; layer: "cast" | "project" }; + +/** The character whose preset reads `role` of item `id` now (null: none -- no button). */ +export function useReadCharacter(project: string | null | undefined, id: string, role = "post"): ReadCharacter | null { + const [c, setC] = useState<ReadCharacter | null>(null); + useEffect(() => { + if (!project) return; + let live = true; + fetch(`/api/report/post-narration?project=${encodeURIComponent(project)}&id=${encodeURIComponent(id)}&reads=${encodeURIComponent(role)}`, { cache: "no-store" }) + .then((r) => (r.ok ? r.json() : null)) + .then((j: { character?: ReadCharacter | null } | null) => { + if (live) setC(j?.character && (j.character.layer === "cast" || j.character.layer === "project") ? j.character : null); + }) + .catch(() => { + if (live) setC(null); + }); + return () => { + live = false; + }; + }, [project, id, role]); + return c; +} + +const words = (t: Tuning) => Object.entries(t).map(([k, v]) => `${k.replace("_", " ")} ${v}`).join(", ") || "the defaults"; + +/** + * The seam's function for one character: keep `tuning` as its own -- exactly these numbers (a sampler value left out + * is its default; takes left out is the editor's setting) -- and say what was kept and what that leaves stale, this + * item first. A refusal is said in the command's words ("not kept: …"). + */ +export function keepTuningFor(project: string, item: string, c: ReadCharacter): KeepForCharacter { + return async (t) => { + const tuning = { temperature: t.temperature ?? null, top_p: t.top_p ?? null, repeat_penalty: t.repeat_penalty ?? null, takes: t.takes ?? null, ...(t.top_k !== undefined ? { top_k: t.top_k } : {}), ...(t.min_p !== undefined ? { min_p: t.min_p } : {}) }; + const r = await fetch("/api/report/voices", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ project, op: "character-set", scope: c.layer, id: c.id, tuning }) }).catch(() => null); + const j = (await r?.json().catch(() => null)) as { error?: string; notes?: string[] } | null; + if (!r?.ok) return `not kept: ${j?.error ?? (r ? `HTTP ${r.status}` : "umtool could not be reached")}`; + const where = c.layer === "cast" ? "the cast: every project" : "this video only"; + const s = await fetch(`/api/report/voices?project=${encodeURIComponent(project)}&stale=${encodeURIComponent(c.id)}`, { cache: "no-store" }).then((x) => (x.ok ? x.json() : null)).catch(() => null) as { count?: number; items?: string[] } | null; + const items = s?.items ?? []; + const stale = !s ? "" : items.length ? ` · ${items.includes(item) ? "this read was" : `${items.length} read${items.length === 1 ? " was" : "s were"}`} made with other settings${items.includes(item) && items.length > 1 ? ` (and ${items.length - 1} more: ${items.filter((x) => x !== item).join(", ")})` : items.includes(item) ? "" : `: ${items.join(", ")}`}` : " · every read of theirs is made with these"; + return `kept for ${c.name} (${where}): ${words(t)}${(j?.notes ?? []).map((n) => ` · ${n}`).join("")}${stale}`; + }; +} + +/** The seam for one piece of one item: its character's keeper, or undefined (no character: no button). */ +export function useKeepForCharacter(project: string | null | undefined, id: string, role = "post"): { character: ReadCharacter | null; keepForCharacter: KeepForCharacter | undefined } { + const character = useReadCharacter(project, id, role); + const keepForCharacter = useMemo(() => (project && character ? keepTuningFor(project, id, character) : undefined), [project, id, character]); + return { character, keepForCharacter }; +} diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -1867,6 +1867,17 @@ editor's `tts.orpheus.takes`, and the preset and `--json` say that number, never cast|project` looks the character up in one layer (the preset's: the cast and this video may both hold an id). - **Keep these settings** runs `cast set` (a cast character) or `cast project <p> set` (this video's own): one write, an undo point. +- **Where it is asked:** a post's take (`posts narrate --take`, the bench's Read again), every piece of a thread read + and each screen line, when the character's preset answers for its voice and the engine is Orpheus. A line's own + tuning (the flags, the bench's Tune, a `--for`/`--tuned` piece) beats it field by field (a line asking only its takes + keeps the character's sampler). The take records `tuningAsked`: `"preset"` (the character's) or `true` (its own); a + thread read's parts each record theirs, and its `read.tuned` keeps only the read's own, so a later read asks the + character's as it is then. `cast reread` of a take whose tuning was the character's passes its reading, not its old + tuning. A character with no tuning: every ask, key and record as before. +- **Keep for the character, on the bench:** the Tune's **Keep this tuning for <character>** (a post's script, a thread + read, a screen line: the character whose preset reads that piece, `GET /api/report/post-narration?reads=<role>`) + runs the same `cast set` / `cast project <p> set`, and says what was kept and what that leaves made with other + settings (`umtool cast stale`). - **Stale, never re-made:** a picked Orpheus read of the character is made with OTHER SETTINGS when its character's preset answers for it now in the voice it was made in, its tuning was not asked by its own line (the take's `tuningAsked` is not `true`; a take that says nothing but records a tuning off the defaults was asked so), and the diff --git a/umtool/e2e/character-tuning.spec.ts b/umtool/e2e/character-tuning.spec.ts @@ -51,6 +51,12 @@ const reset = () => { for (const f of [MANIFEST, CHARACTERS]) copyFileSync(`${f}.pristine`, f); rmSync(CHARACTERS.replace(/\.json$/, ".undo.json"), { force: true }); rmSync(path.join(DIR, "narration", "auditions"), { recursive: true, force: true }); + // The takes a test made (the fixture's own are each post's take-1), and a read's marker. + for (const id of ["1", "2", "3"]) { + const dir = path.join(DIR, "narration", "posts", id); + if (!existsSync(dir)) continue; + for (const f of readdirSync(dir)) if (!f.startsWith("take-1.")) rmSync(path.join(dir, f), { recursive: true, force: true }); + } }; test.beforeEach(() => { test.setTimeout(240_000); @@ -205,3 +211,64 @@ test("a character's tuning: Lively, Read it, Another reading, Keep -- its stale expect(await drawn()).toEqual(cardsBefore); expect(takeFiles()).toEqual(takesBefore); }); + +// THE BENCH (after S3, lane line-rerun): the character's tuning reaches its post's Read again; the Tune's numbers beat +// it; "Keep this tuning for <character>" keeps them as the character's (cast project <p> set) and says what that leaves +// stale -- and the card draws what it drew. +type BenchTake = { file: string; tuning?: Record<string, number>; tuningAsked?: true | "preset"; reading?: number }; +const takesOf = (id: string) => ((JSON.parse(readFileSync(MANIFEST, "utf8")) as { timeline: { id: string; narration?: { takes?: BenchTake[] } }[] }).timeline.find((e) => e.id === id)!.narration?.takes ?? []); +const benchAsks = () => (existsSync(STUB_LOG) ? (JSON.parse(readFileSync(STUB_LOG, "utf8")) as (Tts & { out?: string })[]) : []).filter((r) => r.route === "tts" && String(r.out ?? "").includes("/tuning-fixture/narration/posts/1/")); +const drawnCard = async (page: import("@playwright/test").Page) => { + const frame = page.frameLocator('[data-post-card-frame="read"]'); + await expect(frame.locator("[data-post-words]")).toContainText("bridge", { timeout: 15_000 }); + return frame.locator("body").evaluate((b) => ({ + words: b.querySelector("[data-post-words]")?.textContent ?? null, + blocks: [...b.querySelectorAll("[data-post-block]")].map((x) => [x.getAttribute("data-post-block"), x.textContent]), + tiles: [...b.querySelectorAll("[data-thread-tile]")].map((x) => [x.getAttribute("data-thread-tile"), x.getAttribute("data-thread-mode")]), + follow: b.getAttribute("data-post-follow"), + })); +}; + +test("the post bench: Read again asks the character's Lively (\"preset\"); the Tune's numbers beat it (true); Keep for the character -- the card unchanged", async ({ page }) => { + await page.setViewportSize({ width: 1440, height: 1400 }); + await page.goto(urls.voicesHref(P)); + // The character's tuning, kept through its command (the Voices page's Keep is the first test's). + const kept0 = await page.evaluate(async (project) => { + const r = await fetch("/api/report/voices", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ project, op: "character-set", scope: "project", id: "teller", tuning: { temperature: 0.75, top_p: 0.92, repeat_penalty: 1.25 } }) }); + return r.status; + }, P); + expect(kept0).toBe(200); + await page.goto(urls.postBenchHref(P, "p-1")); + const panel = page.locator('[data-post-narration="p-1"]'); + await expect(panel.locator("[data-post-take]")).toHaveCount(1, { timeout: 30_000 }); + const before = await drawnCard(page); + const asked0 = benchAsks().length; + + // Read again: the character's tuning asked, recorded as its ("preset"). + await panel.locator('[aria-label="Read again"]').click(); + await expect(panel.locator("[data-post-take]")).toHaveCount(2, { timeout: 30_000 }); + expect(benchAsks().length).toBe(asked0 + 1); + expect(benchAsks().at(-1)!.tuning).toEqual({ temperature: 0.75, top_p: 0.92, repeat_penalty: 1.25 }); + expect(takesOf("p-1")[1]).toMatchObject({ tuningAsked: "preset", tuning: { temperature: 0.75, top_p: 0.92, repeat_penalty: 1.25 } }); + + // The Tune's numbers, this line only: they beat the character's, and say so (true). + await panel.locator("[data-read-tune] summary").click(); + await panel.locator('[aria-label="temperature, this line only"]').fill("0.9"); + await panel.locator('[aria-label="Read again with this tuning"]').click(); + await expect(panel.locator("[data-post-take]")).toHaveCount(3, { timeout: 30_000 }); + expect(benchAsks().at(-1)!.tuning?.temperature).toBe(0.9); + expect(takesOf("p-1")[2]).toMatchObject({ tuningAsked: true }); + expect(takesOf("p-1")[2].tuning?.temperature).toBe(0.9); + + // Keep this tuning for the character: its command; what it kept, and that this read (the picked one, made with the + // defaults) was made with other settings. + await panel.getByRole("button", { name: "Keep this tuning for The Teller" }).click(); + await expect(panel.locator("[data-read-tune-kept]")).toContainText("kept for The Teller (this video only)", { timeout: 15_000 }); + await expect(panel.locator("[data-read-tune-kept]")).toContainText("this read was made with other settings"); + const teller = (JSON.parse(readFileSync(CHARACTERS, "utf8")) as { characters: { id: string; synthetic?: { tuning?: Record<string, number> } }[] }).characters.find((c) => c.id === "teller"); + expect(teller?.synthetic?.tuning?.temperature).toBe(0.9); + + // The card draws what it drew: no take was picked, no words changed. + await page.reload(); + expect(await drawnCard(page)).toEqual(before); +}); diff --git a/umtool/e2e/fixtures/tuning-fixture.mjs b/umtool/e2e/fixtures/tuning-fixture.mjs @@ -35,7 +35,7 @@ export function makeTuningFixture({ reports, manifest, ff }) { }; const timeline = [ post("1", TUNING_LINE, { file: "narration/posts/1/take-1.orpheus-tara.wav", engine: "orpheus", voice: "tara", tuning: made(), reading: 0 }), - post("2", "The teller answers a second question about the ferry and its fares.", { file: "narration/posts/2/take-1.orpheus-tara.wav", engine: "orpheus", voice: "tara", tuning: made({ temperature: 0.9 }), reading: 0 }), + post("2", "The teller answers a second question about the ferry and its fares.", { file: "narration/posts/2/take-1.orpheus-tara.wav", engine: "orpheus", voice: "tara", tuning: made({ temperature: 0.9 }), reading: 0, tuningAsked: true }), post("3", "The teller reads this one aloud in a voice of his own.", { file: "narration/posts/3/take-1.recorded.wav", engine: "recorded", voice: "operator" }), ]; for (const e of timeline) tone(e.narration.takes[0].file);