Archilyzer · Source

archilyzer

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

commit f3bd7644a8834e85710541ae6653488621a20b4d
parent 712a19dd74e0b83493b5f9c3ff5866c7f0fe361a
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Tue, 17 Nov 2026 10:57:45 -0500

umtool review 1 (musts 1, 3; should 8): the tiles keep their times, the playing take decides the card

- Finding 1: read-follow.mjs keeps the take part each followParts part stands for (`at`) and each block says it
  (`takePart`); post-thread.mjs threadSchedule and the two lints key a piece by the take's parts. Pin: the tiles'
  t0/t1 of the unedited items hashed as main schedules them (recorded by running 4c45f197b's report-to-video on
  the fixtures), every edited variant the same; a single read in parts with no roles pinned too.
- Finding 3 (the orchestrator's ruling): the writer stamps a take `forReading` when it is made from words that are
  not the post's as drafted (post-item.mjs takeIsEditedRead); readEditOf decides by the PLAYING take;
  narration.forReading only with no take playing. Pin: probe 4's sequence, an older edited take re-picked, the
  plural writer's redraft while an edited take plays.
- Finding 8: legacy is a playing take from before the rule (legacyReadOf); --list (json readEdit) and the bench say
  "read it again to move it to the new rule"; Save script no longer pretends to.

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

Diffstat:
Mumtool/components/projects/PostNarrationPanel.tsx | 6+++---
Mumtool/docs/knobs.md | 22++++++++++++----------
Mumtool/lib/report/manifest.mjs | 6+++++-
Mumtool/lib/report/postNarrationCli.mjs | 8++++----
Mumtool/lib/report/postReadAgain.test.mjs | 39++++++++++++++++++++++++++++++++++++---
Mumtool/lib/report/threadTuned.test.mjs | 25++++++++++++++++++++++++-
Mumtool/report-to-video/post-item.mjs | 48++++++++++++++++++++++++++++++++++++++++--------
Mumtool/report-to-video/post-narration.mjs | 5++++-
Mumtool/report-to-video/post-reading-pin.test.mjs | 55++++++++++++++++++++++++++++++++++++++++++++++++++++---
Mumtool/report-to-video/post-thread.mjs | 16++++++++++------
Mumtool/report-to-video/read-follow.mjs | 25+++++++++++++++----------
11 files changed, 205 insertions(+), 50 deletions(-)

diff --git a/umtool/components/projects/PostNarrationPanel.tsx b/umtool/components/projects/PostNarrationPanel.tsx @@ -17,7 +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 { LEGACY_EDIT_TEXT, scriptEditOf } from "umtool-report-to-video/post-item"; +import { LEGACY_EDIT_TEXT, legacyReadOf } from "umtool-report-to-video/post-item"; // --------------------------------------------------------------------------- // A POST's NARRATION ON THE BENCH (report-to-video/post-narration.mjs; @@ -264,7 +264,7 @@ export default function PostNarrationPanel({ const same = synth.filter((t) => (t.script ?? "").replace(/\s+/g, " ").trim() === (n.script ?? "").replace(/\s+/g, " ").trim()); return (same.at(-1) ?? (picked?.tuning ? picked : null) ?? synth.at(-1))?.tuning ?? null; }, [takes, n.script, picked]); - const legacy = scriptEditOf(entry) === "legacy"; + const legacy = legacyReadOf(entry); useEffect(() => { if (!job || job.state !== "running") return; const t = setTimeout(async () => { @@ -790,7 +790,7 @@ export default function PostNarrationPanel({ onAutoplay={setAutoplay} /> <div className="flex flex-wrap items-center gap-1.5"> - <button type="button" className={btn} disabled={script === (n.script ?? "") && !legacy} onClick={() => void set({ script })} data-post-script-save=""> + <button type="button" className={btn} disabled={script === (n.script ?? "")} onClick={() => void set({ script })} data-post-script-save=""> Save script </button> <input value={dir.note} onChange={(e) => setDir({ ...dir, note: e.target.value })} placeholder="direction (kept with the take)" className="min-w-0 flex-1 rounded border border-seam bg-ground px-1.5 py-0.5" data-post-retake-note="" /> diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -1547,16 +1547,18 @@ deleted by a re-read; recorded takes and their enhance/convert chain are untouch keeps the parts-cache key it always had. - **One read of a post at a time**: a second press while one is made is refused in place (409), never asked twice. While render mode holds the machine a pressed read says it is waiting for the render, and is made when it ends. -- **The card follows the shown text** (`narration.forReading`): a script saved on the bench (or by `--script`, or a - take that carries one) that differs from the post's words as drafted is marked for reading by the same writer - (`updatePostNarration`; undo restores it with the script). With the mark, the post's blocks, the lit/dim follow and - the parts' roles come from the post's words as drafted -- timed by the read's parts one for one, else shared by words - over the span his parts were read in -- so no spoken edit moves, hides or dims for good a drawn word, or changes a - thread tile's mode (`read-follow.mjs followParts`, `post-thread.mjs partRoles`). A script saying what a screen masks - or a redacted line holds is refused when it is written. -- **Edited before the rule** (a script that differs from the post's words, with no mark): its card follows the script, - as it always did. `umtool posts narrate <p> --list` flags it (`--json`: `scriptEdit: "legacy"`), the bench says so in - one line, and saving the script again moves it to the rule. Nothing migrates by itself. +- **The card follows the shown text; the playing take decides** (review 1's ruling). A take is stamped `forReading` + by the writer when it is made from words that are not the post's as drafted (a script edited for reading, a lexicon + word, a tag). While a stamped take plays, the post's blocks, the lit/dim follow and the parts' roles come from the + post's words as drafted -- timed by the read's parts one for one, else shared by words over the span his parts were + read in -- and the thread tiles keep their times, so no spoken edit moves, hides or dims for good a drawn word, or + changes when or how a thread tile shows (`read-follow.mjs followParts`, `post-thread.mjs partRoles`, + `threadSchedule`). Saving the script back, re-picking an older take or redrafting scripts changes nothing while that + take plays. `narration.forReading` (set by the script's writer) decides only for an item with no take playing. A + script saying what a screen masks or a redacted line holds is refused when it is written. +- **A playing take from before the rule** (no stamp, and its words are not the post's): its card follows its words, as + it always did. `umtool posts narrate <p> --list` flags it (`--json`: `readEdit: "legacy"`), the bench says so in one + line: read it again to move it to the rule. Nothing migrates by itself. - **Keep for the character** (S2, lane character-tuning) is a seam: `ReadAgain`'s `keepForCharacter` prop; absent, no button. diff --git a/umtool/lib/report/manifest.mjs b/umtool/lib/report/manifest.mjs @@ -67,7 +67,7 @@ import { variantsProblems, verdictOfInput, } from "./knobs.mjs"; import { validateNarration } from "umtool-report-to-video/narration"; -import { postReadText, saysShownDraft, shownDraftOf, validatePostItem, validatePostItems } from "umtool-report-to-video/post-item"; +import { postReadText, saysShownDraft, shownDraftOf, takeIsEditedRead, validatePostItem, validatePostItems } from "umtool-report-to-video/post-item"; import { spokenSaysHiddenErrors, threadReadErrors } from "umtool-report-to-video/post-thread"; import { planContext } from "umtool-report-to-video/post-conversation"; import { followKnobs } from "umtool-report-to-video/read-follow"; @@ -3440,6 +3440,10 @@ export function postNarrationIn(m, id, patch, { forReading = false } = {}) { } } if (isObj(patch.addTake)) { + // STAMPED WHEN IT IS MADE (review 1, finding 3; the orchestrator's ruling): a take whose words are not the post's + // as drafted is a read edited for reading -- while it plays the card follows the shown text, whatever the script + // says later (post-item.mjs readEditOf). + if (patch.addTake.forReading === undefined && takeIsEditedRead(e, patch.addTake)) patch.addTake.forReading = true; n.takes.push(patch.addTake); if (patch.keepPick !== true) n.pick = n.takes.length - 1; } diff --git a/umtool/lib/report/postNarrationCli.mjs b/umtool/lib/report/postNarrationCli.mjs @@ -29,7 +29,7 @@ import { } from "umtool-report-to-video/post-narration"; import { CAST_CONVERT_PITCH, CAST_SEMITONES_MAX, convertPitchLabel } from "umtool-report-to-video/cast"; import { convertAskOf, stepPitchOf } from "./derivePitch.mjs"; -import { LEGACY_EDIT_TEXT, excerptSpansOf, postItemPlan, postReadText, scriptEditOf } from "umtool-report-to-video/post-item"; +import { LEGACY_EDIT_TEXT, excerptSpansOf, legacyReadOf, postItemPlan, postReadText, readEditOf } from "umtool-report-to-video/post-item"; import { partRoles } from "umtool-report-to-video/post-thread"; import { spokenRead } from "umtool-report-to-video/post-redact"; import { projectRedaction } from "./postRedaction.mjs"; @@ -279,8 +279,8 @@ export function narrationLines(e, render) { `${e.id} ${isNarrated(e) ? "NARRATED" : n.off ? "narration off" : "not narrated"}${n.approved ? " · approved" : ""} ${plan.total.toFixed(2)} s`, ` script: ${n.script ? JSON.stringify(n.script) : "(none)"}`, ]; - // EDITED BEFORE READS WERE KEPT APART FROM THE CARD (post-item.mjs scriptEditOf "legacy"): its card follows the script. - if (scriptEditOf(e) === "legacy") lines.push(` ${LEGACY_EDIT}`); + // ITS PLAYING TAKE PREDATES THE RULE (post-item.mjs legacyReadOf): its card follows what that take says. + if (legacyReadOf(e)) lines.push(` ${LEGACY_EDIT}`); (n.takes ?? []).forEach((tk, i) => { const tuned = [...(Number.isInteger(tk.reading) && tk.reading > 0 ? [`reading ${tk.reading}`] : []), ...Object.entries(normalizeTtsTuning(tk.tuning)).map(([k, v]) => `${k} ${v}`)]; lines.push(` ${t?.index === i ? "▶" : " "} #${i + 1} ${tk.file} ${Number(tk.seconds).toFixed(2)} s ${tk.engine ?? "?"} · ${tk.voice ?? "?"}${tuned.length ? ` ${tuned.join(", ")}` : ""}${tk.parts?.length ? ` ${tk.parts.length} parts` : ""}${tk.note ? ` note: ${tk.note}` : ""}${tk.script && tk.script !== n.script ? " (an older script)" : ""}`); @@ -632,7 +632,7 @@ export async function narrateCommand(project, words, flags, { json = false, dryR } if (flags.has("--list") || (!ref && !flags.has("--all"))) { - if (json) out(JSON.stringify({ ok: true, items: tl.map((e) => ({ id: e.id, narrated: isNarrated(e), narration: e.narration ?? null, seconds: postItemPlan(e, render).total, ...(scriptEditOf(e) ? { scriptEdit: scriptEditOf(e) } : {}) })) }, null, 2)); + if (json) out(JSON.stringify({ ok: true, items: tl.map((e) => ({ id: e.id, narrated: isNarrated(e), narration: e.narration ?? null, seconds: postItemPlan(e, render).total, ...(legacyReadOf(e) ? { readEdit: "legacy" } : readEditOf(e) === "reading" ? { readEdit: "reading" } : {}) })) }, null, 2)); else { const narrated = tl.filter(isNarrated).length; out(`${project.id}: ${tl.length} post item(s), ${narrated} narrated, ${tl.filter((e) => e.narration?.approved).length} approved`); diff --git a/umtool/lib/report/postReadAgain.test.mjs b/umtool/lib/report/postReadAgain.test.mjs @@ -95,12 +95,45 @@ test("A SPOKEN EDIT that says what a screen masks (an e-mail, a number) or a red assert.equal((await manifest(p)).timeline[0].narration.forReading, true); }); -test("EDITED BEFORE THE RULE: --list (and --json) says which items' scripts were edited before reads were kept apart from the card", async () => { - const p = await project("legacy", [item({ narration: { script: "Something else entirely." } }), { ...item({ narration: { script: shownDraftOf(item()) } }), id: "p-2", post: "ferry-x/2" }]); +test("A PLAYING TAKE FROM BEFORE THE RULE: --list (and --json) says which items play a take read from other words with no stamp -- read it again to move it", async () => { + const old = (script) => ({ script, pick: 0, takes: [{ file: "narration/posts/1/take-1.orpheus-zac.wav", engine: "orpheus", voice: "zac", seconds: 1, script }] }); + const p = await project("legacy", [item({ narration: old("Something else entirely.") }), { ...item({ narration: old(shownDraftOf(item())) }), id: "p-2", post: "ferry-x/2" }, { ...item({ narration: { script: "Unread other words." } }), id: "p-3", post: "ferry-x/3" }]); const r = await cli(["narrate", p.id, "--list"]); assert.equal(r.code, 0, r.out); assert.equal(r.out.split(LEGACY_EDIT).length - 1, 1, r.out); const j = await cli(["narrate", p.id, "--list", "--json"]); const items = JSON.parse(j.out).items; - assert.deepEqual(items.map((x) => x.scriptEdit ?? null), ["legacy", null]); + assert.deepEqual(items.map((x) => x.readEdit ?? null), ["legacy", null, null], "an item with no take playing is not flagged"); +}); + +// --------------------------------------------------------------------------- +// THE PLAYING TAKE DECIDES (review 1, finding 3; the orchestrator's ruling): a take is stamped `forReading` when it is +// made from words that are not the post's as drafted, and the card follows the shown text while a stamped take plays -- +// whatever the script says afterwards. `narration.forReading` decides only with no take playing. +// --------------------------------------------------------------------------- + +test("RULING 3 HOLDS when the script is saved back to the post's words while an edited take still plays, when an older edited take is picked again, and after --draft-scripts --force", async () => { + const { postNarrationIn } = await import("./manifest.mjs"); + const { FIXTURES, drawn, singleItem, threadItem } = await import("../../report-to-video/post-reading-pin.fixtures.mjs"); + void FIXTURES; + const drafted = shownDraftOf(singleItem()); + const edited = "The council met on Tuesday about the new bridge."; + const m = { timeline: [singleItem({ parents: [threadItem().parents[0]], thread: { parent: "excerpt" } })] }; + const base = drawn(m.timeline[0]); + // Edited, read, picked. + postNarrationIn(m, "p-7003", { script: edited, addTake: { file: "narration/posts/7003/take-2.orpheus-zac.wav", engine: "orpheus", voice: "zac", seconds: 3, script: edited } }, { forReading: true }); + assert.equal(m.timeline[0].narration.takes[1].forReading, true, "the take is stamped when it is made"); + assert.deepEqual(drawn(m.timeline[0]), base); + // The script saved back to the post's words, no read: the edited take still plays -- the card as before. + postNarrationIn(m, "p-7003", { script: drafted }, { forReading: true }); + assert.deepEqual(drawn(m.timeline[0]), base); + // A read of the post's words (no stamp), picked; then the older edited take picked again. + postNarrationIn(m, "p-7003", { addTake: { file: "narration/posts/7003/take-3.orpheus-zac.wav", engine: "orpheus", voice: "zac", seconds: 6, script: drafted } }, { forReading: true }); + assert.equal("forReading" in m.timeline[0].narration.takes[2], false, "a take of the post's words is not stamped"); + assert.deepEqual(drawn(m.timeline[0]), base); + postNarrationIn(m, "p-7003", { pick: 1 }, { forReading: true }); + assert.deepEqual(drawn(m.timeline[0]), base); + // --all --draft-scripts --force (the plural writer) while the edited take plays. + postNarrationIn(m, "p-7003", { script: drafted }); + assert.deepEqual(drawn(m.timeline[0]), base); }); diff --git a/umtool/lib/report/threadTuned.test.mjs b/umtool/lib/report/threadTuned.test.mjs @@ -8,7 +8,7 @@ import path from "node:path"; 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 { nextPartReading, partKey, threadReadPlan, threadTake, tuneSig } from "./postThreadRead.mjs"; +import { ThreadReadError, nextPartReading, partKey, threadReadPlan, threadTake, tuneSig, upToDate } from "./postThreadRead.mjs"; import { threadTunedOf, tuningFlags } from "./postNarrationCli.mjs"; import { playingTuned } from "./postScreensCli.mjs"; import { threadArgvOf } from "./castProject.mjs"; @@ -110,3 +110,26 @@ test("the playing read's readings are KEPT by a later read while each piece says assert.equal(plan.pieces.find((x) => x.role === "screen:s1:0").reading, undefined); assert.deepEqual(threadArgvOf(e.narration.takes[0].read).filter((x, i, a) => x === "--tuned" || a[i - 1] === "--tuned"), ["--tuned", "screen:s1:0=reading:3"]); }); + +test("UP TO DATE IS PER PIECE (review 1, finding 2): a line asked at another reading is never 'up to date' because another line already has that reading", () => { + const mk = (r) => ["screen:s1:0", "screen:s1:1", "screen:s1:2"].map((role, i) => ({ role, voice: "leo", engine: "orpheus", text: `line ${i}`, file: `x${i}`, start: i, seconds: 1, ...(r[i] ? { reading: r[i] } : {}) })); + const post = { role: "post", voice: "zac", engine: "orpheus", text: "his words", file: "p", start: 9, seconds: 1 }; + const want = "his words\n\nline 0\n\nline 1\n\nline 2"; + const e = { narration: { pick: 0, takes: [{ file: "t.wav", seconds: 5, script: want, voice: "zac+leo", engine: "orpheus", parts: [post, ...mk([0, 1, 0])], read: { kind: "thread" } }] } }; + assert.equal(nextPartReading(e, "screen:s1:2", "line 2"), 1); + assert.equal(upToDate(e, { want, voice: "zac+leo", engine: "orpheus", pieces: [post, ...mk([0, 1, 1])] }), false); + assert.equal(upToDate(e, { want, voice: "zac+leo", engine: "orpheus", pieces: [post, ...mk([0, 1, 0])] }), true); +}); + +test("A RECORDED PIECE asked to be read again is refused in a sentence; a read with nothing synthesized to read again too; an unknown piece too", async () => { + const p = await project("recorded"); + const asked = []; + await threadTake(p, (await read(p)).timeline[0], { red: NO_RED, ask: stubAsk(asked), lanes: null, ...LAYERS }); + const e = (await read(p)).timeline[0]; + // His line from take 1 (a recording of his words would be read in his piece's place). + await wavOf(path.join(p.dir, "narration/posts/7/take-9.recorded-me.wav")); + const rec = { file: "narration/posts/7/take-9.recorded-me.wav", engine: "recorded", voice: "me", seconds: 1, script: "Here is what they sent.", source: { kind: "recorded", voice: "me" } }; + const withRec = { ...e, narration: { ...e.narration, takes: [...e.narration.takes, rec] } }; + await assert.rejects(() => threadTake(p, withRec, { red: NO_RED, ask: stubAsk(asked), lanes: null, ...LAYERS, postTake: 2, tuned: { post: { reading: "next" } } }), (err) => err instanceof ThreadReadError && /is read from take 2/.test(err.message)); + await assert.rejects(() => threadTake(p, e, { red: NO_RED, ask: stubAsk(asked), lanes: null, ...LAYERS, tuned: { "screen:s9:0": { reading: "next" } } }), (err) => err instanceof ThreadReadError && /no piece screen:s9:0/.test(err.message)); +}); diff --git a/umtool/report-to-video/post-item.mjs b/umtool/report-to-video/post-item.mjs @@ -30,7 +30,7 @@ // and the card's HTML. import { - draftScript, isNarrated, narrationSchedule, postNarrationFiles, postNarrationKnobs, validatePostNarration, + draftScript, isNarrated, narrationSchedule, pickedTake, postNarrationFiles, postNarrationKnobs, validatePostNarration, } from "./post-narration.mjs"; import { BAR_CSS, barsHtml, hasMarks, projectRedactOf, redactEntry, redactSceneRef, redactionOn, validatePostsRender } from "./post-redact.mjs"; import { blurErrors, blurOn, censorEntry } from "./post-censor.mjs"; @@ -179,17 +179,16 @@ const spacing = (t) => str(t).split(/\n\s*\n/).map((x) => x.replace(/\s+/g, " ") /** Whether `script` says his words as drafted (shownDraftOf), paragraph for paragraph: not an edit for reading. */ export const saysShownDraft = (entry, script) => spacing(script) === spacing(shownDraftOf(entry)); -/** What an item edited before the rule is told (`posts narrate --list`, the bench): the fact, and what moves it. */ -export const LEGACY_EDIT_TEXT = "edited before reads were kept apart from the card: its card follows the script -- save the script again to keep the card to the post's words"; +/** What an item whose playing take predates the rule is told (`posts narrate --list`, the bench), and what moves it. */ +export const LEGACY_EDIT_TEXT = "its playing take was read before reads were kept apart from the card, so the card follows what that take says -- read it again to move it to the new rule"; /** * Whether a script is the post's words EDITED FOR READING (lane line-rerun; operator ruling 3, 15 Nov 2026: an edit - * changes only what is spoken) -- `script` the one to judge (default: the item's own): + * changes only what is spoken) -- `script` the one to judge (default: the item's own). What it decides is only an + * item with NO playing take (a preview from the script); with one, the take decides (readEditOf): * null no script, no words on the card, or the script says the shown text as drafted - * "reading" edited, and `narration.forReading` set by the writer: the card's layout follows the SHOWN text - * (read-follow.mjs followParts, post-thread.mjs partRoles), never the edited words - * "legacy" edited before reads were kept apart from the card (no marker): its layout follows the script, as it - * always did -- saving the script again moves it to the new rule + * "reading" edited, and `narration.forReading` set by the writer + * "legacy" edited, no marker */ export function scriptEditOf(entry, script = entry?.narration?.script) { const own = spacing(script); @@ -198,6 +197,39 @@ export function scriptEditOf(entry, script = entry?.narration?.script) { return entry?.narration?.forReading === true ? "reading" : "legacy"; } +/** The post's words a take SAYS: its parts of his post ("post") when it has roles, else all its parts, else its script. */ +export function takePostWords(take) { + const parts = Array.isArray(take?.parts) ? take.parts : []; + const roled = parts.some((p) => typeof p?.role === "string"); + const own = roled ? parts.filter((p) => p?.role === "post") : parts; + return own.length ? own.map((p) => str(p?.text)).join("\n\n") : str(take?.script); +} + +/** + * Whether a take is stamped FOR READING when it is made (the writer, postNarrationIn): its words are not the post's + * as drafted -- an edit for reading, so while it plays the card follows the shown text. False with no shown text. + */ +export const takeIsEditedRead = (entry, take) => !!spacing(shownDraftOf(entry)) && !!spacing(takePostWords(take)) && !saysShownDraft(entry, takePostWords(take)); + +/** + * THE RULE FOR THE CARD's LAYOUT (lane line-rerun; review 1, finding 3, the orchestrator's ruling): the take that PLAYS + * decides. `take` (default: the picked one): + * "reading" stamped `forReading` when it was made: the card follows the SHOWN text (read-follow.mjs followParts, + * post-thread.mjs partRoles), never the read's words + * null it says the post's words as drafted: the card follows it, as ever (the same thing) + * "legacy" made before the rule (no stamp) from other words: the card follows them, as it always did -- read it + * again to move it to the rule + * With no take playing, the script decides (scriptEditOf: `narration.forReading`). + */ +/** Whether the PLAYING take predates the rule and reads other words than the post's (`--list`, the bench say so). */ +export const legacyReadOf = (entry) => !!pickedTake(entry) && readEditOf(entry) === "legacy"; + +export function readEditOf(entry, take = pickedTake(entry)) { + if (!take) return scriptEditOf(entry); + if (take.forReading === true) return "reading"; + return takeIsEditedRead(entry, take) ? "legacy" : null; +} + /** The card's word indices (cardTokens') that the excerpt does NOT read (drawn dimmed), or null with no excerpt. */ export function excerptCutWords(entry) { const spans = excerptSpansOf(entry); diff --git a/umtool/report-to-video/post-narration.mjs b/umtool/report-to-video/post-narration.mjs @@ -200,7 +200,9 @@ const ITEM_KEYS = new Set([...MIX_KEYS, "script", "excerpt", "engine", "voice", // item's own), "preset" (its character's: drift when that changes). Absent: unknown -- never speed drift. // `tuning`, `reading` (lane orpheus-tuning): what an Orpheus take was made with, as the editor's result said it -- // every tuning value (the defaults included) and the reading (0 = the first) -- so it can be made again exactly. -const TAKE_KEYS = new Set(["file", "engine", "voice", "seconds", "script", "at", "note", "speed", "lufs", "jobId", "parts", "label", "source", "steps", "words", "slurs", "lexicon", "read", "said", "speedAsked", "screenLine", "tuning", "reading"]); +// `forReading` (lane line-rerun): the take was made from words that are not the post's as drafted -- stamped by the +// writer when it is made; while it plays the card follows the shown text (post-item.mjs readEditOf). +const TAKE_KEYS = new Set(["file", "engine", "voice", "seconds", "script", "at", "note", "speed", "lufs", "jobId", "parts", "label", "source", "steps", "words", "slurs", "lexicon", "read", "said", "speedAsked", "screenLine", "tuning", "reading", "forReading"]); const STEP_KEYS = new Set(["op", "engine", "voice", "pitch", "semitones", "params", "ranAt", "job", "drop", "tempo", "spans", "pauses", "revoice"]); // `role` (post-thread.mjs): the text a part reads -- "post", "quoted", "parent:<i>", "media:<i>"; `voice`, `piece`: the batch's; // `engine`: the part's own when it is not the take's (a cast voice that names its engine: postThreadRead.mjs). @@ -684,6 +686,7 @@ export function validatePostNarration(e) { if (t.said !== undefined && (typeof t.said !== "string" || t.said.length > 50000)) errors.push(`${tw}.said must be the words its read said`); if (t.speedAsked !== undefined && t.speedAsked !== true && t.speedAsked !== "item" && t.speedAsked !== "preset") errors.push(`${tw}.speedAsked must be true, "item" or "preset"`); errors.push(...tuningProblems(t.tuning, t.reading, tw)); + if (t.forReading !== undefined && t.forReading !== true) errors.push(`${tw}.forReading must be true (or absent)`); if (t.read !== undefined && !(isObj(t.read) && t.read.kind === "thread" && JSON.stringify(t.read).length <= 4000)) errors.push(`${tw}.read must be {kind: "thread", …} (how the thread read was asked for)`); // A RECORDING OF ONE SCREEN LINE (postScreensCli.mjs `posts screen … record`, post-screens.mjs): the line it was // recorded for -- its screen, its index, its words as a read writes them, its speaker. Never the item's read. diff --git a/umtool/report-to-video/post-reading-pin.test.mjs b/umtool/report-to-video/post-reading-pin.test.mjs @@ -7,7 +7,9 @@ // Recorded on main: PIN_RECORD=1 node --test report-to-video/post-reading-pin.test.mjs import assert from "node:assert/strict"; import { test } from "node:test"; +import { createHash } from "node:crypto"; import { draftScript } from "./post-narration.mjs"; +import { postItemPlan } from "./post-item.mjs"; import { FIXTURES, PINNED_SHAS, drawn, singleItem, threadItem } from "./post-reading-pin.fixtures.mjs"; test("THE READING PIN: an item whose read says its shown text as drafted draws as it did on main", () => { @@ -35,7 +37,7 @@ const EDITS = { /** A single item whose script is `script`, saved for reading, and a take of it picked. */ function editedSingle(script) { const e = singleItem(); - return { ...e, narration: { ...e.narration, script, forReading: true, pick: 1, takes: [...e.narration.takes, { file: "narration/posts/7003/take-2.orpheus-zac.wav", engine: "orpheus", voice: "zac", seconds: 5.1, script, reading: 1 }] } }; + return { ...e, narration: { ...e.narration, script, forReading: true, pick: 1, takes: [...e.narration.takes, { file: "narration/posts/7003/take-2.orpheus-zac.wav", engine: "orpheus", voice: "zac", seconds: 5.1, script, reading: 1, forReading: true }] } }; } /** A thread item whose post piece reads `script` (its paragraphs its parts), saved for reading, picked. */ @@ -53,7 +55,7 @@ function editedThread(script) { return p; }); const parts = [...before.slice(0, at), ...post, ...before.slice(at)].map((p, i) => ({ ...p, n: i + 1 })); - const take = { ...t, file: "narration/posts/7003/take-2.orpheus-thread.wav", parts, script: parts.map((p) => p.text).join("\n\n"), reading: 1 }; + const take = { ...t, file: "narration/posts/7003/take-2.orpheus-thread.wav", parts, script: parts.map((p) => p.text).join("\n\n"), reading: 1, forReading: true }; return { ...e, narration: { ...e.narration, script, forReading: true, pick: 1, takes: [t, take] } }; } @@ -66,8 +68,55 @@ for (const [name, script] of Object.entries(EDITS)) { }); } -test("EDITED BEFORE (no marker): the card follows the script, as it always did", () => { +test("EDITED BEFORE (a playing take made before the rule: no stamp): the card follows its words, as it always did", () => { const e = editedSingle(EDITS.unrelated); delete e.narration.forReading; + delete e.narration.takes[1].forReading; assert.notDeepEqual(drawn(e), PINNED_SHAS.single); }); + +// --------------------------------------------------------------------------- +// WHEN THE TILES ARE DRAWN (review 1, finding 1): a spoken edit never moves when a thread tile shows. The tiles' t0/t1 +// of the unedited items, hashed as main (19fb842b5) schedules them -- recorded by running main's report-to-video on +// these fixtures -- and every edited variant schedules them the same. +// --------------------------------------------------------------------------- + +const RENDER = { postNarration: { lead: 0.4 } }; +const tilesOf = (e) => (postItemPlan(e, RENDER).follow?.thread?.tiles ?? []).map((t) => [t.scope, t.mode, t.t0, t.t1, t.from, t.to]); +const sha = (v) => createHash("sha1").update(JSON.stringify(v)).digest("hex"); +// Main's: thread [["parent:0","excerpt",4.8,5.5,…],["quoted","full",4.8,5.5,…],["post","full",7.93,8.63,…],["screen:s1","full",15.33,16.03,…]]. +const TILE_SHAS_MAIN = { single: "d1021365f7f764ec2d5fb30a8b089d2ba6ddfe54", thread: "ee8b33368446e02103771de890cb8b9f9c060583" }; + +test("THE TILES' TIMES: the unedited items schedule their tiles as main does", () => { + assert.deepEqual(Object.fromEntries(Object.entries(FIXTURES).map(([k, e]) => [k, sha(tilesOf(e))])), TILE_SHAS_MAIN); +}); + +for (const [name, script] of Object.entries(EDITS)) { + test(`THE TILES' TIMES (${name}): an edit to his words read moves no tile's time -- the parent, the quoted post, his post, the screen`, () => { + assert.equal(sha(tilesOf(editedThread(script))), TILE_SHAS_MAIN.thread, JSON.stringify(tilesOf(editedThread(script)))); + }); +} + +// --------------------------------------------------------------------------- +// A SINGLE READ IN PARTS, its parts storing no role (Rule B: his post's, part by part; Rule A: the shown paragraphs). +// --------------------------------------------------------------------------- + +/** A single read of `script` in parts (a paragraph each), no roles, stamped for reading, picked. */ +function editedSingleParts(script) { + const e = singleItem(); + let t = 0; + const parts = draftScript(script).script.split("\n\n").map((text, i) => { + const sec = Math.round((text.split(/\s+/).length / 3) * 100) / 100; + const p = { n: i + 1, para: i, text, start: Math.round(t * 1000) / 1000, seconds: sec }; + t += sec + 0.5; + return p; + }); + const take = { file: "narration/posts/7003/take-2.orpheus-zac.wav", engine: "orpheus", voice: "zac", seconds: Math.round(t * 100) / 100, script, parts, reading: 1, forReading: true }; + return { ...e, narration: { ...e.narration, script, forReading: true, pick: 1, takes: [...e.narration.takes, take] } }; +} + +for (const [name, script] of Object.entries(EDITS)) { + test(`A SINGLE READ IN PARTS, NO ROLES (${name}): the card draws as before the edit`, () => { + assert.deepEqual(drawn(editedSingleParts(script)), PINNED_SHAS.single); + }); +} diff --git a/umtool/report-to-video/post-thread.mjs b/umtool/report-to-video/post-thread.mjs @@ -48,7 +48,7 @@ // PURE and dependency-free (but its siblings): the plan, the build, Play, the // bench, the writers and the lint all read the same rules from here. -import { POST_PARENTS_MAX, cardText, contextText, linksOf, parentsOf, refMediaOf, refShown, scriptEditOf } from "./post-item.mjs"; +import { POST_PARENTS_MAX, cardText, contextText, linksOf, parentsOf, readEditOf, refMediaOf, refShown } from "./post-item.mjs"; import { draftScript, isNarrated, isOnlyUrls, joinSplitLinks, pickedTake, postNarrationKnobs, scriptParts, spokenUrls } from "./post-narration.mjs"; import { normWord, scriptWordsOf } from "./word-zoom.mjs"; import { followKnobs } from "./read-follow.mjs"; @@ -223,9 +223,9 @@ export function partRoles(entry, take = undefined) { parts = scriptParts(script).map((p) => ({ text: p.text, para: p.para * 100 })); } if (!parts.length) return []; - // HIS WORDS EDITED FOR READING (post-item.mjs scriptEditOf; ruling 3): a read of them that stores no roles is his - // post's, part by part -- never inferred from the edited words as a parent, the quoted post or a picture. - if (scriptEditOf(entry) === "reading" && !parts.some((p) => typeof p?.role === "string")) return parts.map(() => ({ role: "post", source: "inferred" })); + // HIS WORDS EDITED FOR READING (post-item.mjs readEditOf: the take's stamp; ruling 3): a read of them that stores + // no roles is his post's, part by part -- never inferred from the edited words as a parent, the quoted post or a picture. + if (t && readEditOf(entry, t) === "reading" && !parts.some((p) => typeof p?.role === "string")) return parts.map(() => ({ role: "post", source: "inferred" })); const texts = readTexts(entry); const orderOf = roleOrderOf(entry); const images = (Array.isArray(entry?.media) ? entry.media : []).map((m, i) => ({ m, i })).filter((x) => x.m?.kind === "image"); @@ -917,7 +917,11 @@ export function threadSchedule(entry, render, { layout, blocks, lead = 0.4, beat const roles = layout.roles; // Each read piece's start on the item's clock: its first block's start. const startOfPart = new Map(); - for (const b of blocks) if (b.part !== null && b.start !== null && !startOfPart.has(b.part)) startOfPart.set(b.part, b.start); + // Keyed by the TAKE's part (`takePart` when read-follow's part stands for one: his words edited for reading). + for (const b of blocks) { + const n = b.part === null ? null : b.takePart ?? b.part; + if (n !== null && b.start !== null && (!startOfPart.has(n) || b.start < startOfPart.get(n))) startOfPart.set(n, b.start); + } // A PICTURE-ONLY context post's BEAT (pictureBeats) is a piece of its own, before the read's first. const beatOf = new Map((Array.isArray(beats) ? beats : []).map((b) => [b.scope, b])); const pieces = [...beatOf.values()].map((b) => ({ role: b.scope, parts: [], start: b.t0, beat: b.scope !== "post" })).concat(tilePieces(readPieces(entry, roles)).map((p) => { @@ -1327,7 +1331,7 @@ export function panelReadErrors(follow, panel, { id = "?", settle = 0.35 } = {}) const show = (panel?.shows ?? []).find((sh) => sh.scope === b.scope); const a = b.start + settle; const z = Math.max(a, (fin(b.end) ? b.end : b.start) - 0.4); - if (!show || show.t0 > a + 1e-6 || show.t1 < z - 1e-6) errors.push(`${id}: part ${b.part + 1} reads the picture of ${b.scope}, which the panel does not show while it is said (${r3(b.start)}–${r3(fin(b.end) ? b.end : b.start)} s)`); + if (!show || show.t0 > a + 1e-6 || show.t1 < z - 1e-6) errors.push(`${id}: part ${(b.takePart ?? b.part) + 1} reads the picture of ${b.scope}, which the panel does not show while it is said (${r3(b.start)}–${r3(fin(b.end) ? b.end : b.start)} s)`); } return errors; } diff --git a/umtool/report-to-video/read-follow.mjs b/umtool/report-to-video/read-follow.mjs @@ -43,7 +43,7 @@ // sets it on the page -- in the build per frame before a screenshot // (post-render.mjs), in Play per tick (PostItemPlayer). -import { cardText, contextReadSeconds, contextText, linksOf, parentsOf, readSeconds, scriptEditOf, shownDraftOf } from "./post-item.mjs"; +import { cardText, contextReadSeconds, contextText, linksOf, parentsOf, readEditOf, readSeconds, shownDraftOf } from "./post-item.mjs"; import { isNarrated, narrationSchedule, partStartOnItem, pickedTake, scriptParts } from "./post-narration.mjs"; import { cardTokens, easeOf, normWord, scriptWordsOf } from "./word-zoom.mjs"; import { partRoles, threadGeoAt, threadKnobs, threadLayout, threadSchedule, threadStateAt } from "./post-thread.mjs"; @@ -203,10 +203,10 @@ function fitMatch(a, b, lo, hi) { export function followParts(entry) { if (isNarrated(entry)) { const t = pickedTake(entry); - // HIS WORDS EDITED FOR READING (post-item.mjs scriptEditOf; ruling 3): the card follows the SHOWN text -- his - // post's blocks are made from his words as drafted, never from the edited ones, so no edit to what is said moves, - // dims for good or hides a drawn word. The edited read only times them. - const forReading = scriptEditOf(entry) === "reading"; + // HIS WORDS EDITED FOR READING (post-item.mjs readEditOf: the playing take's stamp; ruling 3): the card follows + // the SHOWN text -- his post's blocks are made from his words as drafted, never from the edited ones, so no edit + // to what is said moves, dims for good or hides a drawn word. The edited read only times them. + const forReading = readEditOf(entry, t) === "reading"; if (Array.isArray(t?.parts) && t.parts.length) { // Each part's ROLE (post-thread.mjs): the text it reads -- a context post, his words, an attachment's. const roles = partRoles(entry); @@ -231,7 +231,9 @@ export function followParts(entry) { function shownPostParts(entry, parts, takeParts) { const at = parts.map((p, i) => (p.scope === "post" ? i : -1)).filter((i) => i >= 0); if (!at.length || at.some((i, j) => j && i !== at[j - 1] + 1)) return parts; - const shown = scriptParts(shownDraftOf(entry)).map((q) => ({ text: q.text, scope: "post", shown: true })); + // Each shown part keeps the take's part it stands for (`at`: one for one, else his first part for the first, his + // last for the rest) -- the thread schedule finds a piece's start by the take's parts (review 1, finding 1). + const shown = scriptParts(shownDraftOf(entry)).map((q, j) => ({ text: q.text, scope: "post", shown: true, at: at[Math.min(j, at.length - 1)] })); if (!shown.length) return parts; const own = at.map((i) => parts[i]); let timed; @@ -248,8 +250,8 @@ function shownPostParts(entry, parts, takeParts) { return { ...q, start }; }); } - // The parts after his keep the take's part they are (`at`): the schedule times them by it. - return [...parts.slice(0, at[0]), ...timed, ...parts.slice(at[at.length - 1] + 1).map((p, j) => ({ ...p, at: at[at.length - 1] + 1 + j }))]; + // Every other part keeps the take's part it is (`at`): the schedule times them by it. + return [...parts.slice(0, at[0]).map((p, j) => ({ ...p, at: j })), ...timed, ...parts.slice(at[at.length - 1] + 1).map((p, j) => ({ ...p, at: at[at.length - 1] + 1 + j }))]; } /** @@ -355,7 +357,10 @@ export function followBlocks(entry) { blocks.push(...segs); } blocks.push(...media); - return { source, parts: parts.length, blocks: blocks.map((b, k) => ({ k, ...b })) }; + // A block read by a part that stands for a take's part (shownPostParts): that take part's index (`takePart`) -- + // the thread schedule and the lint name a piece by the take's parts. + const takeAt = (b) => (b.part !== null && Number.isInteger(parts[b.part]?.at) ? { takePart: parts[b.part].at } : {}); + return { source, parts: parts.length, blocks: blocks.map((b, k) => ({ k, ...b, ...takeAt(b) })) }; } /** A block map's runs for one scope, as wordsHtml wraps them: `[{ from, to, k }]`. */ @@ -859,7 +864,7 @@ export function readInViewErrors(follow, geo, stateAt, { total = null, id = "?" } const secs = times.length > 1 ? bad * T.step : bad ? Math.max(0.1, bEnd - b.start) : 0; if (bad && secs > T.slack + 1e-9) { - errors.push(`${id}: part ${b.part + 1} (${tileName(b.scope)}, block ${b.k}) is not in full view for ${secs.toFixed(2)} s of its read (${r3(b.start)}–${r3(bEnd)} s) -- at ${worst.s} s ${worst.why.join("; ")}`); + errors.push(`${id}: part ${(b.takePart ?? b.part) + 1} (${tileName(b.scope)}, block ${b.k}) is not in full view for ${secs.toFixed(2)} s of its read (${r3(b.start)}–${r3(bEnd)} s) -- at ${worst.s} s ${worst.why.join("; ")}`); } } // A CONTEXT tile is never larger nor stronger than its context size; a carried or scene tile, once it has given way.