commit a71ec2f490c2318f398447aa5abeabefeb3ea88e
parent 294abc5e18a4cec733cbd01030b755e98df4c732
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Tue, 17 Nov 2026 09:49:21 -0500
umtool narration: a card's narration and its readings from the CLI -- read again, kept without changing the card, picked
- lib/report/cardNarrationCli.mjs: umtool narration <p> [<card>] [--list] | --read [--text] [--reading N|next]
[tuning flags] | --pick <key> | --text/--reading/--tuning-off; a pick keeps a verdict given on the same words.
- manifest.mjs updateCardNarration (text, reading, tuning; one undo point); narration-store.mjs records the tuning
a reading was asked with (askedTuning) so a pick asks its key again.
- The CLI registry and docs rows (verbs.mjs: the narration row and the posts narrate/screen flags; groups.mjs).
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat:
7 files changed, 333 insertions(+), 9 deletions(-)
diff --git a/umtool/bin/umtool.mjs b/umtool/bin/umtool.mjs
@@ -16,6 +16,7 @@
// umtool check [<project> | --all] [--take <t>] [--json] exit 1 on anything blocking (--take: the take's quote rows)
// umtool links <project> [--json] [--fix] do the clip QRs open on their sites (out/links.json)
// umtool cast [ls|add|set|rm|undo|project|audition|use|reread] … the characters' voices across projects (castCli.mjs)
+// umtool narration <project> [<card>] [--read|--pick <key>|--text …] a card's narration and its readings (cardNarrationCli.mjs)
// umtool speaker-check <project> [--clip <id> …] [--set 'Name=…'] [--list] which named voice each clip is (speaker-check.json)
// umtool quote-check <project> [--take <t>] [--clips a,b] [--status] is each clip's quote in the seconds it plays (quote-check.json; a take's: takes/<t>/)
// umtool check-joins <project> --take <id> [--json] [--all] do the post joins of a rendered take carry on, or jump
@@ -973,6 +974,8 @@ const COMMANDS = {
links: async () => process.exit(await (await import("../lib/report/linksCli.mjs")).linksCommand(argv.slice(argv.indexOf("links") + 1))),
// The cast: characters' voices across projects, auditions, a project's voices (operator, 6 Nov): lib/report/castCli.mjs.
cast: async () => process.exit(await (await import("../lib/report/castCli.mjs")).castCommand(argv.slice(argv.indexOf("cast") + 1))),
+ // A card's narration: its words, reading and tuning, its readings read again and picked (lane line-rerun): lib/report/cardNarrationCli.mjs.
+ narration: async () => process.exit(await (await import("../lib/report/cardNarrationCli.mjs")).cardNarrationCommand(argv.slice(argv.indexOf("narration") + 1))),
// Which named voice each clip is (UI notes #15): lib/report/speakerCheck.mjs.
"speaker-check": async () => process.exit(await (await import("../lib/report/speakerCheck.mjs")).speakerCheckCommand(argv.slice(argv.indexOf("speaker-check") + 1))),
// Is each clip's quote in the seconds it plays (lane one-clock): the editor transcribes, quote-check.json keeps the rows.
diff --git a/umtool/lib/cli/groups.mjs b/umtool/lib/cli/groups.mjs
@@ -280,6 +280,20 @@ export const GROUPS = [
],
},
{
+ cmd: "narration",
+ usage: [
+ " umtool narration <project> [<card>] [--list] [--json] a CARD's NARRATION (spoken only; no card draws it): its",
+ " words, reading and tuning, and its READINGS kept beside the build (out/narration/)",
+ " umtool narration <project> <card> --read [--text \"…\"] [--reading N|next] [tuning flags] one reading asked of",
+ " the editor and kept, the card NOT changed · --pick <key>: the card made that reading",
+ " umtool narration <project> <card> [--text \"…\"] [--reading N] [tuning flags | --tuning-off] set them",
+ ],
+ docs: [
+ ["`narration <project> [<card>] [--list] [--json]` · `<card> --read [--text \"…\"] [--reading N\|next] [--temperature t] [--top-p p] [--top-k k] [--min-p m] [--repeat-penalty r] [--chunk-takes n]` · `<card> --pick <key>` · `<card> [--text \"…\"] [--reading N] [tuning flags \| --tuning-off]`",
+ "a **card's narration** and its readings ([knobs.md](knobs.md#a-cards-narration-read-again), `lib/report/cardNarrationCli.mjs`): the words a stock voice says over a card (spoken only — no card draws them), its reading and Orpheus tuning; `--read` asks the editor for one reading (a job; it waits while render mode holds the machine) and keeps it in `out/narration/` without changing the card (`--reading next`: one past the highest these words were read at); `--pick <key>` makes the card play a kept reading (its words, reading and tuning; nothing synthesized) — a verdict on the same words is kept; without either, the card's words, reading and tuning are set. The narration page's Read again, Read edited text, Tune and Pick run these."],
+ ],
+ },
+ {
cmd: "present",
usage: [
" umtool present <project> [--take <id> | --cut] [--json] [--public] [--open] PRESENT MODE: the cut as slides,",
@@ -1031,12 +1045,13 @@ export const GROUPS = [
" a re-run adds only posts not already in the cut",
" umtool posts set-item <project> <item> [hold=<s>|off] [layout=sequence|grid] [redact=on|off|auto] [media.<i>.start=<s>]",
" [media.<i>.end=<s>] [media.<i>.mute=on|off] [media.<i>.crop=x,y,w,h|off] [media.<i>.push=on|off] [--json]",
- " umtool posts narrate <project> [--import | --list | <item> [--script \"…\"] [--take [--note \"…\"] [--reading n]",
- " [--temperature t] [--top-p p] [--top-k k] [--min-p m] [--repeat-penalty r] [--chunk-takes n]]",
+ " umtool posts narrate <project> [--import | --list | <item> [--script \"…\"] [--take [--note \"…\"] [--reading n|next]",
+ " [--temperature t] [--top-p p] [--top-k k] [--min-p m] [--repeat-penalty r] [--chunk-takes n] [--no-pick]]",
" [--pick n] [--approve] [k=v …]",
" | --all --draft-scripts | --all --take | --cut k=v …] a post read aloud (its takes: the editor's tts or yours)",
" umtool posts narrate <project> <item> --take --thread [--parents 0|all] [--skip-parent <id>]… [--no-quoted]",
- " [--voice-for <handle>=<voice>]… [--dry-run] [--json] a THREAD READ: its context and his words in date",
+ " [--voice-for <handle>=<voice>]… [--reading n|next [--for <role>]] [--tuned <role>=reading:n,…]… [--no-pick]",
+ " [--dry-run] [--json] a THREAD READ: its context and his words in date",
" order, each in its author's voice, parts cached, one take saved and picked (exit 0 / 1)",
" umtool posts set-item | roles | narrate | reread | fx … --in-take <take> the same edit on a TAKE of the project:",
" its manifest read as the take's, the write in takes/<take>/take.json's patch (an undo point of the take's,",
@@ -1080,13 +1095,13 @@ 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 <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 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 said.<n>=\"…\"\\|off [--from <file>]`; check: `<id> [--by <name>] [--undo]`; read: `[--post-take <n>] [--line-take screen:<id>:<line>=<n>]… [--voice-for h=v]… [--reading N\\|next] [tuning flags] [--for screen:<id>:<line>] [--tuned <role>=reading:N,…]… [--no-pick] [--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. `said.<n>=` is what the voice SAYS for line n (`saidAs`: an acronym spelled out, a typo said right) -- never drawn, never the line's identity; one that says a masked shape or a redacted line is refused. `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>…`",
+ ["`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 \"…\"] [--reading N\\|next] [--no-pick]` · `<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 -- with `--reading N` it is ANOTHER READING of the same words (0 the first; Orpheus's seeds move, a new cached file) and `--temperature` `--top-p` `--top-k` `--min-p` `--repeat-penalty` `--chunk-takes` its tuning (the editor's ranges; one item's `--take` only, not `--thread` or `--all`), and the take records every tuning value and the reading it was made with; `--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]`",
+ ["`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>]… [--reading N\\|next] [tuning flags] [--for <role>] [--tuned <role\\|*>=reading:N,…]… [--no-pick] [--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"],
["`posts say <project> [ls] [--item <id>]` · `add <word\\|phrase> \"<spoken>\" [--case] [--item <id>] [--note \"…\"]` · `remove <word\\|n> [--item <id>]` · `try \"<text>\" [--item <id>]` · `stale` `[--json]`",
"**THE PRONUNCIATION LEXICON** ([knobs.md](knobs.md#pronunciation-and-voices-the-lexicon-the-voice-map-a-thread-read)): `narration/lexicon.json` in the project, a word or phrase said differently in EVERY synthesized read (a script's `--take`, each piece of a thread read, the bench's re-take); the scripts and cards keep their words. Whole words, without case unless `--case`, a phrase across any spaces, regex characters literal; `--item` for one item's reads (it wins over the project's). A masked slur and a redacted word are never replaced. `add` of a word already listed changes what is said. `try` prints what a voice would be asked to say. `stale` lists every picked read that still says an entry the old way, with the command that re-reads it. A bad entry or an unknown item: **exit 2**"],
diff --git a/umtool/lib/cli/verbs.mjs b/umtool/lib/cli/verbs.mjs
@@ -218,6 +218,12 @@ export const VERBS = Object.freeze([
form("review-pass verdict", "project", "the draft's verdict at the pass's end: its parent's when only review fields differ, else saved as a version and judged", [
project(), pick("verdict", ["like", "maybe", "no", "clear"], { required: true }), opt("--note", { type: "text", help: "the verdict's note" }),
], { shape: "review-pass <project> verdict <verdict>" }),
+ // A card's narration and its readings (lane line-rerun, lib/report/cardNarrationCli.mjs): the narration page's twin.
+ form("narration", "draft", "a card's narration: its words, reading and tuning; a reading made, or picked", [
+ project(), arg("card", { required: false, help: "the card (none: every narrated card)" }), bool("--read", "one reading asked of the editor, the card not changed"),
+ opt("--text", { type: "text" }), opt("--reading", { help: "0-99999, or next (with --read)" }), opt("--pick", { help: "a kept reading's key" }),
+ num("--temperature"), num("--top-p"), num("--top-k"), num("--min-p"), num("--repeat-penalty"), num("--chunk-takes"), bool("--tuning-off"), bool("--list"),
+ ]),
form("present", "project", "present mode's address and slides", [project(), takeOpt({ help: "that take's cut (default the latest)" }), bool("--cut", "the manifest alone"), bool("--public", "as a public page would carry it")]),
form("set", "draft", "a clip's knobs: claim, marks, audio, blur, fx …", [project(), clip(), pairs({ help: "key=value, one per line (claim.at=190.2, audio.gain=-3, `key=` clears)" }), opt("--mark", { help: "the mark the claim.* keys set" }), takeOpt()], B(["clip"], { clip: "{id}" })),
form("intro", "draft", "the intro the cut opens on (render.intro)", [project(), pairs({ required: false, help: "key=value, one per line (style=boot-dark, seconds=4); none: print it" }), bool("--off", "take the intro off"), takeOpt({ help: "a version: --off opens it on no intro, --on on the cut's" }), bool("--on")], B(["intro"], {})),
@@ -524,10 +530,11 @@ function posts() {
p("narrate", "draft", "a post item's narration: script, takes, pick, approve, mix", [
item({ required: false, help: "the post item (none: --list, --import, --all or --cut)" }), opt("--script", { type: "text" }), bool("--take", "a new read (the editor's tts)"), opt("--note"),
opt("--voice"), opt("--engine"), num("--speed"),
- num("--reading", { help: "with --take: another reading of the same words, 0-99999 (0 = the first)" }), num("--temperature", { help: "with --take: Orpheus's tuning, 0.1-1.5" }),
+ opt("--reading", { help: "with --take: another reading of the same words, 0-99999 (0 = the first), or next" }), num("--temperature", { help: "with --take: Orpheus's tuning, 0.1-1.5" }),
num("--top-p", { help: "with --take: 0.05-1" }), num("--top-k", { help: "with --take: 0-200" }), num("--min-p", { help: "with --take: 0-0.5" }),
num("--repeat-penalty", { help: "with --take: 1-2" }), num("--chunk-takes", { help: "with --take: the tries a sentence gets, 1-6" }),
- num("--pick"), bool("--approve"), bool("--unapprove"), bool("--off"), bool("--on"),
+ num("--pick"), bool("--approve"), bool("--unapprove"), bool("--off"), bool("--on"), bool("--no-pick", "with --take: the new take joins the list unpicked"),
+ opt("--for", { help: "with --thread: the piece the reading and tuning are for (screen:<id>:<line>, post, …)" }), many("--tuned", { repeat: true, item: "role=reading:N,…", help: "with --thread: each piece's reading and tuning" }),
bool("--thread", "with --take: a thread read"), opt("--parents"), num("--post-take", { help: "with --thread: his own line is this take of the item (as --list numbers them)" }), bool("--words", "the picked take's word timings"), bool("--import"), bool("--list"), bool("--all"), bool("--draft-scripts"),
num("--limit"), bool("--force"), file("--recording", { help: "a person's recording (a file of the project) made the read" }), opt("--as"),
pick("--pitch", ["target", "source", "contour"], { help: "a convert's pitch (--recording, --derive)" }), num("--semitones", { help: "-12…12, moves a followed pitch" }), dry(),
@@ -543,6 +550,8 @@ function posts() {
many("--line", { repeat: true, item: "line", help: "add: a line `who: words`, one per line" }),
opt("--read", { help: "add: all, none or line numbers" }), pick("--unread", ["omit", "dim"]), opt("--by", { help: "check: who checked it" }), bool("--undo", "check: not checked"),
num("--post-take", { help: "read: her own line is this take of the item" }), many("--line-take", { repeat: true, item: "role=n", help: "read: screen:<id>:<line>=<take n>, one per line" }),
+ opt("--reading", { help: "read: 0-99999 or next" }), num("--temperature"), num("--top-p"), num("--top-k"), num("--min-p"), num("--repeat-penalty"), num("--chunk-takes"),
+ opt("--for", { help: "read: the piece they are for (screen:<id>:<line>)" }), bool("--no-pick", "read: the new take joins the list unpicked"),
pairs({ required: false, help: "set: kind= title= at= read= read.<n>=\"excerpt\" line.<n>.who= …, one per line" }), dry(), inTake(),
], { shape: "posts screen <project> <item> <op>", ...POST_ITEM }),
p("say", "draft", "the pronunciation lexicon", [pick("op", ["ls", "add", "remove", "try", "stale"], { required: true }), arg("word", { required: false, allowAt: true, help: "the word or phrase (try: the text)" }), arg("spoken", { required: false }), bool("--case"), opt("--item"), opt("--note")], { shape: "posts say <project> <op>" }),
diff --git a/umtool/lib/report/cardNarration.test.mjs b/umtool/lib/report/cardNarration.test.mjs
@@ -0,0 +1,93 @@
+// `umtool narration` (cardNarrationCli.mjs; lane line-rerun): a card's narration read again, kept beside the build
+// without changing the card, picked, and its verdict kept on the same words. A stub for the editor; temp dirs.
+import assert from "node:assert/strict";
+import { execFileSync } from "node:child_process";
+import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
+import { tmpdir } from "node:os";
+import path from "node:path";
+import { after, test } from "node:test";
+import { cardNarrationCommand, cardReadings, nextCardReading } from "./cardNarrationCli.mjs";
+import { keepNarration } from "umtool-report-to-video/narration-store";
+import { readNarrationReview, reviewState, setNarrationReview } from "umtool-report-to-video/narration-review";
+import { narrationsOf } from "umtool-report-to-video/narration";
+
+const ROOT = await mkdtemp(path.join(tmpdir(), "umtool-card-narration-"));
+after(() => rm(ROOT, { recursive: true, force: true }));
+const REPORTS = path.join(ROOT, "reports");
+const CARD = { type: "card", id: "c1", seconds: "auto", heading: "The crossing", narration: { text: "Six months later, the ferry ran again.", engine: "orpheus", voice: "tara" } };
+
+async function project(name) {
+ const dir = path.join(REPORTS, name);
+ await mkdir(dir, { recursive: true });
+ await writeFile(path.join(dir, "video.manifest.json"), JSON.stringify({
+ schemaVersion: 1, slug: name, title: name, provenance: { siteOrigin: "", channelSlug: "ferry-x", channelsDir: path.join(ROOT, "channels") },
+ render: { width: 1920, height: 1080, fps: 30 }, timeline: [CARD],
+ }, null, 2));
+ return { id: name, dir };
+}
+const manifest = async (p) => JSON.parse(await readFile(path.join(p.dir, "video.manifest.json"), "utf8"));
+/** The editor, stubbed: a tone kept as the editor's result would be (narration-store.mjs keepNarration). */
+const narrate = (asked) => async ({ narrations, dir }) => {
+ const recs = new Map();
+ for (const n of narrations) {
+ asked.push(n);
+ const wav = path.join(ROOT, `${n.key}.src.wav`);
+ execFileSync("ffmpeg", ["-v", "error", "-y", "-f", "lavfi", "-i", "sine=f=330:d=1.4", "-ar", "48000", "-ac", "1", wav]);
+ recs.set(n.id, await keepNarration(dir, n, { wav, engine: n.engine, voice: n.voice, reading: n.reading ?? 0, ...(n.tuning ? { tuning: n.tuning } : {}) }, { jobId: `job-${asked.length}` }));
+ }
+ return recs;
+};
+const run = async (args, asked = []) => {
+ const lines = [];
+ const code = await cardNarrationCommand(args, { root: REPORTS, out: (s) => lines.push(s), err: (s) => lines.push(s), narrate: narrate(asked) });
+ return { code, out: lines.join("\n"), json: () => JSON.parse(lines.join("\n")) };
+};
+
+test("--read keeps a reading WITHOUT changing the card; --reading next is one past the highest of these words; --pick plays it, a verdict on the same words kept", async () => {
+ const p = await project("read");
+ const asked = [];
+ let r = await run([p.id, "c1", "--read", "--json"], asked);
+ assert.equal(r.code, 0, r.out);
+ assert.equal(r.json().plays, true);
+ r = await run([p.id, "c1", "--read", "--reading", "next", "--temperature", "0.7", "--json"], asked);
+ assert.equal(r.code, 0, r.out);
+ assert.deepEqual([asked[1].reading, asked[1].tuning], [1, { temperature: 0.7 }]);
+ assert.equal(r.json().plays, false);
+ assert.deepEqual((await manifest(p)).timeline[0].narration, CARD.narration, "the card is not changed by a reading");
+ const readings = await cardReadings(p.dir, "c1");
+ assert.equal(readings.length, 2);
+ assert.equal(nextCardReading(readings, CARD.narration.text), 2);
+ // Approved as it plays now; picking reading 1 of the same words keeps the verdict.
+ const now = narrationsOf(await manifest(p))[0];
+ await setNarrationReview(p.dir, "c1", { verdict: "approved", key: now.key, text: now.text });
+ r = await run([p.id, "c1", "--pick", readings[1].key, "--json"]);
+ assert.equal(r.code, 0, r.out);
+ assert.equal(r.json().verdictKept, true);
+ const after1 = (await manifest(p)).timeline[0].narration;
+ assert.deepEqual([after1.reading, after1.tuning], [1, { temperature: 0.7 }]);
+ const n1 = narrationsOf(await manifest(p))[0];
+ assert.equal(n1.key, readings[1].key, "the card plays the picked reading's file");
+ assert.equal(reviewState(n1, (await readNarrationReview(p.dir)).rows.c1), "approved");
+ // Back to the first: one press, nothing synthesized.
+ r = await run([p.id, "c1", "--pick", readings[0].key.slice(0, 12)], asked);
+ assert.equal(r.code, 0, r.out);
+ assert.equal(asked.length, 2);
+ assert.equal("reading" in (await manifest(p)).timeline[0].narration, false);
+});
+
+test("--read --text reads other words (the card keeps its own until a pick); setting the words, a reading and the tuning; refusals", async () => {
+ const p = await project("set");
+ const asked = [];
+ const r = await run([p.id, "c1", "--read", "--text", "Six months on, the ferry ran.", "--reading", "next", "--json"], asked);
+ assert.equal(r.code, 0, r.out);
+ assert.equal(asked[0].reading ?? 0, 0, "new words: the first reading");
+ assert.equal((await manifest(p)).timeline[0].narration.text, CARD.narration.text);
+ assert.equal((await run([p.id, "c1", "--reading", "3"])).code, 0);
+ assert.equal((await manifest(p)).timeline[0].narration.reading, 3);
+ assert.equal((await run([p.id, "c1", "--tuning-off"])).code, 0);
+ assert.equal((await run([p.id, "c1", "--reading", "next"])).code, 1);
+ assert.equal((await run([p.id, "c1", "--pick", "0000000000"])).code, 1);
+ assert.equal((await run([p.id, "nope", "--read"])).code, 1);
+ const list = await run([p.id, "--list", "--json"]);
+ assert.equal(list.json().cards[0].readings.length, 1);
+});
diff --git a/umtool/lib/report/cardNarrationCli.mjs b/umtool/lib/report/cardNarrationCli.mjs
@@ -0,0 +1,174 @@
+// `umtool narration` -- A CARD's NARRATION from the CLI (report-to-video/narration.mjs; lane line-rerun, S3 of the
+// Orpheus re-tune plan): its words, its reading and its tuning, and its READINGS -- every voice kept for it beside the
+// build (out/narration/<key>.{wav,json}, narration-store.mjs) -- read again, compared and picked, with no agent. A
+// card's narration is SPOKEN ONLY: no card draws its words (narration.mjs), so an edit changes what is said and the
+// card's length, never what is shown.
+//
+// umtool narration <project> [--list] [--json] every narrated card: its words, reading, tuning, readings
+// umtool narration <project> <card> [--json] one card's
+// umtool narration <project> <card> --read [--text "…"] [--reading N|next] [--temperature t] [--top-p p] [--top-k k]
+// [--min-p m] [--repeat-penalty r] [--chunk-takes n] [--json]
+// ONE READING asked of the editor (its tts op, a job; waits)
+// and kept beside the build -- the card NOT changed
+// umtool narration <project> <card> --pick <key> [--json] the card made that reading: its words, reading, tuning
+// umtool narration <project> <card> [--text "…"] [--reading N] [tuning flags | --tuning-off] [--json] set them
+//
+// Plain ESM: the CLI runs it under bare node.
+import { readFile, readdir, stat } from "node:fs/promises";
+import path from "node:path";
+import { narrationKey, narrationTuningOf, narrationsOf, resolveNarration } from "umtool-report-to-video/narration";
+import { narrationDir, narrationWavPath } from "umtool-report-to-video/narration-store";
+import { REPORTS_ROOT, resolveProject } from "../projects/core.mjs";
+import { readManifest } from "../projects/report.mjs";
+import { withEditNotes } from "./edit-guard.mjs";
+import { StaleToken, StructureRefused, manifestToken, updateCardNarration } from "./manifest.mjs";
+import { NarrateError, tuningFlags } from "./postNarrationCli.mjs";
+
+export const CARD_NARRATION_USAGE = [
+ "usage: umtool narration <project> [--list] [--json]",
+ " umtool narration <project> <card> [--json]",
+ " umtool narration <project> <card> --read [--text \"…\"] [--reading N|next] [--temperature t] [--top-p p] [--top-k k]",
+ " [--min-p m] [--repeat-penalty r] [--chunk-takes n] [--json]",
+ " umtool narration <project> <card> --pick <key> [--json]",
+ " umtool narration <project> <card> [--text \"…\"] [--reading N] [tuning flags | --tuning-off] [--json]",
+ " A CARD's NARRATION: the words a stock synthetic voice says over a card (spoken only -- no card draws them), its",
+ " READING (0 the first; 1, 2, … the same words read anew) and Orpheus's TUNING (umtool posts narrate --help). Its",
+ " READINGS are the voices kept for it beside the build (out/narration/<key>.wav): each its words, reading, tuning.",
+ " --read: one reading asked of the editor (its tts op, a job; it waits while render mode holds the machine) and",
+ " kept -- the card is NOT changed; --text reads other words, --reading next one past the highest these words were",
+ " read at. --pick <key>: the card made that reading (its words, reading and tuning; nothing synthesized). Without",
+ " --read or --pick: the card's words (--text), reading and tuning set (--tuning-off: none). A verdict on the card's",
+ " words (the narration review) is kept by a pick of another reading of the same words.",
+].join("\n");
+
+const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v);
+const spacing = (t) => String(t ?? "").replace(/\s+/g, " ").trim();
+
+/** Every reading kept for `cardId` beside the build (its record and its sound there), oldest first. */
+export async function cardReadings(projectDir, cardId) {
+ const dir = narrationDir(path.join(projectDir, "out"));
+ const names = await readdir(dir).catch(() => []);
+ const out = [];
+ for (const f of names) {
+ if (!/^[0-9a-f]{64}\.json$/.test(f)) continue;
+ const rec = await readFile(path.join(dir, f), "utf8").then(JSON.parse, () => null);
+ if (!isObj(rec) || rec.id !== cardId || `${rec.key}.json` !== f) continue;
+ if (!(await stat(narrationWavPath(dir, rec.key)).catch(() => null))?.isFile()) continue;
+ out.push(rec);
+ }
+ return out.sort((a, b) => String(a.createdAt ?? "").localeCompare(String(b.createdAt ?? "")));
+}
+
+/** One past the highest reading `text` was kept at (a record with none: 0), or 0 when it never was. */
+export function nextCardReading(readings, text) {
+ let hi = -1;
+ for (const r of readings) if (spacing(r.text) === spacing(text)) hi = Math.max(hi, Number.isInteger(r.reading) ? r.reading : 0);
+ return hi + 1;
+}
+
+/** A reading as a line: its key, words, reading, tuning, length -- and whether the card plays it. */
+const readingLine = (r, current) => ` ${r.key === current ? "▶" : " "} ${r.key.slice(0, 12)} ${Number(r.seconds).toFixed(2)} s reading ${r.reading ?? 0}${r.askedTuning ? ` ${Object.entries(r.askedTuning).map(([k, v]) => `${k} ${v}`).join(", ")}` : ""} "${spacing(r.text).slice(0, 70)}"`;
+
+/** `umtool narration <project> …` */
+export async function cardNarrationCommand(args, { root = REPORTS_ROOT, out = (s) => console.log(s), err = (s) => console.error(s), narrate = null } = {}) {
+ const flags = new Map();
+ const words = [];
+ const VALUED = new Set(["--text", "--reading", "--pick", "--temperature", "--top-p", "--top-k", "--min-p", "--repeat-penalty", "--chunk-takes"]);
+ for (let i = 0; i < args.length; i += 1) {
+ const a = args[i];
+ if (VALUED.has(a)) {
+ flags.set(a, args[i + 1] ?? "");
+ i += 1;
+ } else if (a.startsWith("--")) flags.set(a, true);
+ else words.push(a);
+ }
+ const str = (k) => (flags.has(k) && typeof flags.get(k) === "string" ? flags.get(k) : null);
+ const json = flags.has("--json");
+ const [projectArg, cardId] = words;
+ if (!projectArg || flags.has("--help")) {
+ out(CARD_NARRATION_USAGE);
+ return projectArg ? 0 : 2;
+ }
+ try {
+ const r = await resolveProject(projectArg, root);
+ if (r.ambiguous) throw new NarrateError(`"${projectArg}" is the name of ${r.ambiguous.length} projects — pass its id`);
+ if (!r.project) throw new NarrateError(`no project matches "${projectArg}"`);
+ const project = r.project;
+ const manifest = await readManifest(project.dir);
+ if (!manifest) throw new NarrateError(`${project.id} has no manifest`);
+ const all = narrationsOf(manifest);
+ if (!cardId || flags.has("--list")) {
+ const rows = [];
+ for (const n of all) rows.push({ ...n, readings: await cardReadings(project.dir, n.id) });
+ if (json) out(JSON.stringify({ ok: true, cards: rows }, null, 2));
+ else {
+ out(`${project.id}: ${rows.length} narrated card(s)`);
+ for (const n of rows) out([`${n.id} ${n.engine} · ${n.voice} reading ${n.reading ?? 0}${n.tuning ? ` ${JSON.stringify(n.tuning)}` : ""} "${spacing(n.text).slice(0, 70)}"`, ...n.readings.map((x) => readingLine(x, n.key))].join("\n"));
+ }
+ return 0;
+ }
+ const e = (manifest.timeline ?? []).find((x) => x?.id === cardId);
+ const now = all.find((x) => x.id === cardId);
+ if (!e || !now) throw new NarrateError(`${cardId} is not a card with a narration (umtool narration ${project.id} --list)`);
+ const readings = await cardReadings(project.dir, cardId);
+ const tuned = tuningFlags(str);
+ const write = async (patch) => withEditNotes(project, async () => updateCardNarration(project.dir, cardId, patch, { token: await manifestToken(project.dir) }));
+
+ if (flags.has("--read")) {
+ // ONE READING, the card not changed: its words (--text, else its own), the reading and tuning asked (else its own).
+ const text = str("--text") !== null ? String(str("--text")).trim() : now.text;
+ if (!text) throw new NarrateError("--text needs words");
+ const reading = tuned?.reading === "next" ? nextCardReading(readings, text) : tuned?.reading ?? (now.reading ?? 0);
+ const tuning = tuned?.tuning ? narrationTuningOf({ ...(now.tuning ?? {}), ...tuned.tuning }) : now.tuning ?? null;
+ const ask = resolveNarration({ ...e, narration: { ...e.narration, text, ...(reading > 0 ? { reading } : { reading: undefined }), ...(tuning ? { tuning } : { tuning: undefined }) } }, manifest.render);
+ const n = { id: cardId, ...ask, key: narrationKey(ask) };
+ const run = narrate ?? (await import("umtool-report-to-video/narrate-via-editor")).narrateCut;
+ const recs = await run({ narrations: [n], dir: narrationDir(path.join(project.dir, "out")), emit: (_ev, f) => !json && f?.message && out(f.message) });
+ const rec = recs.get(cardId);
+ if (json) out(JSON.stringify({ ok: true, id: cardId, key: n.key, reading: n.reading ?? 0, tuning: n.tuning ?? null, text: n.text, seconds: rec?.seconds ?? null, plays: n.key === now.key }, null, 2));
+ else out(`${cardId}: reading ${n.reading ?? 0} kept (${n.key.slice(0, 12)}, ${rec?.seconds ?? "?"} s)${n.key === now.key ? " -- the one the card plays" : ` -- the card plays another; pick it: umtool narration ${project.id} ${cardId} --pick ${n.key}`}`);
+ return 0;
+ }
+ if (str("--pick") !== null) {
+ const key = String(str("--pick")).trim();
+ const rec = readings.find((x) => x.key === key || (key.length >= 8 && x.key.startsWith(key)));
+ if (!rec) throw new NarrateError(`${cardId} has no reading ${key} kept (umtool narration ${project.id} ${cardId})`);
+ const patch = { text: rec.text, reading: Number.isInteger(rec.reading) && rec.reading > 0 ? rec.reading : null, tuning: rec.askedTuning ?? null };
+ const want = resolveNarration({ ...e, narration: { ...e.narration, text: patch.text, reading: patch.reading ?? undefined, tuning: patch.tuning ?? undefined } }, manifest.render);
+ if (narrationKey(want) !== rec.key) throw new NarrateError(`${cardId}: reading ${rec.key.slice(0, 12)} was made with another voice or speed than the card's now -- read it again (--read)`);
+ const { result } = await write(patch);
+ // A VERDICT ON THESE WORDS IS KEPT (lane line-rerun ruling): the review keys a verdict by the narration's key,
+ // which a reading moves -- a verdict given on the card as it played, on the same words, moves with the pick.
+ const { readNarrationReview, setNarrationReview } = await import("umtool-report-to-video/narration-review");
+ const row = (await readNarrationReview(project.dir)).rows?.[cardId];
+ const kept = !!row?.verdict && row.key === now.key && spacing(row.text) === spacing(rec.text);
+ if (kept) await setNarrationReview(project.dir, cardId, { verdict: row.verdict, key: rec.key, text: rec.text });
+ if (json) out(JSON.stringify({ ok: true, id: cardId, key: rec.key, narration: result.entry.narration, verdictKept: kept, token: result.token ?? null }, null, 2));
+ else out(`${cardId}: plays reading ${rec.reading ?? 0} (${rec.key.slice(0, 12)})${kept ? ` -- still ${row.verdict} (the same words)` : ""}`);
+ return 0;
+ }
+ const patch = {};
+ if (str("--text") !== null) patch.text = String(str("--text"));
+ if (tuned?.reading === "next") throw new NarrateError("--reading next goes with --read (a reading is made, then picked)");
+ if (tuned?.reading !== undefined && tuned?.reading !== null) patch.reading = tuned.reading;
+ if (tuned?.tuning) patch.tuning = narrationTuningOf({ ...(e.narration.tuning ?? {}), ...tuned.tuning });
+ if (flags.has("--tuning-off")) patch.tuning = null;
+ if (!Object.keys(patch).length) {
+ if (json) out(JSON.stringify({ ok: true, id: cardId, narration: e.narration, key: now.key, readings }, null, 2));
+ else out([`${cardId} ${now.engine} · ${now.voice} reading ${now.reading ?? 0}${now.tuning ? ` ${JSON.stringify(now.tuning)}` : ""}`, ` "${now.text}"`, ...readings.map((x) => readingLine(x, now.key))].join("\n"));
+ return 0;
+ }
+ const { result } = await write(patch);
+ if (json) out(JSON.stringify({ ok: true, id: cardId, narration: result.entry.narration, token: result.token ?? null }, null, 2));
+ else out(`${cardId}: ${JSON.stringify(result.entry.narration)}`);
+ return 0;
+ } catch (e) {
+ if (e instanceof NarrateError || e instanceof StructureRefused || e instanceof StaleToken) {
+ const msg = e instanceof StructureRefused ? e.errors.join("; ") : e.message;
+ if (json) out(JSON.stringify({ ok: false, error: msg }, null, 2));
+ else err(`umtool narration: ${msg}`);
+ return 1;
+ }
+ throw e;
+ }
+}
diff --git a/umtool/lib/report/manifest.mjs b/umtool/lib/report/manifest.mjs
@@ -4461,6 +4461,33 @@ export async function updateNarration(dir, id, text, { token = null, at = null }
}
/**
+ * A CARD's NARRATION -- its words, its reading, its tuning -- through the manifest (lane line-rerun; `umtool narration
+ * <p> <card>`): `patch` any of `text` (words), `reading` (0 or null: the first), `tuning` (null: none). A structural
+ * write (an undo point), refused in the build's words. The words are spoken only: no card draws them.
+ */
+export async function updateCardNarration(dir, id, patch, { token = null } = {}) {
+ if (!isObj(patch) || !Object.keys(patch).length) throw new Error("a card narration patch is { text?, reading?, tuning? }");
+ for (const k of Object.keys(patch)) if (!["text", "reading", "tuning"].includes(k)) throw new Error(`${k} is not a card narration's (text, reading, tuning)`);
+ return structural(dir, "narration", token, (m) => {
+ const e = m.timeline[entryIndex(m.timeline, id)];
+ if (e.type !== "card" || !e.narration || typeof e.narration !== "object") throw new Error(`${id} is not a card with a narration`);
+ const before = JSON.stringify(e.narration);
+ if (typeof patch.text === "string") e.narration.text = patch.text.trim();
+ if ("reading" in patch) {
+ if (patch.reading === null || patch.reading === 0) delete e.narration.reading;
+ else e.narration.reading = patch.reading;
+ }
+ if ("tuning" in patch) {
+ if (patch.tuning === null || !Object.keys(patch.tuning ?? {}).length) delete e.narration.tuning;
+ else e.narration.tuning = patch.tuning;
+ }
+ const errors = validateNarration({ render: m.render, timeline: [e] });
+ if (errors.length) throw new StructureRefused(errors);
+ return { id, entry: e, changed: before !== JSON.stringify(e.narration) };
+ });
+}
+
+/**
* A drafted field's whole value, written as THE OPERATOR's (release 28, M0):
* what umtool's "Use this" under an alternative (`<task>-draft.json`) runs.
* Checked as the field's own editor checks it; a structural write (snapshot
diff --git a/umtool/report-to-video/narration-store.mjs b/umtool/report-to-video/narration-store.mjs
@@ -121,6 +121,9 @@ export async function keepNarration(dir, n, result, { jobId = null } = {}) {
// What Orpheus made it with, as the editor says (every tuning value, the reading, its seed base), so the reading
// can be made again exactly. Absent for another engine, and in a record kept before (it still reads).
...madeWith(result),
+ // The tuning it was ASKED with (lane line-rerun): what the card says to ask this file again -- its key -- when
+ // another reading is picked (umtool narration <p> <card> --pick <key>).
+ ...(n.tuning && typeof n.tuning === "object" && Object.keys(n.tuning).length ? { askedTuning: n.tuning } : {}),
editor: {
jobId,
cached: result.cached === true,