commit 7db0c1e9c26eb7e48ac77e58d5661040b5a8053d parent f6c3dfa231a9d2d48577219d5a5bff1ba0353d66 Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st> Date: Fri, 13 Nov 2026 02:19:43 -0500 umtool screens, review 1 (a-j): content-owned line takes, claimed recording names, heard or not a. A line take is its line's by CONTENT (screen, words as a read writes them, speaker), not its index: a line removed above a chosen take moves the key and the take still plays; validation asks only that it is of the screen; `set take.<n>=` and --line-take refuse a take whose words or speaker are not the line's as it is now (post-thread.mjs lineTakeCurrent, lineTakesOf). b. A recorded take's name is CLAIMED with an exclusive create, the next number while one is there (postRecord.mjs claimRecordedTake, claimTakeName): keepRecording and the record page's Keep (keepPreview, which no longer removes a parts folder it did not make) never overwrite or rename over a recording; two kept at once take two files. c. Upload scratch dirs by mkdtemp (the line upload and the bench's recording upload). d. --check-words refuses an anonymous author's handle or display name bare, possessive or spaced ("secret kid"), and a number said in words; the names from this video's characters and posts. e. linesOfRead leaves out only Orpheus's own tags; any other <word> is words. f. record --as may name only the line's speaker's character; another, or the narrator, is refused. g. editor/CHANGELOG.md [Unreleased]: three bullets. j. A heard take records what it was heard saying and against which words (screenLine.heard); an unheard one says so on record, the lint warns per chosen unheard take, the bench marks each recording heard / not heard; the docs say exactly what is and is not verified. Tests made failing first: lib/report/postScreensReview3.test.mjs (b, d, e, f, j), postScreensRound2 (a, l1 #1b); e2e post-screens: a stale read on the bench plays silent and says why. Co-Authored-By: Claude <noreply@anthropic.com> Diffstat:
18 files changed, 414 insertions(+), 98 deletions(-)
diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog ## [Unreleased] +- **umtool: a picture-only post's read can become its screen, and a screen line can be read in your own voice.** `umtool posts screen <p> <item> add --from-read` (the post bench's "From its read") turns the script of a picture-only post into a screen: one line per line of the script, not checked, and with no speaker split out of a line. That screen *is* the post's read, so the thread read no longer reads the same words twice. `posts screen … record <id> <n> --recording <file>` (the bench's per-line Record / Stop / Keep) records one line as the read says it, with masked numbers and redacted words left out of what you read. It is kept as new takes: recorded, cleaned, and converted to the line's speaker's character's stock voice. None of them is picked. A line take is read only when you choose it, with the bench's per-line select or `set <id> take.<n>=<take>`. A choice follows its line when lines move, and is refused when the line's words or speaker changed. `--check-words` (CLI only) transcribes the recording first and refuses it if it says a number, a handle, an anonymous author's name or a redacted term. The lint flags every chosen take that was not heard this way. +- **umtool: no preview plays a read the build refuses.** After a screen line is edited, removed, redacted or no longer read, the build refuses the old read. Play, Present (including the public payload), the card page and the post bench's player now refuse it too: they play the item silent and say why, until the read is made again. Present's public payload carries a post's screens the way the card draws them (masked, blurred speakers nameless), never the raw lines. +- **umtool: no part of a read may say what the item's screens mask.** A build refuses a read in which any part says a number or e-mail one of the item's screens masks, or the words of a redacted line. That covers the post's own words, a context post and a screen line. Two recordings kept at the same moment never take the same file: a recorded take's name is now claimed with an exclusive create. - **A local-only Archilyzer in one command: `./docker/demo.sh up`.** On a machine with only docker (compose v2.24 or newer), it starts the editor, umtool and a local model server (ollama) in Docker, connects a published archive as a source (https://jeralyzer.pages.dev unless `--archive`), pulls the model (`--model`, default qwen2.5:7b) and routes every AI task to it. Every step is one printed line; `--dry-run` prints every command and changes nothing; a missing prerequisite (docker, compose, the daemon, 12 GB of RAM, 25 GB free, a port) is one sentence and exit 1. The GPU is found by itself (a render node: ollama on Vulkan; NVIDIA; else the CPU, said so), and ollama's own line about the device it uses is printed. A host ollama already holding a model on the GPU is warned about. The choices are kept in `.env.demo` (mode 600) and reused, so a second `up` changes nothing. A step that fails after the start (the start itself, the editor's first answer, the pull, the settings) ends with one sentence saying the demo is partly up and that `./docker/demo.sh down` stops it. `down` keeps the volumes unless `--volumes`, and stops the stack even when `.env.demo` is gone; `status` shows the stack; `voice` says what Orpheus needs. Nothing is opened off this machine: every value written to `.env.demo` is checked character by character (a newline cannot be smuggled in through `--archive`), a `.env.demo` line it did not write or a bind other than 127.0.0.1 (in the file or the shell) is refused, and the exposure guard is handed the binds compose really publishes on (docker-compose.yml, for every stack). RUNNING_IN_DOCKER.md, "A local-only demo". - **Local only: `ARCHILYZER_LOCAL_ONLY=1` (the demo sets it).** With ARCHILYZER_LOCAL_ONLY=1, this instance refuses — before any request is sent or any process started — every call to the Claude API, every Claude Code answer (a task routed to `code`, or `answers` posted by a session), the digest's `claude` CLI lane, and every call to an ollama model that is a cloud model (a `-cloud` tag, or one whose /api/show names a remote host) or that is served from anywhere but this machine (a loopback address) or a host named in ARCHILYZER_LOCAL_MODEL_HOSTS. It does not cover the web pages a local model may read (its web_search and fetch tools), the published site's in-browser Ask, or remote transcription workers, which are not language models. A settings change (on the ops route or the editor's own pages) that would route a task off the local model or name a model server elsewhere is refused, an LLM worker elsewhere is not saved and is skipped, and `reports import-sweep` and `import-local-runs` are refused. A refused job or write says so in one sentence; the digest's metered lane says "refused: local only", not "is the claude CLI installed". `archilyzer gen local-check` (and `./docker/demo.sh check`) checks it afterwards by counts and host names: the flag on, every route local, every model server a local route asks on this machine, no API key present, no call off the local route in the usage ledger or the per-call logs since a date, and no imported iteration; it exits 1 when any fails, says NOTHING TO PROVE YET (not PASS) while no call is recorded, and never prints a key or a home path. The editor's boot log says `models: LOCAL ONLY`, says as an ERROR when the flag holds a value it does not understand, and gives one line on whether ollama answers. umtool makes no model call itself. Unset, nothing changes. Needs a restart of the editor. - **`archilyzer gen model api|local|extractor <model>` sets the model a route runs** (settings.generation.models), from a terminal or a container; bare, it shows the three. diff --git a/umtool/app/api/report/post-narration/route.ts b/umtool/app/api/report/post-narration/route.ts @@ -1,4 +1,4 @@ -import { mkdir, readFile, readdir, rm, stat, writeFile } from "node:fs/promises"; +import { mkdir, mkdtemp, readFile, readdir, rm, stat, writeFile } from "node:fs/promises"; import path from "node:path"; import { POST_DERIVE_OPS, POST_DERIVE_ROUTES, derivedFileOf, isNarrated, nextTakeNumber, pickedTake, postIdOf, postNarrationKnobs, takeFileOf, takeIdOf, takesDirOf, @@ -464,8 +464,9 @@ async function record(request: Request) { if (form.get("line") !== null) return recordLine(r.project, e, String(form.get("line")), label, blobs[0]); const texts = form.getAll("text").map(String); const paras = form.getAll("para").map((x) => Number(x)); - const up = path.join(r.project.dir, ...takesDirOf(postIdOf(e)).split("/"), `.upload-${Date.now()}`); - await mkdir(up, { recursive: true }); + const takesDir = path.join(r.project.dir, ...takesDirOf(postIdOf(e)).split("/")); + await mkdir(takesDir, { recursive: true }); + const up = await mkdtemp(path.join(takesDir, ".upload-")); try { const parts = []; for (const [k, b] of blobs.entries()) { @@ -520,8 +521,10 @@ async function recordLine(project: { id: string; dir: string }, e: Entry, role: if (blob.size > 200 * 1024 * 1024) return Response.json({ error: "the recording is larger than 200 MB" }, { status: 413 }); const running = runningJob(); if (running) return Response.json({ error: `umtool is running another job (${running.kind}): keep it when that is done`, busy: true }, { status: 409 }); - const up = path.join(project.dir, ...takesDirOf(postIdOf(e)).split("/"), `.line-upload-${Date.now()}`); - await mkdir(up, { recursive: true }); + // A scratch dir of its own (mkdtemp: unique, never another upload's). + const takesDir = path.join(project.dir, ...takesDirOf(postIdOf(e)).split("/")); + await mkdir(takesDir, { recursive: true }); + const up = await mkdtemp(path.join(takesDir, ".line-upload-")); const own = /\.(wav|mp3|m4a|aac|ogg|opus|flac|webm)$/i.exec(typeof blob.name === "string" ? blob.name : "")?.[1]?.toLowerCase(); const file = path.join(up, `line.${own ?? (/ogg/.test(blob.type) ? "ogg" : /wav/.test(blob.type) ? "wav" : "webm")}`); await writeFile(file, new Uint8Array(await blob.arrayBuffer())); diff --git a/umtool/components/projects/PostScreensPanel.tsx b/umtool/components/projects/PostScreensPanel.tsx @@ -22,7 +22,7 @@ import { ScreenLineVoice, useScreenVoice, type LineTakeOption, type ScreenVoice, type Line = { who?: string; side?: "left" | "right"; text: string; time?: string; redact?: true }; type Read = "all" | "none" | Array<{ line: number; text?: string }>; type Screen = { id: string; media: number; at?: [number, number]; kind: string; title?: string; source?: string; checked?: { by: string; at: string }; ref?: string; unread?: "omit" | "dim"; lines: Line[]; read: Read; lineTakes?: Record<string, string> }; -type LineRecs = Array<{ role: string; screen: string; n: number; takes: Array<{ n: number; id: string; take: { steps?: Array<{ op: string; voice?: string }>; engine?: string }; current: boolean; chosen: boolean }> }>; +type LineRecs = Array<{ role: string; screen: string; n: number; takes: Array<{ n: number; id: string; take: { steps?: Array<{ op: string; voice?: string }>; engine?: string; screenLine?: { heard?: unknown } }; current: boolean; chosen: boolean }> }>; /** A recording's step as the select says it: recorded, cleaned, converted to its voice. */ const stepOf = (t: { steps?: Array<{ op: string; voice?: string }>; engine?: string }) => { const st = t.steps?.[0]; @@ -353,7 +353,7 @@ function ScreenEditor({ n={n} voice={voice} dirty={dirty} - options={(recs.find((x) => x.screen === sc.id && x.n === n)?.takes ?? []).map((x): LineTakeOption => ({ id: x.id, label: `take ${x.n} · ${stepOf(x.take)}`, current: x.current }))} + options={(recs.find((x) => x.screen === sc.id && x.n === n)?.takes ?? []).map((x): LineTakeOption => ({ id: x.id, label: `take ${x.n} · ${stepOf(x.take)}${x.take.screenLine?.heard ? " · heard" : " · not heard"}`, current: x.current }))} chosen={sc.lineTakes?.[String(n)]} onChoose={(id) => setScreen((s) => { diff --git a/umtool/docs/cli.md b/umtool/docs/cli.md @@ -132,7 +132,7 @@ Inbox cannot disagree about what is wrong with one. | `posts reread <project> <item> --pause "<word>[#<n>]=<seconds>\|@<take s>=<seconds>[,…]" [--target post\|parent:0\|quoted\|linked:0] [--dry-run] [--json]` | **pauses put in after words** of a narrated read, no TTS (`lib/report/postPause.mjs`; operator, 5 Nov: a countdown "20 10 4 0" read without a breath): the picked take cut just after each word named (half way into the quiet before the next word, at most 0.1 s past its end) and that much silence (0.05–3 s) put in -- each cut moved to the quietest 10 ms its word allows (40 ms before its timed end up to the next word, ±40 ms when they run together) when that is clearly quieter (~3 dB) than the timing's own, and each side of the silence faded over 10 ms, so a pause in normally paced speech does not click -- everything after moved on -- its words (by index), its parts (one a pause falls in grows), its length -- so word zooms, captions, slams, beeps and the read-follow stay on their words; an effect with a set `at` does not move (the plan counts them). A word is matched as a word zoom's is (case and edge punctuation aside; a phrase pauses after its last word; `#n` its n-th time in the read; `--target` counts only the words of the parts reading that piece). A derived take (`steps: [{op: "pause", pauses: [{word, w, at, seconds}]}]`) picked in ONE write. **Absolute**, like a tempo: on a take whose last step is a pause it re-cuts from the take before (the pauses it had kept, a word named again takes the new seconds, `=0` takes one away). `--in-take <t>` puts it in a take's read. No word timings (**exit 1**, naming `posts narrate <p> <item> --words`), a word not read, an occurrence not there, nothing to change: **exit 1**; a malformed spec, seconds outside 0.05–3, `--pause` with another reread form: **exit 2** | | `posts reread <project> <item> --revoice "<phrase>[#<n>]" --say "<what to say instead>" [--target <piece>] [--voice <v>\|auto] [--xfade 0.03] [--splice <from>-<to>] [--dry-run] [--json]` | **one phrase of an approved read re-voiced**, the rest untouched (`lib/report/postRevoice.mjs`; operator, 5 Nov: the countdown gabbled, and pauses cut into it "choppy"): the phrase found in the picked take's word timings as `--pause` finds a word (`#n`, `--target`; inside one part), the original cut from just before its first word to just after its last -- each cut at the quietest 10 ms within ±40 ms of the boundary, and when that is still speech within ±0.15 s (never inside the phrase as timed; a nearer quiet preferred) -- **`--say` alone synthesized by the editor's TTS** (narrate-via-editor; the engine of the root take, the voice of the part the phrase is in, `--voice` overrides; the project's lexicon, redaction and slur filter applied; kept in `narration/parts-cache/` like a thread read's parts, so asking again is free), its lead and tail of silence trimmed, loudness-matched to the speech in the 2 s either side (±6 dB) and spliced in with equal-power crossfades (`--xfade`, 0–0.2 s) at both joins, at the take's rate and layout. The length is exact: the take − the span cut + the piece. Everything after moves by the difference (its words, the part holding the span, the later parts) so zooms, captions, slams, beeps and the read-follow stay on their words; the new words are timed from the piece's speech and marked `estimated` (a later `posts narrate … --words` refines them); the part's text and the script say `--say`. A derived take (`steps: [{op: "revoice", revoice: {word, count, words, phrase, say, said, voice, engine, from, to, seconds, gain, xfade, key}}]`) picked in ONE write; re-voicing exactly the words a re-voice put in re-cuts from the take before. `--dry-run`: the span (words, seconds), each cut and its level, what is said and in which voice, the length change when the piece is cached -- no TTS. A cut still in speech is warned of (the word timings off there): `--splice 65.03-66.00` sets the cuts (either side may be left out). `--in-take <t>` puts it in a take's read. No word timings (naming `posts narrate <p> <item> --words`), the phrase not read or across two parts, a recorded read, the TTS failing: **exit 1**; no `--say`, a bad voice, crossfade or splice, `--revoice` with another reread form: **exit 2** | | `posts progress <project> [auto\|on\|off\|default] [--json]` | the cut's **progress bar** default (`render.posts.progress`, `updatePostProgressRender`; [report-video.md](report-video.md#the-progress-bar)); bare, which items draw it | -| `posts screen <project> <item> list\|add\|set\|rm\|check\|read\|record …` (add: `--media <i> [--at <from>,<to>] --kind dm\|email\|post\|text [--id <id>] [--title "…"] [--from <file>] [--line "who: words"]… [--read all\|none\|<n>,…] [--unread omit\|dim] [--ref <channel>/<postId>]` or `--from-read [--media <i>] [--kind …]`; record: `<id> <line> --recording <file> [--as <character>] [--no-clean\|--clean] [--no-trim\|--trim] [--no-convert] [--pitch target\|source\|contour] [--semitones n] [--label l] [--check-words [--worker w]] [--events]`; set: `<id> kind= title= media= at=<a>,<b>\|off unread= ref= read=all\|none\|<n>,… read.<n>="excerpt"\|on\|off line.add="who: words" line.<n>=off line.<n>.who= line.<n>.side=left\|right\|auto line.<n>.text= line.<n>.time= line.<n>.redact=on\|off take.<n>=<take n>\|off [--from <file>]`; check: `<id> [--by <name>] [--undo]`; read: `[--post-take <n>] [--line-take screen:<id>:<line>=<n>]… [--voice-for h=v]… [--force] [--dry-run]`; `--json`, `--dry-run`, `--take <take>`) | a post's **SCREENS** ([report-video.md](report-video.md#screens-text-screenshots-read-as-part-of-the-post), [knobs.md](knobs.md#screens-a-posts-text-screenshots), `post-screens.mjs`): the text screenshots its attachments carry -- a DM exchange or an email shown in its video (`--at`: the seconds it is visible), an image that is a screenshot -- transcribed once (`--from`: a JSON screen, or text lines `[right] who: words \| time`, `- words`, `[redact] …`), checked by a person (`check`; a screen not checked is a lint WARNING; new words take the check away), and read whole or in excerpts. Each write is the post item's one writer (`updatePostItem`'s `screens`, one undo point), refused in the build's words (**exit 1**); an attachment a screen is in cannot be removed. An e-mail address, a phone number, an order or long number in a line is masked on the card and never said. `read` makes the THREAD READ with the screens (as `posts narrate <p> <item> --take --thread`): her own line from the take that plays (or the one the thread read used; `--post-take n` another), never made again; each read line in its speaker's voice (`who`: the post's author in hers, a handle or a character's name in theirs); `--line-take` takes a line from the item's take n (a recording of it), and a line's CHOSEN take (`take.<n>=`, the bench's select) is read in its place -- a recording nobody chose is named, never read in. `add --from-read`: a PICTURE-ONLY post's read (its `narration.script`) made its screen, a line per line, on its picture, read whole, NOT checked -- no speaker parsed out of it. `record`: ONE LINE in your voice ([report-video.md](report-video.md#a-line-in-your-own-voice), `lib/report/screenLineRecord.mjs`) -- the line as the read says it (its shapes and the redaction left out, an anonymous handle as its shown name), kept as new takes through `posts narrate --recording`'s chain: recorded, cleaned, converted to its SPEAKER's character's stock voice (none: kept as recorded, said), NONE picked, each carrying `screenLine`; refused on an item with no read of its own (**exit 1**). A line take is refused picked as the item's read, as `--post-take`, for another line, or once its line's words or speaker changed. `--check-words` (the editor's transcribe op; opt-in, CLI only): refused when it is heard saying a shape, an @handle, an anonymous handle or a redacted term -- nothing kept -- and a warning on other words. Usage errors: **exit 2** | +| `posts screen <project> <item> list\|add\|set\|rm\|check\|read\|record …` (add: `--media <i> [--at <from>,<to>] --kind dm\|email\|post\|text [--id <id>] [--title "…"] [--from <file>] [--line "who: words"]… [--read all\|none\|<n>,…] [--unread omit\|dim] [--ref <channel>/<postId>]` or `--from-read [--media <i>] [--kind …]`; record: `<id> <line> --recording <file> [--as <the speaker's character>] [--no-clean\|--clean] [--no-trim\|--trim] [--no-convert] [--pitch target\|source\|contour] [--semitones n] [--label l] [--check-words [--worker w]] [--events]`; set: `<id> kind= title= media= at=<a>,<b>\|off unread= ref= read=all\|none\|<n>,… read.<n>="excerpt"\|on\|off line.add="who: words" line.<n>=off line.<n>.who= line.<n>.side=left\|right\|auto line.<n>.text= line.<n>.time= line.<n>.redact=on\|off take.<n>=<take n>\|off [--from <file>]`; check: `<id> [--by <name>] [--undo]`; read: `[--post-take <n>] [--line-take screen:<id>:<line>=<n>]… [--voice-for h=v]… [--force] [--dry-run]`; `--json`, `--dry-run`, `--take <take>`) | a post's **SCREENS** ([report-video.md](report-video.md#screens-text-screenshots-read-as-part-of-the-post), [knobs.md](knobs.md#screens-a-posts-text-screenshots), `post-screens.mjs`): the text screenshots its attachments carry -- a DM exchange or an email shown in its video (`--at`: the seconds it is visible), an image that is a screenshot -- transcribed once (`--from`: a JSON screen, or text lines `[right] who: words \| time`, `- words`, `[redact] …`), checked by a person (`check`; a screen not checked is a lint WARNING; new words take the check away), and read whole or in excerpts. Each write is the post item's one writer (`updatePostItem`'s `screens`, one undo point), refused in the build's words (**exit 1**); an attachment a screen is in cannot be removed. An e-mail address, a phone number, an order or long number in a line is masked on the card and never said. `read` makes the THREAD READ with the screens (as `posts narrate <p> <item> --take --thread`): her own line from the take that plays (or the one the thread read used; `--post-take n` another), never made again; each read line in its speaker's voice (`who`: the post's author in hers, a handle or a character's name in theirs); `--line-take` takes a line from the item's take n (a recording of it), and a line's CHOSEN take (`take.<n>=`, the bench's select) is read in its place -- a recording nobody chose is named, never read in. `add --from-read`: a PICTURE-ONLY post's read (its `narration.script`) made its screen, a line per line, on its picture, read whole, NOT checked -- no speaker parsed out of it. `record`: ONE LINE in your voice ([report-video.md](report-video.md#a-line-in-your-own-voice), `lib/report/screenLineRecord.mjs`) -- the line as the read says it (its shapes and the redaction left out, an anonymous handle as its shown name), kept as new takes through `posts narrate --recording`'s chain: recorded, cleaned, converted to its SPEAKER's character's stock voice (none: kept as recorded, said), NONE picked, each carrying `screenLine`; refused on an item with no read of its own (**exit 1**). A line take is refused picked as the item's read, as `--post-take`, for another line, or once its line's words or speaker changed. `--as` may name only that character (another, or the narrator, **exit 1**). A take is a line's by its content (its screen, words and speaker), not its index. `--check-words` (the editor's transcribe op; opt-in, CLI only): refused when it is heard saying a shape or a number in words, an @handle, an anonymous author's handle or name, or a redacted term -- nothing kept -- and a warning on other words; the take keeps what it was heard saying. Without it nothing hears the recording: the lint warns for each chosen take not heard. A screen made `--from-read` is the post's read: `read` leaves his own piece out and refuses `--post-take`. Usage errors: **exit 2** | | `posts roles <project> [<item> …] [--write] [--set <n>=<role>,…] [--json]` | a narrated read **piece by piece** ([knobs.md](knobs.md#thread-reads-every-part-of-a-read-on-screen-while-it-is-said), [report-video.md](report-video.md#thread-reads)): the text each part of the picked take reads -- `parent:<i>`, `quoted`, `post`, `media:<i>` -- stored or inferred, what the card shows for each, and the build's guard (a part read off a post the card hides is refused). `--write` stores the inferred roles on the picked takes' parts (one write; the import stores them for every new take); `<item> --set n=role,…` sets parts' roles by hand (`off`: inferred again); a part out of range or an unknown role is refused (**exit 1**) | | `posts narrate <project> --import [--dry-run] [--json]` · `--list` · `<item> [--script "…"] [--pick <n>] [--approve\|--unapprove] [--off\|--on] [lead= tail= ramp= linger= clip=read\|full wet= lowpass= duck=on\|off short=hold\|loop attach=under\|after lufs= pace=fast\|normal]` · `<item> --take [--note "…"] [--voice v] [--engine e] [--speed s] [--script "…"]` · `<item> --derive <n> --op enhance\|convert [--engine e] [--voice v]` · `<item> --delete <n>` · `--all --draft-scripts [--force]` · `--all --take [--limit N]` · `--cut <k=v>…` | a **narrated post item** ([report-video.md](report-video.md#narrated-post-items), [knobs.md](knobs.md#a-narrated-post-item)): `--import` reads `narration/posts/index.json` (`[{id, entry, script, takes: [{file, engine, voice, seconds}], pick}]`, and a take's `take-<n>.parts.json`) into the cut in ONE write, measuring each take (length, loudness); a re-run adds only takes not there. `--take` asks the EDITOR for a new take (`POST /api/ops/tts`, its `out` the next `narration/posts/<postId>/take-<n>.<engine>-<voice>.wav`; a job, waited for; `ARCHILYZER_EDITOR_URL`, `WORKER_TOKEN`) and picks it, its `--note` kept with it; `--pick <n>` is the take's number as `--list` shows it. `--derive <n>` makes a NEW take from take n through the editor's `voice-enhance` / `voice-convert` op (a stock synthetic voice; "not installed" until the editor has the engine), the original kept; `--delete <n>` moves a take's file to the post's `.trash/`. A new script or pick takes the approval away. `--all --draft-scripts` writes every post's words as its script, VERBATIM (cleaned only to be spoken: a reply's leading @handles, links, emoji dropped -- a handle typed inside the message is kept and said "at <handle>", the lexicon first; `plan(s)` → plans, `w/` → with, `&` → and; paragraphs kept). `--cut` sets `render.postNarration` (and its read-follow: `follow=on\|off`, `follow.dim=`, `follow.ease=`; its thread reads: `thread.parent=`, `thread.quoted=`, `thread.carry=`, `thread.reveal=`, `thread.shrink=`, `thread.dim=`, `thread.seconds=`, `thread.pan=`). Refused in the build's words (**exit 1**) A `--take` whose read says a slur the cut BEEPS is word-timed by the editor's transcription before it is kept -- never waited on: with the transcription lane held (as while Orpheus runs) the take is kept as read and the timing deferred (it says so, naming `posts narrate <p> <item> --words` to run after the release; the build refuses the take until then), and a timing still queued after 5 min is deferred the same way. An excerpted item (`posts set-item … excerpt=`) reads its spans. | | `posts narrate <project> <item> --take --thread [--parents 0\|all\|none\|<n>] [--skip-parent <id\|parent:i>]… [--no-quoted] [--no-linked] [--read-seen] [--voice-for <handle>=<voice>]… [--voice v] [--engine e] [--speed s] [--no-screens] [--line-take screen:<id>:<line>=<n>]… [--note "…"] [--force] [--no-hold] [--dry-run] [--json]` | a **THREAD READ** as one command ([knobs.md](knobs.md#pronunciation-and-voices-the-lexicon-the-voice-map-a-thread-read), `lib/report/postThreadRead.mjs`): the post it answers (`--parents all`: every ancestor; `<n>`: parents 0..n; `none`), the post it quotes and the posts it links to, then his words, in DATE order, each in its author's voice (`--voice-for`, then the item's own character, this video's characters and voice map, the cast: `cast project`; his own: the narrator's) and at its character's speed (its synthetic preset's; `--speed`: every part at that one; Orpheus has none; a part at another speed is another cached part), the redaction, the slur filter (a beep is skipped: a joined read is not word-timed) and the lexicon (`posts say`) applied. A parent or quoted post the item before already shows is not read again (`--read-seen`: it is). Each part is synthesized ONCE by the editor's tts op into `narration/parts-cache/<sha1(voice\|text)>.wav` (the transcription lane held meanwhile, only if it was not; `--no-hold`: left alone), joined (0.8 s between pieces, 0.6 between paragraphs, 0.25 inside one) into `take-<n>.<engine>-thread.wav` with `take-<n>.parts.json`, saved with its parts' roles, its lexicon and how it was asked (`read`) and PICKED — one write (one undo point). `--dry-run`: the pieces, voices and parts (cached or not), nothing asked. Already up to date (same words and voices): nothing done, **exit 0** (`--force`: again). **`--post-take <n>`**: his OWN line is the item's take n (as `--list` numbers them) -- a recording, or one converted to his character's voice -- not synthesized; the context pieces are, in their authors' voices, and each part of the new take records where it came from (a synthesized part its parts-cache file and voice; the take's part its file and `take`: that take's id; the read's `postTake`). A thread take, or one whose file is gone: **exit 1**. A part not synthesized: **exit 1** (the parts made stay cached; run it again); `--json` prints `{ok: false, error}` too. A usage error: **exit 2** Its SCREENS (`posts screen`) are read after his words, each line in its speaker's voice (`--no-screens`: left out); `--line-take screen:<id>:<line>=<n>` takes a line from the item's take n as `--post-take` does his own | diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -1854,8 +1854,8 @@ lint says so. Nothing in a screen is drawn that is not read, unless `unread: "di | `checked: { by, at }` -- the transcription read against the screenshot (a screen not checked is a lint WARNING; new words take it away) | **checked** | `… check s1 [--by <name>]` · `--undo` | same | | THE READ -- her words, then each read line in its speaker's voice; her own line from the take that plays (never made again); a line from an existing take; a line's CHOSEN take in its place | **Make the read** (a job), the command shown beside it | `umtool posts screen <p> <item> read [--post-take n] [--line-take screen:s1:3=4]… [--dry-run]` (= `posts narrate <p> <item> --take --thread`, `--no-screens` leaves them out) | `POST /api/report/post-narration {project, op: "screen-read", id}` (a job; `GET ?project&id&screenJob=<job>`) | | a screen from a PICTURE-ONLY post's read -- its `narration.script` a line per line, on its picture, read whole, not checked | **From its read** (a picture-only post with a script) | `umtool posts screen <p> <item> add --from-read [--media i] [--kind text] [--id] [--title]` | same as `screens[]` | -| A LINE IN YOUR VOICE -- the line as the read says it recorded, cleaned, converted to its speaker's character's stock voice, each a new take with `screenLine`, none picked ([report-video.md](report-video.md#a-line-in-your-own-voice)) | each read line's **Record** / **Stop** / play back / **Discard** / **Keep** (a job; off while the draft is unsaved) | `umtool posts screen <p> <item> record s1 2 --recording my-read.wav [--as <character>] [--no-clean] [--no-trim] [--no-convert] [--pitch …] [--semitones n] [--label l]` · `--check-words` (the editor's transcribe op: refused on a number, a handle or a redacted term heard; CLI only) | `POST /api/report/post-narration` multipart `{project, id, line: "screen:s1:2", label?, part}` (a job) | -| `lineTakes` -- `{ "<n>": "<take id>" }`, the take CHOSEN to be read in line n's place (a recording of that line); none: synthesized | each read line's **reads** select (saved with Save) | `… set s1 take.2=5` (`take.2=off`) | `POST /api/report/post-item {op: "set", patch: {screens}}` | +| A LINE IN YOUR VOICE -- the line as the read says it recorded, cleaned, converted to its speaker's character's stock voice, each a new take with `screenLine`, none picked ([report-video.md](report-video.md#a-line-in-your-own-voice)) | each read line's **Record** / **Stop** / play back / **Discard** / **Keep** (a job; off while the draft is unsaved) | `umtool posts screen <p> <item> record s1 2 --recording my-read.wav [--as <the speaker's character>] [--no-clean] [--no-trim] [--no-convert] [--pitch …] [--semitones n] [--label l]` · `--check-words` (the editor's transcribe op: refused on a number -- in digits or words --, a handle, an anonymous author's name or a redacted term heard; the take keeps what was heard; CLI only. Without it nothing hears the recording: the lint warns, the bench says "not heard") | `POST /api/report/post-narration` multipart `{project, id, line: "screen:s1:2", label?, part}` (a job) | +| `lineTakes` -- `{ "<n>": "<take id>" }`, the take CHOSEN to be read in line n's place (a recording that says that line as it is now: its screen, words and speaker; a removed line above it moves the key); none: synthesized | each read line's **reads** select, each recording marked heard / not heard (saved with Save) | `… set s1 take.2=5` (`take.2=off`) | `POST /api/report/post-item {op: "set", patch: {screens}}` | What is never drawn nor said, marked or not -- in a line, a speaker, a time or a title: an e-mail address, a phone-style run of nine digits or more or a local number, an order / confirmation / tracking / account / card / code value, a diff --git a/umtool/docs/report-video.md b/umtool/docs/report-video.md @@ -1583,9 +1583,13 @@ read**; `post-screens.mjs linesOfRead`, `screenFromRead`). A PICTURE-ONLY post w words typed once -- its read's script (`narration.script`). `--from-read` makes them its screen: a line per line of the script (blank lines and Orpheus emotion tags dropped, a line past 600 characters split at its sentence ends), on its picture (its first image; a GIF or a video visible its whole length; `--media` another), kind `text` (`--kind`), read -whole, NOT checked (the lint says so until a person reads it against the picture). A "who:" is never parsed out of a -read -- a shape or a heading would become a speaker ("Order number: 4419"); set the speakers after. Refused off a -picture-only post or with no script. As any screen, nothing of it is drawn until the read reads it. +whole, NOT checked (the lint says so until a person reads it against the picture), `source: "read"`. A "who:" is never +parsed out of a read -- a shape or a heading would become a speaker ("Order number: 4419"); set the speakers after; +only Orpheus's own tags (`<laugh> <chuckle> <sigh> <cough> <sniffle> <groan> <yawn> <gasp>`) are left out, any other +`<…>` is words. Refused off a picture-only post or with no script. As any screen, nothing of it is drawn until the read +reads it -- and until then the item plays its read as it was, which the build refuses while it says what the screen +masks (below). Such a screen IS the post's read: the thread read leaves his own piece out (it would say the picture's +words twice), reuses no take of it, and refuses `--post-take`. #### A line in your own voice @@ -1593,32 +1597,55 @@ A read line of a screen may be RECORDED by the operator (`lib/report/screenLineR <item> record <id> <n> --recording <file>`; the bench's per-line **Record**). What he reads is the line AS THE READ SAYS IT -- its read run, its shapes left out, the redaction left out, an anonymous handle as its shown name (never the raw line: a masked number is never on the prompt). It is kept through `posts narrate --recording`'s chain as NEW takes of the -item -- recorded (a new `take-<n>.recorded-<label>.wav`; no recording is ever rewritten), cleaned, converted to the -line's SPEAKER's character's STOCK voice (the author's own lines her character; anyone else the character holding their -handle, this video's first then the cast's; never the narrator; none: kept as recorded, and said) -- each carrying -`screenLine: { screen, n, said, speaker }`, NONE of them picked, the item's script untouched. Its script is the line's +item -- recorded (a new `take-<n>.recorded-<label>.wav`, its name CLAIMED by an exclusive create, the next number while +one is there: two recordings kept at once never share a file, and no recording is ever overwritten or renamed over -- +on every recording path, the record page's Keep too), cleaned, converted to the line's SPEAKER's character's STOCK voice +(the author's own lines her character; anyone else the character holding their handle, this video's first then the +cast's; never the narrator; none: kept as recorded, and said; `--as` may name that character and no other) -- each +carrying `screenLine: { screen, n, said, speaker, heard? }`, NONE of them picked, the item's script untouched. Its script is the line's words as the read says them (the lexicon's spellings in), so the read holds it to the line (`lineTakeProblem`). It is refused on an item with no read of its own (a line is read inside one). A line take is read ONLY WHEN CHOSEN -- nothing is said that the operator did not choose: the screen's `lineTakes` (`{ "<n>": "<take id>" }`: the bench's per-line select, saved with Save; `posts screen … set <id> take.<n>=<take>|off`) -or `--line-take`. `read` without a choice synthesizes the line and NAMES the recordings nobody chose; the lint warns of +or `--line-take`. A take is a line's by its CONTENT -- its screen, its words as a read writes them, its speaker -- not by +the index it was recorded at: a line removed above it moves the choice's key and the take still says its line; a take +whose words or speaker are not the line's as it is now is refused. `read` without a choice synthesizes the line and NAMES the recordings nobody chose; the lint warns of them too, of a chosen take recorded for the line as it was, and of a picked read that does not play its chosen take. REFUSED: a line take picked as the item's read (the writer), used as `--post-take`, chosen for or named as another line, read after its line's words or speaker changed (record it again), or deleted while chosen (unchoose it first); a line removed takes its choice with it. Its disclosure in the read: "a recorded reading converted to a stock voice (engine · voice)", or "a recorded reading". `--check-words` (opt-in, the CLI only; the editor's transcribe op): the recording is -transcribed before anything is kept and REFUSED when it is heard saying a shape, an @handle, an anonymous handle or a -redacted term; other words are a warning (the transcription may mishear). Without it, the recording is what he read. +transcribed before anything is kept and REFUSED when it is heard saying a shape or a number in words ("five five five +two oh one…"), an @handle, an anonymous author's handle or display name (bare, possessive, or spaced: "secret kid"), or a +redacted term; other words are a warning (the transcription may mishear); the take keeps what it was heard saying and +against which words (`screenLine.heard`). WHAT IS VERIFIED: without `--check-words`, NOTHING hears the recording -- the +read holds the take's script (the line's own words, typed) to the line, which is the line compared with itself; the +lint WARNS for every chosen take not heard ("was not heard -- nothing verified what the recording says") and the bench +marks each recording "heard" or "not heard". What is always checked: the prompt never shows what the card masks, the +take is the line's (its screen, words and speaker as they are now), and it is never the item's read. On the bench, Record and Make the read are off while the draft differs from what is saved (a line is recorded as it is -saved); Keep and Make the read are each ONE umtool job (`posts screen … record`, `posts screen … read`), followed on the -page; a job's result never replaces edits made meanwhile. +saved); Keep and Make the read are each ONE umtool job (`posts screen … record`, `posts screen … read`; the upload in a +scratch dir of its own, mkdtemp), followed on the page; a job's result never replaces edits made meanwhile. + +**No preview plays a read the build refuses** (post-thread.mjs `playableEntry`, the enforced lint's own judgement on the +item as written: `itemReadRefusals`). The writer lets a screen change under its read -- a line's words or speaker +edited, a line removed, redacted or no longer read -- and the build refuses the old read; so do Play, Present (the +public payload too), the card page and the post bench's player: the item plays SILENT, as an item not narrated, no take +of it in the payload, saying why ("the read is older than its screen … make the read again"). **No part of a read may +say what the item's screens hide** (`readSaysHiddenErrors`, in the enforced lint): his words, a context post, a screen +line or a take with no parts that says a number (four digits or more, however joined) or an e-mail one of the item's +screens masks, or three or more words of a line marked `redact`, refuses the read -- naming the part and the line, never +the value. (The project's own redaction terms are a read's to leave out -- spokenRead -- and an anonymous handle the +anonymity lint's.) Present's PUBLIC payload carries the screens as the card draws them -- every shape masked in words, +speakers, times and titles (an excerpt masked in place), a redacted line wordless, a speaker the card blurs nameless -- +never a raw line. **Byte-identical without.** An item with no `screens` draws, plans and keys exactly as before (`post-screens-pin.test.mjs`); a segment with screens carries `screens: POST_SCREEN_DRAW_V` in its key. An item with -round-1 screens and none of `lineTakes` / `screenLine` draws, plans, keys, validates, guards and lints as before -(`post-screens-pin2.test.mjs`). +round-1 screens and none of `lineTakes` / `screenLine` draws, plans, keys, validates, guards and lints as before -- its +enforced lint, thread-read warnings and new-read plan too (`post-screens-pin2.test.mjs`). The knobs: [knobs.md](knobs.md#screens-a-posts-text-screenshots); the CLI: `umtool posts screen <p> <item> list|add|set|rm|check|read|record` ([cli.md](cli.md)); the post bench's **screens** section. diff --git a/umtool/e2e/post-screens.spec.ts b/umtool/e2e/post-screens.spec.ts @@ -200,3 +200,28 @@ test("a read line in your own voice: Record / Stop / Keep (one job, none picked) expect(playing.parts?.find((p) => p.role === "screen:s1:0")?.take).toBe(converted); expect(playing.parts?.some((p) => p.role === "screen:s1:1" && !p.take)).toBe(true); }); + +test("a read older than its screen is not played on the bench: the item plays silent and says why (review round 1, M1)", async ({ page }) => { + // Its read reads the screen's two lines; then line 0's words are edited under it (the writer takes it). + const m = JSON.parse(readFileSync(MANIFEST, "utf8")); + const e = m.timeline.find((x: { id: string }) => x.id === "p-11"); + e.screens = [{ id: "s1", media: 0, at: [0.5, 3.5], kind: "dm", read: "all", lines: [{ who: "TheQuartering", text: "call me at 555 201 4477 fatso" }, { who: "narrsubject", text: "you first" }] }]; + e.narration.script = "The video speaks for itself."; + e.narration.takes[0].parts = [ + { n: 1, para: 0, text: "The video speaks for itself.", start: 0, seconds: 0.6, role: "post" }, + { n: 2, para: 100, text: "hop on the scale fatso", start: 0.8, seconds: 0.5, role: "screen:s1:0", line: "hop on the scale fatso", speaker: "TheQuartering" }, + { n: 3, para: 200, text: "you first", start: 1.5, seconds: 0.5, role: "screen:s1:1", line: "you first", speaker: "narrsubject" }, + ]; + writeFileSync(MANIFEST, JSON.stringify(m, null, 2) + "\n"); + await page.setViewportSize({ width: 1366, height: 1100 }); + await page.goto(urls.postBenchHref(PROJECT, "p-11")); + const player = page.locator('[data-post-play="p-11"]').first(); + await expect(player).toHaveAttribute("data-post-read-refused", "1", { timeout: 15_000 }); + await expect(player.locator("[data-post-read-refused-reason]")).toContainText("make the read again"); + await expect(player).not.toHaveAttribute("data-post-narrated", "1"); + await expect(player.locator("[data-post-narration-audio]")).toHaveCount(0); + // The card page draws no screen (no read reads it) and never the old lit lines. + const frame = page.frameLocator('[data-post-card-frame="read"]'); + await expect(frame.locator("body")).toHaveAttribute("data-post-ready", "1", { timeout: 15_000 }); + await expect(frame.locator('[data-post-screen="s1"]')).toHaveCount(0); +}); diff --git a/umtool/lib/cli/groups.mjs b/umtool/lib/cli/groups.mjs @@ -1046,8 +1046,8 @@ export const GROUPS = [ "**one phrase of an approved read re-voiced**, the rest untouched (`lib/report/postRevoice.mjs`; operator, 5 Nov: the countdown gabbled, and pauses cut into it \"choppy\"): the phrase found in the picked take's word timings as `--pause` finds a word (`#n`, `--target`; inside one part), the original cut from just before its first word to just after its last -- each cut at the quietest 10 ms within ±40 ms of the boundary, and when that is still speech within ±0.15 s (never inside the phrase as timed; a nearer quiet preferred) -- **`--say` alone synthesized by the editor's TTS** (narrate-via-editor; the engine of the root take, the voice of the part the phrase is in, `--voice` overrides; the project's lexicon, redaction and slur filter applied; kept in `narration/parts-cache/` like a thread read's parts, so asking again is free), its lead and tail of silence trimmed, loudness-matched to the speech in the 2 s either side (±6 dB) and spliced in with equal-power crossfades (`--xfade`, 0–0.2 s) at both joins, at the take's rate and layout. The length is exact: the take − the span cut + the piece. Everything after moves by the difference (its words, the part holding the span, the later parts) so zooms, captions, slams, beeps and the read-follow stay on their words; the new words are timed from the piece's speech and marked `estimated` (a later `posts narrate … --words` refines them); the part's text and the script say `--say`. A derived take (`steps: [{op: \"revoice\", revoice: {word, count, words, phrase, say, said, voice, engine, from, to, seconds, gain, xfade, key}}]`) picked in ONE write; re-voicing exactly the words a re-voice put in re-cuts from the take before. `--dry-run`: the span (words, seconds), each cut and its level, what is said and in which voice, the length change when the piece is cached -- no TTS. A cut still in speech is warned of (the word timings off there): `--splice 65.03-66.00` sets the cuts (either side may be left out). `--in-take <t>` puts it in a take's read. No word timings (naming `posts narrate <p> <item> --words`), the phrase not read or across two parts, a recorded read, the TTS failing: **exit 1**; no `--say`, a bad voice, crossfade or splice, `--revoice` with another reread form: **exit 2**"], ["`posts progress <project> [auto\\|on\\|off\\|default] [--json]`", "the cut's **progress bar** default (`render.posts.progress`, `updatePostProgressRender`; [report-video.md](report-video.md#the-progress-bar)); bare, which items draw it"], - ["`posts screen <project> <item> list\\|add\\|set\\|rm\\|check\\|read\\|record …` (add: `--media <i> [--at <from>,<to>] --kind dm\\|email\\|post\\|text [--id <id>] [--title \"…\"] [--from <file>] [--line \"who: words\"]… [--read all\\|none\\|<n>,…] [--unread omit\\|dim] [--ref <channel>/<postId>]` or `--from-read [--media <i>] [--kind …]`; record: `<id> <line> --recording <file> [--as <character>] [--no-clean\\|--clean] [--no-trim\\|--trim] [--no-convert] [--pitch target\\|source\\|contour] [--semitones n] [--label l] [--check-words [--worker w]] [--events]`; set: `<id> kind= title= media= at=<a>,<b>\\|off unread= ref= read=all\\|none\\|<n>,… read.<n>=\"excerpt\"\\|on\\|off line.add=\"who: words\" line.<n>=off line.<n>.who= line.<n>.side=left\\|right\\|auto line.<n>.text= line.<n>.time= line.<n>.redact=on\\|off take.<n>=<take n>\\|off [--from <file>]`; check: `<id> [--by <name>] [--undo]`; read: `[--post-take <n>] [--line-take screen:<id>:<line>=<n>]… [--voice-for h=v]… [--force] [--dry-run]`; `--json`, `--dry-run`, `--take <take>`)", - "a post's **SCREENS** ([report-video.md](report-video.md#screens-text-screenshots-read-as-part-of-the-post), [knobs.md](knobs.md#screens-a-posts-text-screenshots), `post-screens.mjs`): the text screenshots its attachments carry -- a DM exchange or an email shown in its video (`--at`: the seconds it is visible), an image that is a screenshot -- transcribed once (`--from`: a JSON screen, or text lines `[right] who: words \\| time`, `- words`, `[redact] …`), checked by a person (`check`; a screen not checked is a lint WARNING; new words take the check away), and read whole or in excerpts. Each write is the post item's one writer (`updatePostItem`'s `screens`, one undo point), refused in the build's words (**exit 1**); an attachment a screen is in cannot be removed. An e-mail address, a phone number, an order or long number in a line is masked on the card and never said. `read` makes the THREAD READ with the screens (as `posts narrate <p> <item> --take --thread`): her own line from the take that plays (or the one the thread read used; `--post-take n` another), never made again; each read line in its speaker's voice (`who`: the post's author in hers, a handle or a character's name in theirs); `--line-take` takes a line from the item's take n (a recording of it), and a line's CHOSEN take (`take.<n>=`, the bench's select) is read in its place -- a recording nobody chose is named, never read in. `add --from-read`: a PICTURE-ONLY post's read (its `narration.script`) made its screen, a line per line, on its picture, read whole, NOT checked -- no speaker parsed out of it. `record`: ONE LINE in your voice ([report-video.md](report-video.md#a-line-in-your-own-voice), `lib/report/screenLineRecord.mjs`) -- the line as the read says it (its shapes and the redaction left out, an anonymous handle as its shown name), kept as new takes through `posts narrate --recording`'s chain: recorded, cleaned, converted to its SPEAKER's character's stock voice (none: kept as recorded, said), NONE picked, each carrying `screenLine`; refused on an item with no read of its own (**exit 1**). A line take is refused picked as the item's read, as `--post-take`, for another line, or once its line's words or speaker changed. `--check-words` (the editor's transcribe op; opt-in, CLI only): refused when it is heard saying a shape, an @handle, an anonymous handle or a redacted term -- nothing kept -- and a warning on other words. Usage errors: **exit 2**"], + ["`posts screen <project> <item> list\\|add\\|set\\|rm\\|check\\|read\\|record …` (add: `--media <i> [--at <from>,<to>] --kind dm\\|email\\|post\\|text [--id <id>] [--title \"…\"] [--from <file>] [--line \"who: words\"]… [--read all\\|none\\|<n>,…] [--unread omit\\|dim] [--ref <channel>/<postId>]` or `--from-read [--media <i>] [--kind …]`; record: `<id> <line> --recording <file> [--as <the speaker's character>] [--no-clean\\|--clean] [--no-trim\\|--trim] [--no-convert] [--pitch target\\|source\\|contour] [--semitones n] [--label l] [--check-words [--worker w]] [--events]`; set: `<id> kind= title= media= at=<a>,<b>\\|off unread= ref= read=all\\|none\\|<n>,… read.<n>=\"excerpt\"\\|on\\|off line.add=\"who: words\" line.<n>=off line.<n>.who= line.<n>.side=left\\|right\\|auto line.<n>.text= line.<n>.time= line.<n>.redact=on\\|off take.<n>=<take n>\\|off [--from <file>]`; check: `<id> [--by <name>] [--undo]`; read: `[--post-take <n>] [--line-take screen:<id>:<line>=<n>]… [--voice-for h=v]… [--force] [--dry-run]`; `--json`, `--dry-run`, `--take <take>`)", + "a post's **SCREENS** ([report-video.md](report-video.md#screens-text-screenshots-read-as-part-of-the-post), [knobs.md](knobs.md#screens-a-posts-text-screenshots), `post-screens.mjs`): the text screenshots its attachments carry -- a DM exchange or an email shown in its video (`--at`: the seconds it is visible), an image that is a screenshot -- transcribed once (`--from`: a JSON screen, or text lines `[right] who: words \\| time`, `- words`, `[redact] …`), checked by a person (`check`; a screen not checked is a lint WARNING; new words take the check away), and read whole or in excerpts. Each write is the post item's one writer (`updatePostItem`'s `screens`, one undo point), refused in the build's words (**exit 1**); an attachment a screen is in cannot be removed. An e-mail address, a phone number, an order or long number in a line is masked on the card and never said. `read` makes the THREAD READ with the screens (as `posts narrate <p> <item> --take --thread`): her own line from the take that plays (or the one the thread read used; `--post-take n` another), never made again; each read line in its speaker's voice (`who`: the post's author in hers, a handle or a character's name in theirs); `--line-take` takes a line from the item's take n (a recording of it), and a line's CHOSEN take (`take.<n>=`, the bench's select) is read in its place -- a recording nobody chose is named, never read in. `add --from-read`: a PICTURE-ONLY post's read (its `narration.script`) made its screen, a line per line, on its picture, read whole, NOT checked -- no speaker parsed out of it. `record`: ONE LINE in your voice ([report-video.md](report-video.md#a-line-in-your-own-voice), `lib/report/screenLineRecord.mjs`) -- the line as the read says it (its shapes and the redaction left out, an anonymous handle as its shown name), kept as new takes through `posts narrate --recording`'s chain: recorded, cleaned, converted to its SPEAKER's character's stock voice (none: kept as recorded, said), NONE picked, each carrying `screenLine`; refused on an item with no read of its own (**exit 1**). A line take is refused picked as the item's read, as `--post-take`, for another line, or once its line's words or speaker changed. `--as` may name only that character (another, or the narrator, **exit 1**). A take is a line's by its content (its screen, words and speaker), not its index. `--check-words` (the editor's transcribe op; opt-in, CLI only): refused when it is heard saying a shape or a number in words, an @handle, an anonymous author's handle or name, or a redacted term -- nothing kept -- and a warning on other words; the take keeps what it was heard saying. Without it nothing hears the recording: the lint warns for each chosen take not heard. A screen made `--from-read` is the post's read: `read` leaves his own piece out and refuses `--post-take`. Usage errors: **exit 2**"], ["`posts roles <project> [<item> …] [--write] [--set <n>=<role>,…] [--json]`", "a narrated read **piece by piece** ([knobs.md](knobs.md#thread-reads-every-part-of-a-read-on-screen-while-it-is-said), [report-video.md](report-video.md#thread-reads)): the text each part of the picked take reads -- `parent:<i>`, `quoted`, `post`, `media:<i>` -- stored or inferred, what the card shows for each, and the build's guard (a part read off a post the card hides is refused). `--write` stores the inferred roles on the picked takes' parts (one write; the import stores them for every new take); `<item> --set n=role,…` sets parts' roles by hand (`off`: inferred again); a part out of range or an unknown role is refused (**exit 1**)"], ["`posts narrate <project> --import [--dry-run] [--json]` · `--list` · `<item> [--script \"…\"] [--pick <n>] [--approve\\|--unapprove] [--off\\|--on] [lead= tail= ramp= linger= clip=read\\|full wet= lowpass= duck=on\\|off short=hold\\|loop attach=under\\|after lufs= pace=fast\\|normal]` · `<item> --take [--note \"…\"] [--voice v] [--engine e] [--speed s] [--script \"…\"]` · `<item> --derive <n> --op enhance\\|convert [--engine e] [--voice v]` · `<item> --delete <n>` · `--all --draft-scripts [--force]` · `--all --take [--limit N]` · `--cut <k=v>…`", diff --git a/umtool/lib/report/postRecord.mjs b/umtool/lib/report/postRecord.mjs @@ -98,6 +98,58 @@ export async function decodePart(src, out) { return { seconds: r3(seconds ?? 0), silences }; } +/** + * A NEW RECORDED TAKE's NAME, CLAIMED (review round 1, b): `take-<n>.recorded-<label>.wav` created EMPTY with an + * exclusive create (`wx`), the next n tried while one is there -- so two recordings kept at once never write the same + * file, and no recording already there is ever overwritten or renamed over. `{ n, rel, abs }`; the caller writes the + * take there (a rename over its own empty claim) or, failing, gives the claim back (releaseClaim). + * + * @param {string} projectDir + * @param {Record<string, any>} entry + * @param {string} label + */ +export async function claimRecordedTake(projectDir, entry, label) { + const pid = postIdOf(entry); + const dir = path.join(projectDir, ...takesDirOf(pid).split("/")); + await mkdir(dir, { recursive: true }); + let n = nextTakeNumber(entry, await readdir(dir).catch(() => [])); + for (let tries = 0; tries < 1000; tries += 1, n += 1) { + const rel = `${takesDirOf(pid)}/take-${n}.recorded-${label}.wav`; + const abs = path.join(projectDir, ...rel.split("/")); + try { + const fh = await open(abs, "wx"); + await fh.close(); + return { n, rel, abs }; + } catch (err) { + if (err?.code !== "EEXIST") throw err; + } + } + throw new Error(`no free take number for a recording of ${entry.id}`); +} + +/** Any take file's name claimed the same way: `makeRel(n)` for n from `n0` on, the first created exclusively. `{ n, rel, abs }`. */ +export async function claimTakeName(projectDir, makeRel, n0) { + for (let n = n0, tries = 0; tries < 1000; tries += 1, n += 1) { + const rel = makeRel(n); + const abs = path.join(projectDir, ...rel.split("/")); + await mkdir(path.dirname(abs), { recursive: true }); + try { + const fh = await open(abs, "wx"); + await fh.close(); + return { n, rel, abs }; + } catch (err) { + if (err?.code !== "EEXIST") throw err; + } + } + throw new Error("no free take number"); +} + +/** A claim given back: its file removed only while it is still the empty claim (never a recording). */ +export async function releaseClaim(abs) { + const st = await stat(abs).catch(() => null); + if (st?.isFile() && st.size === 0) await rm(abs, { force: true }); +} + /** The room kept either side of a part's words: a preset's `trim.padMs`, else the recorder's own. */ export const roomOf = (trim) => (trim && Number.isFinite(trim.padMs) ? { head: trim.padMs / 1000, tail: trim.padMs / 1000 } : RECORD_ROOM); @@ -179,13 +231,20 @@ export async function keepRecording(project, entry, parts, { label = "operator", if (!RECORD_LABEL_RE.test(label)) throw new Error(`"${label}" is not a voice label (a-z, 0-9, - and _)`); if (!parts.length) throw new Error("nothing was recorded"); const pid = postIdOf(entry); - const dir = path.join(project.dir, ...takesDirOf(pid).split("/")); - await mkdir(dir, { recursive: true }); - const n = nextTakeNumber(entry, await readdir(dir).catch(() => [])); - const base = `take-${n}.recorded-${label}`; - const rel = `${takesDirOf(pid)}/${base}.wav`; - const partsRel = `${takesDirOf(pid)}/${base}.parts`; + // Its name CLAIMED (claimRecordedTake): never another recording's, kept at the same moment or before. + const claim = await claimRecordedTake(project.dir, entry, label); + const rel = claim.rel; + const partsRel = rel.replace(/\.wav$/, ".parts"); const partsDir = path.join(project.dir, ...partsRel.split("/")); + try { + return await keepClaimed(project, entry, parts, { label, manifest, note, script, trim, spans, screenLine, room, pid, rel, partsRel, partsDir }); + } catch (err) { + await releaseClaim(claim.abs); + throw err; + } +} + +async function keepClaimed(project, entry, parts, { label, manifest, note, script, trim, spans, screenLine, room, rel, partsRel, partsDir }) { await mkdir(partsDir, { recursive: true }); // Each part: decoded, measured, cut to its marks or trimmed of its silence at either end. const sources = []; diff --git a/umtool/lib/report/postScreensCli.mjs b/umtool/lib/report/postScreensCli.mjs @@ -26,7 +26,7 @@ import { readFile } from "node:fs/promises"; import path from "node:path"; import { draftScript, takeIdOf } from "umtool-report-to-video/post-narration"; -import { chosenLineTakes, lineTakesOf as lineRecordingsOf } from "umtool-report-to-video/post-thread"; +import { chosenLineTakes, lineTakeCurrent, lineTakesOf as lineRecordingsOf } from "umtool-report-to-video/post-thread"; import { voiceOverridesOf } from "umtool-report-to-video/post-say"; import { readManifest } from "../projects/report.mjs"; import { withEditNotes } from "./edit-guard.mjs"; @@ -61,9 +61,10 @@ export const SCREEN_USAGE = [ " (--post-take n: another), each read line in its speaker's voice; --line-take: that line from the item's take n;", " a line's CHOSEN take (take.<n>=, the bench's select) in its place. A recording nobody chose is said, never read in.", " record: ONE LINE in your voice -- the line as the read says it (its shapes and redaction left out) recorded, then", - " cleaned and converted to its SPEAKER's character's stock voice (none: kept as recorded), each a new take, none of", - " them picked; choose it for the line (set <id> take.<n>=<take>), then read. --check-words (the editor's transcribe", - " op): refused when it is heard saying a shape, an @handle, an anonymous handle or a redacted term; nothing kept.", + " cleaned and converted to its SPEAKER's character's stock voice (none: kept as recorded; --as may only name that one),", + " each a new take, none of them picked; choose it for the line (set <id> take.<n>=<take>), then read. --check-words", + " (the editor's transcribe op): refused when it is heard saying a shape or a number in words, an @handle, an", + " anonymous author's handle or name, or a redacted term; nothing kept. Without it nothing hears the recording.", ].join("\n"); export class ScreenUsageError extends Error { @@ -345,7 +346,9 @@ export async function screenCommand(project, rest, { flags, str: flag, multi, js const k = Number(v); if (!/^\d{1,3}$/.test(String(v)) || k < 1 || k > takes.length) fail(`take.${n}= takes a take's number (1–${takes.length}) or off`); const t = takes[k - 1]; - if (!isObj(t?.screenLine) || t.screenLine.screen !== sc.id || t.screenLine.n !== n) fail(`take ${k} is not a recording of line ${n} of screen ${sc.id}${isObj(t?.screenLine) ? ` (it is of line ${t.screenLine.n} of screen ${t.screenLine.screen})` : ""}: record it (posts screen <p> ${e.id} record ${sc.id} ${n} --recording <file>)`); + if (!isObj(t?.screenLine) || t.screenLine.screen !== sc.id) fail(`take ${k} is not a recording of a line of screen ${sc.id}${isObj(t?.screenLine) ? ` (it is of screen ${t.screenLine.screen})` : ""}: record it (posts screen <p> ${e.id} record ${sc.id} ${n} --recording <file>)`); + // Owned by its CONTENT: it must say line n as it is now (its words, its speaker), whatever line it was recorded as. + if (lineTakeCurrent(e, t, sc.id, n) !== true) fail(`take ${k} does not say line ${n} of screen ${sc.id} as it is now (it was recorded for line ${t.screenLine.n}: other words or another speaker): record it (posts screen <p> ${e.id} record ${sc.id} ${n} --recording <file>)`); return takeIdOf(t); } }); // Words changed: what was checked is not what is there now. diff --git a/umtool/lib/report/postScreensReview3.test.mjs b/umtool/lib/report/postScreensReview3.test.mjs @@ -161,3 +161,109 @@ test("M2 --from-read: its screen IS the post's read -- the post part is not read const typed = { ...item, screens: [{ id: "s1", media: 0, kind: "text", source: "transcribed", read: "all", lines: [{ text: "hello" }] }] }; assert.deepEqual(threadReadPlan({ render: {}, timeline: [typed] }, typed, {}).pieces.map((p) => p.role), ["post", "screen:s1:0"]); }); + +// --------------------------------------------------------------------------- +// SHOULD-FIXES (b, d, e, f, j) -- a is in postScreensRound2.test.mjs (content-based ownership). +// --------------------------------------------------------------------------- +import { readFile, readdir, stat } from "node:fs/promises"; +import { encodeWav16 } from "yt-dlp-transcript-common/lib/montage/voiceMatch.mjs"; +import { VOICE_A, VOICE_B, syntheticVoice, withSilence } from "yt-dlp-transcript-common/testing/audio/syntheticVoice.mjs"; +import { claimRecordedTake, keepRecording } from "./postRecord.mjs"; +import { heardProblem, recordScreenLine } from "./screenLineRecord.mjs"; +import { lineTakeProblem } from "./postThreadRead.mjs"; +import { linesOfRead } from "umtool-report-to-video/post-screens"; +import { lineTakeWarnings } from "umtool-report-to-video/post-thread"; + +const tone = async (file, voice = VOICE_A, seconds = 1) => { + await mkdir(path.dirname(file), { recursive: true }); + await writeFile(file, encodeWav16(withSilence(syntheticVoice({ ...voice, seconds }), { before: 0.1, after: 0.1 }))); +}; +const OWN_TAKE = { file: "narration/posts/2117/take-1.kokoro-af_heart.wav", engine: "kokoro", voice: "af_heart", seconds: 1, script: "Hey, you told me." }; +const plainItem = () => ({ ...ITEM, narration: { script: "Hey, you told me.", takes: [OWN_TAKE], pick: 0 } }); + +test("b: two recordings kept at once never write one file; a recording already there is never overwritten (an exclusive claim, the next number)", async () => { + const p = await project("b-claim", plainItem()); + // A recording already on disk at the number the item would give next (not in the manifest: a crash, another session). + const there = path.join(p.dir, "narration/posts/2117/take-2.recorded-operator.wav"); + await tone(there, VOICE_B, 0.5); + const before = await readFile(there); + const a = path.join(ROOT, "b-a.wav"); + const b = path.join(ROOT, "b-b.wav"); + await tone(a, VOICE_A, 1); + await tone(b, VOICE_B, 1.3); + const e = JSON.parse(await readFile(path.join(p.dir, "video.manifest.json"), "utf8")).timeline[0]; + const got = await Promise.allSettled([keepRecording(p, e, [{ file: a, text: "x" }]), keepRecording(p, e, [{ file: b, text: "x" }])]); + const files = got.filter((x) => x.status === "fulfilled").map((x) => x.value.take.file); + assert.ok(files.length >= 1); + assert.ok(!files.includes("narration/posts/2117/take-2.recorded-operator.wav"), "the file already there was not taken"); + assert.deepEqual(await readFile(there), before, "never overwritten"); + const names = (await readdir(path.join(p.dir, "narration/posts/2117"))).filter((f) => /^take-\d+\.recorded-operator\.wav$/.test(f)); + assert.equal(new Set(names).size, names.length); + assert.ok(names.length >= 3, `both recordings kept in files of their own: ${names}`); + for (const f of names) assert.ok((await stat(path.join(p.dir, "narration/posts/2117", f))).size > 0, `${f} is a recording, not an empty claim`); + // The claim itself: exclusive, the next number while one is there. + const c1 = await claimRecordedTake(p.dir, e, "operator"); + const c2 = await claimRecordedTake(p.dir, e, "operator"); + assert.notEqual(c1.rel, c2.rel); +}); + +test("d: --check-words refuses an anonymous author's handle or name in any spoken form, and a number said in words (probe h1)", () => { + const o = { handles: ["secretkid"], names: ["Jeremy Smith"], terms: ["Jenny"], lineTakeProblem }; + for (const heard of ["ask secretkid about it", "ask secretkid's mom about it", "ask secret kid about it", "ask Secret Kid about it", "ask SecretKid. about it", "ask @secretkid about it", + "call five five five two oh one four four seven seven", "my number is 555 201 4477", "email jane at gmail dot com", "ask Jeremy Smith about it", "ask jeremysmith's dog", "ask jenny about it"]) { + assert.ok(heardProblem(heard, "ask Kid A about it", o).refused, heard); + } + assert.deepEqual(heardProblem("ask Kid A about it", "ask Kid A about it", o), { refused: null, warning: null }); + assert.ok(heardProblem("about it ask Kid A", "ask Kid A about it", o).warning, "other words: a warning"); + assert.equal(heardProblem("one or two of them", "one or two of them", o).refused, null, "a few number words are words"); +}); + +test("e: linesOfRead leaves out only Orpheus's tags -- any other <word> is the picture's words (probe f1 e)", () => { + assert.deepEqual(linesOfRead("I never said that. <sigh> Press <1> to call <b>a</b> <c>"), [{ text: "I never said that. Press <1> to call <b>a</b> <c>" }]); + assert.deepEqual(linesOfRead("<laugh> ok <gasp>"), [{ text: "ok" }]); +}); + +const CHARS = { format: "umtool-project-characters", version: 1, characters: [ + { id: "tq", name: "Jeremy", handles: ["thequartering"], synthetic: { voice: "kokoro:am_michael" }, recorded: { convert: { engine: "openvoice", voice: "kokoro:am_michael" } } }, + { id: "other", name: "Other", handles: ["someoneelse"], synthetic: { voice: "kokoro:af_sky" }, recorded: { convert: { engine: "openvoice", voice: "kokoro:af_sky" } } }, +] }; +const stubOps = (heard = null) => async (route, body) => { + if (route === "/api/ops/transcribe") { + await writeFile(body.out, JSON.stringify({ words: String(heard ?? "").split(/\s+/).filter(Boolean).map((w, i) => ({ w, start: i * 0.3, end: i * 0.3 + 0.25 })) })); + return { jobId: "t", result: {} }; + } + await tone(body.out, VOICE_B, 1); + return { jobId: "j", result: route.endsWith("voice-convert") ? { op: "convert", engine: "openvoice", voice: String(body.voice ?? "").split(":").pop() } : { op: "enhance", engine: "deepfilternet" } }; +}; + +test("f: record --as only names the line's speaker's character -- another character or the narrator is refused (probe a1)", async () => { + const p = await project("f-as", plainItem()); + await writeFile(path.join(p.dir, "narration", "characters.json"), JSON.stringify(CHARS)); + await mkdir(path.join(p.dir, ".umtool"), { recursive: true }); + await writeFile(path.join(p.dir, ".umtool", "cast.json"), JSON.stringify({ format: "umtool-cast", version: 1, characters: [{ id: "me", name: "Me", handles: ["operator"], voice: "kokoro:bm_george", convert: { engine: "openvoice" }, narrator: true }] })); + const f = path.join(ROOT, "f.wav"); + await tone(f); + await assert.rejects(() => recordScreenLine(p, "p-2117", "screen:s1:0", f, { as: "other", ask: stubOps() }), /not the character of line 0's speaker \(that is tq\)/); + await assert.rejects(() => recordScreenLine(p, "p-2117", "screen:s1:0", f, { as: "me", ask: stubOps() }), /the narrator is never a screen line's voice/); + const ok = await recordScreenLine(p, "p-2117", "screen:s1:0", f, { as: "tq", ask: stubOps(), clean: false }); + assert.match(ok.disclosure, /am_michael/); +}); + +test("j: an unheard line take is said to be one -- the record's note, the lint per chosen take; a heard one records what it was heard saying, against which words", async () => { + const p = await project("j-heard", plainItem()); + await writeFile(path.join(p.dir, "narration", "characters.json"), JSON.stringify(CHARS)); + const f = path.join(ROOT, "j.wav"); + await tone(f); + const r = await recordScreenLine(p, "p-2117", "screen:s1:2", f, { ask: stubOps(), clean: false, convert: false }); + assert.ok(r.notes.some((x) => /not heard: nothing checked what the recording says/.test(x))); + const h = await recordScreenLine(p, "p-2117", "screen:s1:2", f, { ask: stubOps("You can't be this dumb"), clean: false, convert: false, checkWords: true }); + assert.equal(h.heard, true); + const m = JSON.parse(await readFile(path.join(p.dir, "video.manifest.json"), "utf8")); + const e = m.timeline[0]; + const [unheard, heard] = e.narration.takes.slice(1); + assert.equal(unheard.screenLine.heard, undefined); + assert.deepEqual([heard.screenLine.heard.against, heard.screenLine.heard.words], ["You can't be this dumb", "You can't be this dumb"]); + const chose = (id) => ({ ...e, screens: [{ ...e.screens[0], lineTakes: { 2: id } }] }); + assert.ok(lineTakeWarnings(chose("take-2.recorded-operator")).some((x) => /line take 2 of screen s1 line 2 was not heard -- nothing verified what the recording says/.test(x))); + assert.ok(!lineTakeWarnings(chose("take-3.recorded-operator")).some((x) => /was not heard/.test(x))); +}); diff --git a/umtool/lib/report/postScreensRound2.test.mjs b/umtool/lib/report/postScreensRound2.test.mjs @@ -255,7 +255,7 @@ test("a line take is read ONLY when chosen: the screen's lineTakes (set <id> tak // Chosen by number; another line's take refused; off unchooses. r = await posts(["screen", "choose", "p-2117", "set", "s1", "take.0=4"]); assert.equal(r.code, 2); - assert.match(r.text, /take 4 is not a recording of line 0 of screen s1 \(it is of line 2 of screen s1\)/); + assert.match(r.text, /take 4 does not say line 0 of screen s1 as it is now \(it was recorded for line 2/); r = await posts(["screen", "choose", "p-2117", "set", "s1", "take.2=4"]); assert.equal(r.code, 0, r.text); e = (await read(p)).timeline[0]; @@ -268,24 +268,25 @@ test("a line take is read ONLY when chosen: the screen's lineTakes (set <id> tak assert.ok(!tts.some((b) => /dumb/.test(b.text)), "the chosen line is not synthesized"); const after1 = (await read(p)).timeline[0]; assert.deepEqual(threadReadErrors(after1, {}), []); - assert.deepEqual(lineTakeWarnings(after1), []); + assert.deepEqual(lineTakeWarnings(after1).filter((x) => !/was not heard/.test(x)), [], "only that nothing heard it"); // The disclosure names the converted recording (and the synthetic voices of the rest). assert.match(postNarrationDisclosure(after1), /a recorded reading converted to a stock voice \(openvoice · kokoro:am_michael\)/); // A line take is never his words, and never another line's. assert.throws(() => postTakeOf(after1, 4), /a recording of line 2 of screen s1: it is read in that line's place/); - assert.throws(() => postTakeOf(after1, 4, { line: "screen:s1:0" }), /not of screen:s1:0/); - await assert.rejects(() => threadTake(p, after1, { red: NO_RED, ask: stubTts([]), lanes: null, postTake: 1, lineTakes: { "screen:s1:0": 4 }, force: true }), /not of screen:s1:0/); + assert.throws(() => postTakeOf(after1, 4, { line: "screen:s9:0" }), /a recording of a line of screen s1, not of screen:s9:0/); + // Another line's words: refused by its content (owned by what it says, not by its index). + await assert.rejects(() => threadTake(p, after1, { red: NO_RED, ask: stubTts([]), lanes: null, postTake: 1, lineTakes: { "screen:s1:0": 4 }, force: true }), /does not say line 0 of screen s1 as it is now/); // The line edited since it was recorded: the chosen take is refused, never played under new words (R1 #1). r = await posts(["screen", "choose", "p-2117", "set", "s1", "line.2.text=You cannot be this dumb"]); assert.equal(r.code, 0, r.text); const edited = (await read(p)).timeline[0]; assert.ok(lineTakeWarnings(edited).some((x) => /its chosen take \(take 4\) was recorded for the line as it was/.test(x))); - await assert.rejects(() => threadTake(p, edited, { red: NO_RED, ask: stubTts([]), lanes: null, postTake: 1, force: true }), /recorded for line 2 of screen s1 as it was/); + await assert.rejects(() => threadTake(p, edited, { red: NO_RED, ask: stubTts([]), lanes: null, postTake: 1, force: true }), /does not say line 2 of screen s1 as it is now/); // Given to another speaker since: the same. r = await posts(["screen", "choose", "p-2117", "set", "s1", "line.2.text=You can't be this dumb", "line.2.who=Stranger"]); assert.equal(r.code, 0, r.text); const given = (await read(p)).timeline[0]; - await assert.rejects(() => threadTake(p, given, { red: NO_RED, ask: stubTts([]), lanes: null, postTake: 1, force: true }), /recorded for line 2 of screen s1 as it was/); + await assert.rejects(() => threadTake(p, given, { red: NO_RED, ask: stubTts([]), lanes: null, postTake: 1, force: true }), /does not say line 2 of screen s1 as it is now/); r = await posts(["screen", "choose", "p-2117", "set", "s1", "take.2=off"]); assert.equal(r.code, 0, r.text); assert.equal((await read(p)).timeline[0].screens[0].lineTakes, undefined); @@ -299,13 +300,19 @@ test("a line take is read ONLY when chosen: the screen's lineTakes (set <id> tak assert.equal((await read(q)).timeline[0].narration.takes.length, 2, "nothing moved"); }); -test("the data: lineTakes names a recording of that line; a line removed takes its choice with it, the later ones' keys move down", async () => { +test("the data: lineTakes names a recording of a line of that screen; a line removed takes its choice with it, the later ones' keys move down -- and the choice still plays (owned by content, l1 #1b)", async () => { const { withoutLines, validateScreens } = await import("umtool-report-to-video/post-screens"); - const rec = (n, file) => ({ file, engine: "recorded", voice: "operator", seconds: 1, script: "x", screenLine: { screen: "s1", n, said: "x", speaker: "TheQuartering" } }); - const e = { ...SAVVY, narration: { ...SAVVY.narration, takes: [OWN, rec(2, "narration/posts/2117/take-2.recorded-operator.wav"), rec(4, "narration/posts/2117/take-3.recorded-operator.wav")] } }; + const { lineTakesOf } = await import("umtool-report-to-video/post-thread"); + const rec = (n, file, screen = "s1") => ({ file, engine: "recorded", voice: "operator", seconds: 1, script: "x", screenLine: { screen, n, said: n === 2 ? "You can't be this dumb" : "ask Kid A about it", speaker: "TheQuartering" } }); + const e = { ...SAVVY, narration: { ...SAVVY.narration, takes: [OWN, rec(2, "narration/posts/2117/take-2.recorded-operator.wav"), rec(4, "narration/posts/2117/take-3.recorded-operator.wav"), rec(0, "narration/posts/2117/take-4.recorded-operator.wav", "s9")] } }; const sc = { ...DM, lineTakes: { 2: "take-2.recorded-operator", 4: "take-3.recorded-operator" } }; assert.deepEqual(validateScreens({ ...e, screens: [sc] }), []); - assert.ok(validateScreens({ ...e, screens: [{ ...DM, lineTakes: { 0: "take-2.recorded-operator" } }] }).some((x) => /take 2 is not a recording of line 0 of screen s1 \(it is of line 2/.test(x))); + assert.ok(validateScreens({ ...e, screens: [{ ...DM, lineTakes: { 0: "take-4.recorded-operator" } }] }).some((x) => /take 4 is not a recording of a line of screen s1 \(it is of screen s9\)/.test(x))); + // Line 0 removed above line 2's chosen take: the choice moves to key 1 and the take still says that line (current). + const moved = { ...e, screens: [withoutLines(sc, [0])] }; + assert.deepEqual(validateScreens(moved), []); + const L = lineTakesOf(moved).find((x) => x.role === "screen:s1:1"); + assert.deepEqual(L.takes.map((t) => [t.n, t.current, t.chosen]), [[2, true, true]]); assert.ok(validateScreens({ ...e, screens: [{ ...DM, lineTakes: { 2: "take-9.nope" } }] }).some((x) => /must be the id of one of the item's takes/.test(x))); assert.ok(validateScreens({ ...e, screens: [{ ...DM, lineTakes: { 7: "take-2.recorded-operator" } }] }).some((x) => /has no line 7/.test(x))); assert.deepEqual(withoutLines(sc, [2]).lineTakes, { 3: "take-3.recorded-operator" }); diff --git a/umtool/lib/report/postThreadRead.mjs b/umtool/lib/report/postThreadRead.mjs @@ -243,7 +243,7 @@ export function threadReadPlan(manifest, e, { red = null, map = {}, cast = {}, i const sl = lt?.take?.screenLine; if (sl && typeof sl === "object" && (str(sl.said).replace(/\s+/g, " ").trim() !== norm(written) || str(sl.speaker).trim().toLowerCase() !== str(p.who).trim().toLowerCase())) { const sp = /^screen:([a-z0-9-]+):(\d+)$/.exec(p.role); - throw new ThreadReadError(`--line-take ${p.role}=${lt.n}: that take was recorded for line ${sp[2]} of screen ${sp[1]} as it was (its words or its speaker changed since) -- record the line again (umtool posts screen <p> ${e.id} record ${sp[1]} ${sp[2]} --recording <file>), or unchoose it (set ${sp[1]} take.${sp[2]}=off)`); + throw new ThreadReadError(`--line-take ${p.role}=${lt.n}: that take does not say line ${sp[2]} of screen ${sp[1]} as it is now (it was recorded for line ${sl.n} as it was: other words or another speaker) -- record the line again (umtool posts screen <p> ${e.id} record ${sp[1]} ${sp[2]} --recording <file>), or unchoose it (set ${sp[1]} take.${sp[2]}=off)`); } if (lt) { // THE LINE FROM A TAKE (--line-take): that take's file is the line's piece, and its words are what the TAKE says @@ -388,7 +388,8 @@ export function postTakeOf(e, n, { line = null } = {}) { // A RECORDING OF A SCREEN LINE (`screenLine`) is that line's alone: never his words, never another line. const sl = t.screenLine && typeof t.screenLine === "object" ? t.screenLine : null; if (sl && line === null) throw new ThreadReadError(`--post-take ${k} is a recording of line ${sl.n} of screen ${sl.screen}: it is read in that line's place (--line-take screen:${sl.screen}:${sl.n}=${k}), never as his words`); - if (sl && line !== null && line !== `screen:${sl.screen}:${sl.n}`) throw new ThreadReadError(`--post-take ${k} is a recording of line ${sl.n} of screen ${sl.screen}, not of ${line}`); + // Owned by its CONTENT (its screen, words and speaker -- threadReadPlan holds it to the line as it is), not its index. + if (sl && line !== null && parseScreenRole(line)?.id !== sl.screen) throw new ThreadReadError(`--post-take ${k} is a recording of a line of screen ${sl.screen}, not of ${line}`); return { n: k, take: t }; } diff --git a/umtool/lib/report/recordPreview.mjs b/umtool/lib/report/recordPreview.mjs @@ -33,7 +33,7 @@ import { convertAskOf, stepPitchOf } from "./derivePitch.mjs"; import { withEditNotes } from "./edit-guard.mjs"; import { manifestToken, updatePostNarration } from "./manifest.mjs"; import { NarrateError, findPostItem, measureTake } from "./postNarrationCli.mjs"; -import { RECORD_LABEL_RE, decodePart, explicitSpan, joinRecording, partsIn, roomOf, targetLufsOf, trimSpan } from "./postRecord.mjs"; +import { RECORD_LABEL_RE, claimRecordedTake, claimTakeName, decodePart, explicitSpan, joinRecording, partsIn, roomOf, targetLufsOf, trimSpan } from "./postRecord.mjs"; const execFileP = promisify(execFile); const FFMPEG = () => process.env.FFMPEG_BIN ?? "ffmpeg"; @@ -389,7 +389,8 @@ export async function keepPreview(project, entry, { label = "operator", script = const partsRel = rel.replace(/\.wav$/, ".parts"); const from = path.join(dir, made.file.replace(/\.wav$/, ".parts")); if (await stat(from).catch(() => null)) { - await rm(abs(partsRel), { recursive: true, force: true }); + // A parts folder already at that name is another take's: never removed (the claim makes one unlikely; refused). + if (await stat(abs(partsRel)).catch(() => null)) throw Object.assign(new NarrateError(`${partsRel} is there already (another take's parts): nothing of it is touched -- keep it again`), { status: 409 }); await rename(from, abs(partsRel)); } return partsRel; @@ -401,8 +402,11 @@ export async function keepPreview(project, entry, { label = "operator", script = const text = String(script ?? entry.narration?.script ?? ""); const who = doc.character; - // The original. - const rel = `${takesDirOf(pid)}/take-${n}.recorded-${label}.wav`; + // The original -- its name CLAIMED (postRecord.mjs claimRecordedTake): never a recording already there, nor one kept + // at the same moment; each derived one's too (claimTakeName). + const claim = await claimRecordedTake(project.dir, entry, label); + n = claim.n; + const rel = claim.rel; const partsRel = await move(doc.built.raw, rel); const parts = multi ? partsIn(doc.built.raw.parts, partsRel) : null; const recorded = { @@ -419,8 +423,9 @@ export async function keepPreview(project, entry, { label = "operator", script = // The cleaned one. if (doc.built.clean) { - n += 1; - const r2 = derivedFileOf(pid, n, "enhance", "default"); + const c2 = await claimTakeName(project.dir, (k) => derivedFileOf(pid, k, "enhance", "default"), n + 1); + n = c2.n; + const r2 = c2.rel; const p2 = await move(doc.built.clean, r2); const take = derived(r2, doc.built.clean, { op: "enhance", ...(doc.clean?.engine ? { engine: doc.clean.engine } : {}), ranAt: doc.clean?.ranAt ?? at(), ...(doc.clean?.job ? { job: doc.clean.job } : {}) }, label, p2, doc.clean?.job); result = await write({ addTake: take }); @@ -429,9 +434,10 @@ export async function keepPreview(project, entry, { label = "operator", script = } // The converted one -- when it is of these marks (a mark moved after the Filter leaves it behind). if (doc.convert && doc.convert.built === doc.built.key && (await stat(path.join(dir, doc.convert.file)).catch(() => null))?.isFile()) { - n += 1; const c = doc.convert; - const r3 = derivedFileOf(pid, n, "convert", c.asked?.engine ?? c.asked?.voice ?? "default"); + const c3 = await claimTakeName(project.dir, (k) => derivedFileOf(pid, k, "convert", c.asked?.engine ?? c.asked?.voice ?? "default"), n + 1); + n = c3.n; + const r3 = c3.rel; const p3 = await move(c, r3); const pitched = c.pitch ? { pitch: c.pitch, ...(typeof c.semitones === "number" ? { semitones: c.semitones } : {}) } : {}; const take = derived(r3, c, { op: "convert", ...(c.engine ? { engine: c.engine } : {}), voice: c.voice, ...pitched, ranAt: c.ranAt ?? at(), ...(c.job ? { job: c.job } : {}) }, String(c.voice).split(":").pop(), p3, c.job); diff --git a/umtool/lib/report/screenLineRecord.mjs b/umtool/lib/report/screenLineRecord.mjs @@ -4,7 +4,7 @@ // read (never picked): a line take is read in its line's place by the item's thread read only once the operator // CHOOSES it (`--line-take`, the screen's `lineTakes`: the bench's per-line select, `posts screen … set <id> take.<n>=`). // -// umtool posts screen <p> <item> record <id> <n> --recording <file> [--as <character>] [--no-clean|--clean] +// umtool posts screen <p> <item> record <id> <n> --recording <file> [--as <the speaker's character>] [--no-clean|--clean] // [--no-trim|--trim] [--no-convert] [--pitch …] [--semitones n] [--label l] [--check-words [--worker w]] // // WHAT IS READ: the line as the read says it (screenLineSaid: its read run, its shapes left out; draftScript; the @@ -82,25 +82,66 @@ export function lineCharacterOf(layers, e, target) { return projectCharactersOf(layers.project).find((c) => (c.handles ?? []).map(handleKey).includes(h)) ?? characterOf(layers.cast, h) ?? null; } +/** A digit said as a word (ASR writes numbers both ways). */ +const DIGIT_WORDS = new Set(["zero", "oh", "o", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "double", "triple"]); + /** - * WHAT A RECORDING IS HEARD SAYING AMISS, pure (--check-words): `{ refused: string | null, warning: string | null }` -- - * refused when the words heard hold a shape, an @handle, an anonymous handle (`handles`) or a redacted term (`terms`); - * a warning when they are not the line's in order (postThreadRead.mjs lineTakeProblem's "other words": ASR slack is - * the person's to judge). Names what, never the words. + * WHAT A RECORDING IS HEARD SAYING AMISS, pure (--check-words): `{ refused: string | null, warning: string | null }`. + * REFUSED when the words heard hold a shape (an e-mail, a number: post-screens.mjs shapeSpans), a number SAID IN WORDS + * (seven digits or more, as words or digits in a row: "five five five two oh one…"), an @handle, an anonymous author's + * handle (`handles`; bare, possessive "secretkid's", or spaced "secret kid") or display name (`names`, the same forms), + * or a redacted term (`terms`); a warning when its words are not the line's in order (postThreadRead.mjs + * lineTakeProblem's "other words": ASR slack is the person's to judge). Names what, never the words. */ -export function heardProblem(heard, script, { handles = [], terms = [], lineTakeProblem }) { +export function heardProblem(heard, script, { handles = [], names = [], terms = [], lineTakeProblem }) { const h = str(heard); if (shapeSpans(h).length) return { refused: "it is heard saying an e-mail address or a number the card masks", warning: null }; - const words = h.toLowerCase().split(/\s+/).map((w) => w.replace(/^[^\p{L}\p{N}@]+|[^\p{L}\p{N}]+$/gu, "")).filter(Boolean); - if (words.some((w) => w.startsWith("@"))) return { refused: "it is heard saying an @handle", warning: null }; - const banned = new Set(handles.map((x) => String(x).replace(/^@+/, "").toLowerCase())); - if (words.some((w) => banned.has(w))) return { refused: "it is heard saying an anonymous author's handle", warning: null }; + const raw = h.toLowerCase().replace(/[’‘]/g, "'").split(/\s+/).filter(Boolean); + if (raw.some((w) => /^[^\p{L}\p{N}]*@/u.test(w))) return { refused: "it is heard saying an @handle", warning: null }; + // Each word bare: its edge punctuation and a possessive dropped. + const words = raw.map((w) => w.replace(/^[^\p{L}\p{N}]+|[^\p{L}\p{N}']+$/gu, "").replace(/'s$|'$/u, "").replace(/[^\p{L}\p{N}]/gu, "")).filter(Boolean); + // A number said in words (or in digits a word at a time). + let run = 0; + for (const w of words) { + if (DIGIT_WORDS.has(w)) run += w === "double" ? 1 : w === "triple" ? 2 : 1; + else if (/^\d+$/.test(w)) run += w.length; + else run = 0; + if (run >= 7) return { refused: "it is heard saying a number in words (a number the card masks)", warning: null }; + } + // A handle or a name: a word, or two or three words run together ("secret kid"), or the name's words in a row. + const joined = (i, k) => words.slice(i, i + k).join(""); + const says = (target) => { + const t = String(target).toLowerCase().replace(/^@+/, ""); + const flat = t.replace(/[^\p{L}\p{N}]/gu, ""); + if (!flat) return false; + const tw = t.split(/[^\p{L}\p{N}]+/u).filter(Boolean); + for (let i = 0; i < words.length; i += 1) { + for (let k = 1; k <= 3 && i + k <= words.length; k += 1) if (joined(i, k) === flat) return true; + if (tw.length > 1 && tw.every((x, j) => words[i + j] === x)) return true; + } + return false; + }; + if (handles.some(says)) return { refused: "it is heard saying an anonymous author's handle", warning: null }; + if (names.filter((n) => str(n).trim().length >= 3).some(says)) return { refused: "it is heard saying an anonymous author's name", warning: null }; const esc = (t) => String(t).replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); if (terms.some((t) => new RegExp(`(?<![\\p{L}\\p{N}])${esc(t)}(?![\\p{L}\\p{N}])`, "iu").test(h))) return { refused: "it is heard saying a redacted term", warning: null }; const why = lineTakeProblem(h, script, { handles, terms }); return { refused: null, warning: why ? "its words as heard are not the line's in order (the transcription may have misheard: listen to it)" : null }; } +/** The anonymous authors' DISPLAY NAMES this video knows (their characters' names, the posts by their handles). */ +export function anonymousNamesOf(manifest, projectDoc, handles) { + const hs = new Set(handles.map((x) => String(x).replace(/^@+/, "").toLowerCase())); + const out = new Set(); + for (const c of Array.isArray(projectDoc?.characters) ? projectDoc.characters : []) if (c?.anonymous === true && str(c.name).trim()) out.add(str(c.name).trim()); + for (const e of Array.isArray(manifest?.timeline) ? manifest.timeline : []) { + for (const w of [e, ...(Array.isArray(e?.parents) ? e.parents : []), e?.quoted].filter((x) => x && typeof x === "object")) { + if (hs.has(str(w.handle).replace(/^@+/, "").toLowerCase()) && str(w.author).trim()) out.add(str(w.author).trim()); + } + } + return [...out]; +} + /** * RECORD ONE SCREEN LINE of post item `id` (see the head): `file` a sound file; the takes made (`{ takes: [{ step, file * }], picked: null, notes, disclosure, character, line: { role, prompt } }`). Refused (LineRecordError) on an item with @@ -120,12 +161,17 @@ export async function recordScreenLine(project, id, role, file, opts = {}) { const layers = await readLayers(project.dir); const { characterNames, lineTakeProblem } = await import("./postThreadRead.mjs"); const target = lineToRecord(e, role, { red, names: characterNames(layers) }); - let character; + // A line converts ONLY to its SPEAKER's character (operator, 13 Nov): --as may name that one, never another, never + // the narrator. + const character = lineCharacterOf(layers, e, target); if (as) { - character = layers.characterForRead(e, as)?.character ?? null; - if (!character) throw new LineRecordError(`--as ${as}: no such character in this video's characters or the cast (umtool cast project ${project.id}, umtool cast ls)`); - } else character = lineCharacterOf(layers, e, target); + const named = layers.characterForRead(e, as)?.character ?? null; + if (!named) throw new LineRecordError(`--as ${as}: no such character in this video's characters or the cast (umtool cast project ${project.id}, umtool cast ls)`); + if (named.narrator === true) throw new LineRecordError(`--as ${as}: the narrator is never a screen line's voice -- a line converts only to its speaker's character`); + if (!character || named.id !== character.id) throw new LineRecordError(`--as ${as}: not the character of line ${target.n}'s speaker${character ? ` (that is ${character.id})` : " (the speaker has none: the line is kept as recorded)"} -- a line converts only to its speaker's character`); + } const notes = []; + let heardRec = null; if (checkWords) { // Heard BEFORE anything is kept: a refusal keeps nothing. const { decodePart } = await import("./postRecord.mjs"); @@ -143,10 +189,12 @@ export async function recordScreenLine(project, id, role, file, opts = {}) { const heard = Array.isArray(doc?.words) && doc.words.length ? doc.words.map((w) => str(w?.w)).join(" ") : str(doc?.text); if (!heard.trim()) throw new LineRecordError(`--check-words: the editor heard no words in the recording of ${role} -- nothing kept`); const anonHandles = red?.anon instanceof Map ? [...red.anon.keys()] : Object.keys(red?.anon ?? {}).filter((x) => x !== "postIds"); - const p = heardProblem(heard, target.script, { handles: anonHandles, terms: termsFor(e, red).map((x) => x.term), lineTakeProblem }); + const p = heardProblem(heard, target.script, { handles: anonHandles, names: anonymousNamesOf(manifest, layers.project, anonHandles), terms: termsFor(e, red).map((x) => x.term), lineTakeProblem }); if (p.refused) throw new LineRecordError(`--check-words: the recording of ${role} is refused -- ${p.refused}; nothing kept: record the line again`); if (p.warning) notes.push(`--check-words: ${p.warning}`); else notes.push("--check-words: heard saying the line"); + // What it was heard saying, against which words: kept with the take (an unheard one says it was not). + heardRec = { at: new Date().toISOString(), against: target.script, words: heard.replace(/\s+/g, " ").trim().slice(0, 2000) }; } finally { await rm(tmp, { recursive: true, force: true }); } @@ -154,7 +202,8 @@ export async function recordScreenLine(project, id, role, file, opts = {}) { const { importRecording } = await import("./postNarrationCli.mjs"); const r = await importRecording(project, e, file, { label, clean, trim, convert, pitch, semitones, note, emit, editor, ask, character, - screenLine: { screen: target.screen, n: target.n, said: target.written, speaker: target.speaker }, script: target.script, + screenLine: { screen: target.screen, n: target.n, said: target.written, speaker: target.speaker, ...(heardRec ? { heard: heardRec } : {}) }, script: target.script, }); - return { ...r, notes: [...notes, ...r.notes], line: { role, prompt: target.prompt, speaker: target.speaker } }; + if (!heardRec) notes.push("not heard: nothing checked what the recording says -- the read takes it as the line's words (--check-words hears it)"); + return { ...r, notes: [...notes, ...r.notes], line: { role, prompt: target.prompt, speaker: target.speaker }, heard: !!heardRec }; } diff --git a/umtool/report-to-video/post-narration.mjs b/umtool/report-to-video/post-narration.mjs @@ -662,8 +662,10 @@ export function validatePostNarration(e) { // recorded for -- its screen, its index, its words as a read writes them, its speaker. Never the item's read. if (t.screenLine !== undefined) { const sl = t.screenLine; - if (!(isObj(sl) && typeof sl.screen === "string" && /^[a-z0-9][a-z0-9-]{0,23}$/.test(sl.screen) && Number.isInteger(sl.n) && sl.n >= 0 && sl.n < 60 && typeof sl.said === "string" && sl.said.length <= 2000 && typeof sl.speaker === "string" && sl.speaker.length <= 64 && Object.keys(sl).every((kk) => ["screen", "n", "said", "speaker"].includes(kk)))) { - errors.push(`${tw}.screenLine must be { screen, n, said, speaker } (the screen line it is a recording of)`); + // `heard` (--check-words): what the editor's transcription heard it say, against which words, when. + const heardOk = sl?.heard === undefined || (isObj(sl.heard) && typeof sl.heard.at === "string" && typeof sl.heard.against === "string" && sl.heard.against.length <= 2000 && typeof sl.heard.words === "string" && sl.heard.words.length <= 2000 && Object.keys(sl.heard).every((kk) => ["at", "against", "words"].includes(kk))); + if (!(isObj(sl) && typeof sl.screen === "string" && /^[a-z0-9][a-z0-9-]{0,23}$/.test(sl.screen) && Number.isInteger(sl.n) && sl.n >= 0 && sl.n < 60 && typeof sl.said === "string" && sl.said.length <= 2000 && typeof sl.speaker === "string" && sl.speaker.length <= 64 && heardOk && Object.keys(sl).every((kk) => ["screen", "n", "said", "speaker", "heard"].includes(kk)))) { + errors.push(`${tw}.screenLine must be { screen, n, said, speaker, heard? } (the screen line it is a recording of)`); } } if (t.words !== undefined) { diff --git a/umtool/report-to-video/post-screens.mjs b/umtool/report-to-video/post-screens.mjs @@ -413,8 +413,8 @@ export function lineOfText(raw) { return { ...(out.who ? { who: out.who } : {}), ...(out.side ? { side: out.side } : {}), text: t.trim(), ...(out.time ? { time: out.time } : {}), ...(out.redact ? { redact: true } : {}) }; } -/** An Orpheus emotion tag in a script ("<sigh>", "<laugh>"): how it is read, never the picture's words. */ -const SCRIPT_TAG_RE = /<\s*[a-z]+\s*>/gi; +/** Orpheus's expressive tags (the editor's TTS_EXPRESSIVE_TAGS): how a script is read, never the picture's words. Any other `<…>` is words. */ +const SCRIPT_TAG_RE = /<(?:laugh|chuckle|sigh|cough|sniffle|groan|yawn|gasp)>/g; /** * A PICTURE-ONLY post's READ as a screen's LINES, pure (`posts screen … add --from-read`, the post bench's "From its @@ -554,7 +554,9 @@ export function validateScreens(e) { else if (lines[n].redact === true) errors.push(`${at}.lineTakes.${k}: line ${k} is redacted -- it is never read`); const t = typeof v === "string" ? takes.find((x) => takeIdOfFile(x) === v) : null; if (!t) errors.push(`${at}.lineTakes.${k} must be the id of one of the item's takes (a recording of line ${k})`); - else if (!isObj(t.screenLine) || t.screenLine.screen !== sc.id || t.screenLine.n !== n) errors.push(`${at}.lineTakes.${k}: take ${takes.indexOf(t) + 1} is not a recording of line ${k} of screen ${sc.id}${isObj(t.screenLine) ? ` (it is of line ${t.screenLine.n} of screen ${t.screenLine.screen})` : ""}`); + // A recording of a line of THIS screen; whether it says this line as it is now is the read's to judge (by its + // words and speaker, not its index: a line removed above it moves the choice, not the take). + else if (!isObj(t.screenLine) || t.screenLine.screen !== sc.id) errors.push(`${at}.lineTakes.${k}: take ${takes.indexOf(t) + 1} is not a recording of a line of screen ${sc.id}${isObj(t.screenLine) ? ` (it is of screen ${t.screenLine.screen})` : ""}`); } } const r = sc.read; diff --git a/umtool/report-to-video/post-thread.mjs b/umtool/report-to-video/post-thread.mjs @@ -711,35 +711,55 @@ export const screenLineWritten = (screen, n) => draftScript(screenLineSaid(scree const idOfTake = (t) => str(t?.file).split("/").pop().replace(/\.wav$/i, ""); /** - * Whether a line take (`screenLine`) was recorded for the line AS IT IS NOW: its words as a read writes them and its - * speaker. A take that is no recording of a line: null (nothing to judge). + * Whether a line take (`screenLine`) SAYS line `n` of screen `screenId` AS IT IS NOW -- by its content, not its index: + * the same screen, the line's words as a read writes them, its speaker. (Without `screenId`/`n`: the line it was recorded + * for, by its index.) A take that is no recording of a line: null. */ -export function lineTakeCurrent(entry, take) { +export function lineTakeCurrent(entry, take, screenId = undefined, n = undefined) { const sl = take?.screenLine; if (!sl || typeof sl !== "object") return null; - const sc = screensOfEntry(entry).find((x) => x.id === sl.screen); - if (!sc || !sc.lines[sl.n] || sc.lines[sl.n].redact === true) return false; - return normText(sl.said) === normText(screenLineWritten(sc, sl.n)) && normText(sl.speaker).toLowerCase() === normText(sc.lines[sl.n]?.who).toLowerCase(); + const sid = screenId ?? sl.screen; + const k = n ?? sl.n; + if (sl.screen !== sid) return false; + const sc = screensOfEntry(entry).find((x) => x.id === sid); + if (!sc || !sc.lines[k] || sc.lines[k].redact === true) return false; + return normText(sl.said) === normText(screenLineWritten(sc, k)) && normText(sl.speaker).toLowerCase() === normText(sc.lines[k]?.who).toLowerCase(); } /** - * Each screen line's RECORDINGS, pure: `[{ role, screen, n, takes: [{ n, id, take, current, chosen }] }]` -- the item's - * takes that are recordings of a line (`screenLine`), by line, each with its number (as --list counts), whether it was - * recorded for the line as it is now, and whether the screen's `lineTakes` chose it. Lines with none are left out. + * Each screen line's RECORDINGS, pure, BY CONTENT: `[{ role, screen, n, takes: [{ n, id, take, current, chosen }] }]` -- + * for each line, the item's takes that are recordings of a line of its screen (`screenLine`) and say that line as it is + * now (`current`), or that the screen chose for it (`chosen`, current or not); a recording that says no line now is + * listed under the line it was recorded for, not current. Lines with none are left out. */ export function lineTakesOf(entry) { const takes = Array.isArray(entry?.narration?.takes) ? entry.narration.takes : []; - const by = new Map(); - takes.forEach((t, i) => { - const sl = t?.screenLine; - if (!sl || typeof sl !== "object") return; + const recs = takes.map((t, i) => ({ t, i })).filter(({ t }) => t?.screenLine && typeof t.screenLine === "object"); + if (!recs.length) return []; + const out = []; + const placed = new Set(); + for (const sc of screensOfEntry(entry)) { + sc.lines.forEach((_, k) => { + const chosenId = sc.lineTakes && typeof sc.lineTakes === "object" ? sc.lineTakes[String(k)] : undefined; + const mine = recs.filter(({ t }) => t.screenLine.screen === sc.id && (idOfTake(t) === chosenId || lineTakeCurrent(entry, t, sc.id, k) === true)); + if (!mine.length) return; + for (const { i } of mine) placed.add(i); + out.push({ role: screenRole(sc.id, k), screen: sc.id, n: k, takes: mine.map(({ t, i }) => ({ n: i + 1, id: idOfTake(t), take: t, current: lineTakeCurrent(entry, t, sc.id, k) === true, chosen: idOfTake(t) === chosenId })) }); + }); + } + // Recordings that say no line now (the line edited, the screen gone): under the line they were recorded for. + for (const { t, i } of recs) { + if (placed.has(i)) continue; + const sl = t.screenLine; const role = screenRole(sl.screen, sl.n); - const sc = screensOfEntry(entry).find((x) => x.id === sl.screen); - const chosen = !!sc && sc.lineTakes?.[String(sl.n)] === idOfTake(t); - if (!by.has(role)) by.set(role, { role, screen: sl.screen, n: sl.n, takes: [] }); - by.get(role).takes.push({ n: i + 1, id: idOfTake(t), take: t, current: lineTakeCurrent(entry, t) === true, chosen }); - }); - return [...by.values()]; + let row = out.find((x) => x.role === role); + if (!row) { + row = { role, screen: sl.screen, n: sl.n, takes: [] }; + out.push(row); + } + row.takes.push({ n: i + 1, id: idOfTake(t), take: t, current: false, chosen: false }); + } + return out; } /** The takes the screens CHOSE for their lines, as --line-take takes them: `{ "<role>": <take number> }` (none: {}). */ @@ -774,6 +794,9 @@ export function lineTakeWarnings(entry) { else if (!chosen && L.takes.some((x) => x.current) && screenReadLines(sc).some((r) => r.n === L.n)) { out.push(`timeline ${id}: line ${L.n} of screen ${L.screen} has a recording no read uses (take ${L.takes.filter((x) => x.current).map((x) => x.n).join(", take ")}) -- choose one: umtool posts screen <p> ${id} set ${L.screen} take.${L.n}=<take> (or on the post bench), then make the read`); } + // NOT HEARD (review round 1, j): nothing verified what a recording says unless --check-words heard it -- its words + // are the line's text compared with itself. + if (chosen && !chosen.take?.screenLine?.heard) out.push(`timeline ${id}: line take ${chosen.n} of screen ${L.screen} line ${L.n} was not heard -- nothing verified what the recording says; \`umtool posts screen <p> ${id} record ${L.screen} ${L.n} --recording <file> --check-words\` hears it`); if (chosen && chosen.current && isNarrated(entry)) { const mine = parts.filter((p) => p?.role === L.role); if (mine.length && !mine.every((p) => p.take === chosen.id)) out.push(`timeline ${id}: line ${L.n} of screen ${L.screen}: the picked read does not play its chosen take (take ${chosen.n}) -- make the read: umtool posts screen <p> ${id} read`);