Archilyzer · Source

archilyzer

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

commit 3ae8cea8caf2e6d0f2adbbc75b6516e712dcb6fa
parent 5cbdfc02028a190ee5c4b11e2f20757fde5983b5
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Thu, 12 Nov 2026 09:13:46 -0500

umtool: a thread read can use an existing take for his own line -- posts narrate <p> <item> --take --thread --post-take <n> (the take's number as --list shows it): that take's file is the post's one part (its script the part's words), the parents, quoted and linked posts still synthesized in their characters' voices; 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 {n, file}); refused: a thread take, a number out of range, a lost file, --post-take off a thread read; up to date only for the same take; the drift guard reads the take's part as the take it is (converted: against the character's convert target; recorded: never); cast reread names the take again by its number now. --speed on a thread read reaches every synthesized part (already so since C1; tested here). Docs: cli.md, knobs.md, CHANGELOG

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

Diffstat:
Meditor/CHANGELOG.md | 1+
Mumtool/docs/cli.md | 4++--
Mumtool/docs/knobs.md | 10+++++++++-
Mumtool/lib/cli/groups.mjs | 2+-
Mumtool/lib/cli/verbs.mjs | 2+-
Mumtool/lib/report/castProject.mjs | 13++++++++++---
Mumtool/lib/report/postNarrationCli.mjs | 7++++++-
Aumtool/lib/report/postTakeThread.test.mjs | 113+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/lib/report/postThreadRead.mjs | 88++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------
Mumtool/lib/report/postsCli.mjs | 2+-
Mumtool/report-to-video/cast.mjs | 8++++++++
Mumtool/report-to-video/post-narration.mjs | 4+++-
12 files changed, 224 insertions(+), 30 deletions(-)

diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ## [Unreleased] +- **umtool: a thread read can use your recorded line.** `umtool posts narrate <p> <item> --take --thread` synthesized every part, so an operator's recorded (or recorded-and-converted) read of his own line could not sit in a thread read: the item then played his line alone and the post it answers went unread. `--post-take <n>` (the take's number as `--list` shows it) now makes his line that take, while the posts it answers, quotes and links are synthesized in their authors' voices around it. Each part of the new take says where it came from (a synthesized part its cached file and voice, the take's part its file and the take's id), the read records which take it used, and a re-read after a voice change names it again. A thread take, or a take whose file is gone, is refused. `--speed` on a thread read reaches every synthesized part (it has since the character presets landed; a test now holds it). - **umtool: an anonymous character is anonymous on screen too.** An anonymous character of a video ("Anon 1") went by its shown name only on umtool's own pages: the cut's post card still showed the author's name, handle and picture. Now the build and Play draw that author under the shown name wherever a card draws them -- the item's head, the strip, the posts it answers, quotes and links, a repost line, "Replying to", a thread read's and a scene's tiles, a side card, the vertical cut, the chapters -- with no handle, no verified badge and a neutral avatar (the shown name's initial on the card's muted colour). A mention of their handle in the words the card shows becomes `@Anon_1`, and a reply's captured thread shot that shows them is not drawn. A cut with no anonymous character renders exactly as before; a `narration/characters.json` the build cannot read now stops the build rather than show a real name. What a read says is unchanged. - **umtool: the Voices page proposes characters and you accept, change or reject each.** A new "proposed" section: **Propose characters** runs the same rule as `umtool cast assign` (no model is needed or asked), each proposal shows its voice, why it was chosen and the items it would be named on, and **Accept**, **Change** (another stock voice, the name, anonymous) and **Reject** each go through the same writer as the CLI. Accepting never touches a picked read: one in another voice is listed as drift, as before. - **umtool: every post author gets a character by rule, as a proposal you accept.** Giving each author of a video a voice meant one `cast project … keep` or Voices-page click per author. `umtool cast assign <p>` now goes through every post item's author: one the item, this video, its voice map or the cast already answers for is left as it is; one with none gets a PROPOSED character of this video -- an id from the handle, their name and a stock Kokoro voice, the next in one fixed rotation (a male and a female voice in turn) that the project does not use yet. A gender hint comes only from pronouns the profile itself states; today's captures carry none, so the rotation is neutral. Proposals are kept apart in `narration/characters.json` (the same writer and undo) and change nothing until a person acts: `--accept <id>` / `--accept-all` makes the character and names it on that author's items that name none, without touching any take; `--change <id>` sets its voice (a stock one only), speed, name or anonymity; `--reject <id>` drops it. `--dry-run` writes nothing. diff --git a/umtool/docs/cli.md b/umtool/docs/cli.md @@ -133,7 +133,7 @@ Inbox cannot disagree about what is wrong with one. | `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 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] [--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). 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** | +| `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] [--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** | | `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** | | `posts character <project> <item> [<character> \| --clear] [--json]` | **THE CHARACTER ONE ITEM's OWN READ IS MADE WITH** (`narration.character`, [knobs.md](knobs.md#this-videos-own-characters-and-an-items-own)): the id of one of this video's own characters, else of the cast's -- its presets answer for that item before its author's handle does (the synthetic one for `--take` and a thread read, the recorded one for `--recording`). No character: the one it names and what its read resolves to now; `--clear`: by its handle again. One undoable write; no take is made. An id nobody has: **exit 2** | | `posts voices <project> [ls] \| set <handle\|*> <voice> \| remove <handle\|*> [--json]` | **THE VOICE MAP** (`narration/voices.json`): the stock voice a thread read gives each author (`*`: everyone it does not name; default `leo` on Orpheus); `ls` lists the map and every author the cut's items carry with the voice each would get. A bad handle or voice: **exit 2** | @@ -361,7 +361,7 @@ draft (the project's manifest); *project*: a project's other files, or reads; *c | `posts set <project> <post> key=value…` | the Posts table's writer: thread, hide, attach, crop | form · *draft* | | `posts reel <project> --channel CHANNEL… [--since SINCE] [--until UNTIL] [--own] [--with-media] [--replies include\|only\|exclude] [--order chrono\|reverse] [--limit N] [--after AFTER] [--dry-run]` | post items from posts channels, in one write | form · *draft* | | `posts set-item <project> <item> key=value… [--in-take IN-TAKE]` | a post item's knobs | form · *draft* | -| `posts narrate <project> [<item>] [key=value…] [--script SCRIPT] [--take] [--note NOTE] [--voice VOICE] [--engine ENGINE] [--speed N] [--pick N] [--approve] [--unapprove] [--off] [--on] [--thread] [--parents PARENTS] [--words] [--import] [--list] [--all] [--draft-scripts] [--limit N] [--force] [--recording RECORDING] [--as AS] [--pitch target\|source\|contour] [--semitones N] [--dry-run] [--in-take IN-TAKE]` | a post item's narration: script, takes, pick, approve, mix | form · queued · *draft* | +| `posts narrate <project> [<item>] [key=value…] [--script SCRIPT] [--take] [--note NOTE] [--voice VOICE] [--engine ENGINE] [--speed N] [--pick N] [--approve] [--unapprove] [--off] [--on] [--thread] [--parents PARENTS] [--post-take N] [--words] [--import] [--list] [--all] [--draft-scripts] [--limit N] [--force] [--recording RECORDING] [--as AS] [--pitch target\|source\|contour] [--semitones N] [--dry-run] [--in-take IN-TAKE]` | a post item's narration: script, takes, pick, approve, mix | form · queued · *draft* | | `posts say <project> ls\|add\|remove\|try\|stale [<word>] [<spoken>] [--case] [--item ITEM] [--note NOTE]` | the pronunciation lexicon | form · *draft* | | `posts character <project> <item> [<character>] [--clear]` | the character one post item's own read is made with | form · *draft* | | `posts voices <project> ls\|set\|remove [<handle>] [<voice>]` | the voice map a thread read uses | form · *draft* | diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -1300,13 +1300,21 @@ held while parts are asked (only if it was not held; released after, on a failur (`umtool timeline <p> undo`). Its exit code is the answer: 0 made or already up to date (`"upToDate": true`), 1 a part was not synthesized (the parts made stay cached: run it again), 2 a usage error; `--json` for a queue step. +**His own line from a take** (`--post-take <n>`, 1 = the first take as `--list` numbers them): a person's recording of +the item, or one converted to his character's voice, is HIS piece of the thread read -- not synthesized; the posts it +answers, quotes and links are, in their authors' voices, around it. The take's file is the post's one part (its +script the part's words); in the new take's parts a synthesized part keeps its parts-cache file and voice, the take's +part its file and `take` (that take's id), and the read records `postTake: {n, file}` (a re-read after a voice +change names that take again by its number then). A converted take's part is compared with his character's convert +target for drift, a recorded one never. A thread take, or a take whose file is gone, is refused (exit 1). + | Knob | In umtool | From a terminal | Route | |---|---|---|---| | the lexicon -- `[{word, say, case?, item?, note?}]` (at most 500) | the Cut tab's Options → **Reads and voices**: the list, **Add** a word and how it is said, ✕ removes; the bench's re-take applies it | `umtool posts say <p> add tbh "T-B-H"` · `add atm "at the moment" --item p-…` · `add US "U.S." --case` · `ls [--item <id>]` · `remove tbh [--item <id>]` (or its number) | — (`POST /api/report/post-narration {op: "take"}` applies it) | | what a voice would be asked to say (the lexicon, the redaction, the slur filter) | **Reads and voices** → **Try it** | `umtool posts say <p> try "tbh @grok atm" [--item <id>]` | — | | the picked reads that say an entry the old way, each with the command that re-reads it | **Reads and voices** names them | `umtool posts say <p> stale [--json]` | — | | the voice map | **Reads and voices**: the map, **Set** a handle (or `*`) and a voice, ✕ removes; the cut's authors with the voice each gets | `umtool posts voices <p> set kirscheverstahl tara` · `set '*' leo` · `remove <handle>` · `ls` (each author the cut carries, and the voice each gets) | — | -| a thread read -- `takes[i].read: {kind: "thread", parents, skip?, quoted?, linked?, seen?, voiceFor?, voice?}` | the post bench plays and picks it like any take | `umtool posts narrate <p> <item> --take --thread` (parent 0) · `--parents all` (every ancestor) · `--parents none` · `--skip-parent <id>` (repeat) · `--no-quoted` · `--no-linked` · `--read-seen` · `--voice-for Movail2=leah` · `--voice leo` · `--speed 1.1` · `--force` · `--dry-run` · `--json` | — | +| a thread read -- `takes[i].read: {kind: "thread", parents, skip?, quoted?, linked?, seen?, voiceFor?, voice?, speed?, postTake?}` | the post bench plays and picks it like any take | `umtool posts narrate <p> <item> --take --thread` (parent 0) · `--parents all` (every ancestor) · `--parents none` · `--skip-parent <id>` (repeat) · `--no-quoted` · `--no-linked` · `--read-seen` · `--voice-for Movail2=leah` · `--voice leo` · `--speed 1.1` · `--post-take 2` (his line: take 2) · `--force` · `--dry-run` · `--json` | — | Recipes (copy them; `<p>` is the project, `<item>` the post item's id or its post's id): diff --git a/umtool/lib/cli/groups.mjs b/umtool/lib/cli/groups.mjs @@ -1044,7 +1044,7 @@ export const GROUPS = [ ["`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] [--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). 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**"], + "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**"], ["`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**"], ["`posts character <project> <item> [<character> \\| --clear] [--json]`", diff --git a/umtool/lib/cli/verbs.mjs b/umtool/lib/cli/verbs.mjs @@ -497,7 +497,7 @@ 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("--pick"), bool("--approve"), bool("--unapprove"), bool("--off"), bool("--on"), - bool("--thread", "with --take: a thread read"), opt("--parents"), bool("--words", "the picked take's word timings"), bool("--import"), bool("--list"), bool("--all"), bool("--draft-scripts"), + 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(), pairs({ required: false, help: "the mix: lead= tail= linger= rate= …, one per line" }), inTake(), diff --git a/umtool/lib/report/castProject.mjs b/umtool/lib/report/castProject.mjs @@ -151,8 +151,11 @@ export function projectCharacters(manifest, { map = {}, cast = null, project = n }; } -/** A thread take's `read` record as the argv that asks for it again, leaving out the overrides of `handles`. */ -export function threadArgvOf(read, { handles = [], author = null } = {}) { +/** + * A thread take's `read` record as the argv that asks for it again, leaving out the overrides of `handles`. A read + * whose own line was a take (`postTake`) names that take again by its number NOW (`takes`: the item's, found by file). + */ +export function threadArgvOf(read, { handles = [], author = null, takes = null } = {}) { if (!read || read.kind !== "thread") return []; const drop = new Set(handles.map(handleKey)); const a = []; @@ -164,6 +167,10 @@ export function threadArgvOf(read, { handles = [], author = null } = {}) { for (const [h, v] of Object.entries(read.voiceFor ?? {})) if (!drop.has(handleKey(h))) a.push("--voice-for", `${h}=${v}`); if (read.voice && !(author && drop.has(handleKey(author)))) a.push("--voice", String(read.voice)); if (typeof read.speed === "number") a.push("--speed", String(read.speed)); + if (read.postTake && typeof read.postTake.file === "string") { + const at = Array.isArray(takes) ? takes.findIndex((t) => t?.file === read.postTake.file) : -1; + a.push("--post-take", String(at >= 0 ? at + 1 : read.postTake.n)); + } return a; } @@ -192,7 +199,7 @@ export function rereadPlan(projectId, manifest, drift, handles) { const e = tl.find((x) => x?.id === r.id); const takes = e?.narration?.takes ?? []; const t = takes[Number.isInteger(e?.narration?.pick) ? e.narration.pick : 0] ?? null; - const argv = ["posts", "narrate", projectId, r.id, "--take", ...(r.thread ? ["--thread", ...threadArgvOf(t?.read, { handles: [...want], author: e?.handle })] : [])]; + const argv = ["posts", "narrate", projectId, r.id, "--take", ...(r.thread ? ["--thread", ...threadArgvOf(t?.read, { handles: [...want], author: e?.handle, takes })] : [])]; return { ...r, take: t?.file ?? null, argv }; }); return { items, skipped }; diff --git a/umtool/lib/report/postNarrationCli.mjs b/umtool/lib/report/postNarrationCli.mjs @@ -54,7 +54,7 @@ export const NARRATE_USAGE = [ " umtool posts narrate <project> <item> --derive <n> --op enhance|convert [--engine e] [--voice v] [--as <character>]", " [--pitch target|source|contour] [--semitones <n>]", " umtool posts narrate <project> <item> --take --thread [--parents 0|all|none|<n>] [--skip-parent <id>]… [--no-quoted]", - " [--no-linked] [--read-seen] [--voice-for <handle>=<voice>]… [--voice v] [--speed s] [--force] [--dry-run]", + " [--no-linked] [--read-seen] [--voice-for <handle>=<voice>]… [--voice v] [--speed s] [--post-take <n>] [--force] [--dry-run]", " umtool posts narrate <project> <item> … --in-take <take> any of these on a TAKE of the project: the pick, a new", " read (--take, --thread), the script, the mix -- written into the take's patch (umtool posts --help)", " umtool posts narrate <project> --all --draft-scripts [--force] | --all --take [--limit N]", @@ -89,6 +89,8 @@ export const NARRATE_USAGE = [ " nothing again; --discard-preview removes it. --events: its progress as one JSON object a line.", " --speed <s> (--take, --take --thread): the speed the read is asked at (0.5-2; Orpheus has none) -- default the", " item's own, else its character's (the synthetic preset's: umtool cast set <id> --speed). A thread read: every part.", + " --post-take <n> (--take --thread): 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 around it is; each part records where it came from.", " --derive <n> --op enhance|convert [--engine e] [--voice v]: a NEW take made from take n by the editor's op", " (enhance: denoise, level; convert: the performance kept, the timbre a STOCK synthetic voice) -- the original kept.", " A convert is the CHARACTER's (--as, else the item's own, this video's for the author, the cast's, the narrator):", @@ -686,8 +688,11 @@ export async function narrateCommand(project, words, flags, { json = false, dryR manifest, json, out, overrides, parents, skip: multi("--skip-parent").flatMap((x) => x.split(",")).map((x) => x.trim()).filter(Boolean), quoted: !flags.has("--no-quoted"), linked: !flags.has("--no-linked"), readSeen: flags.has("--read-seen"), voice: str("--voice"), engine: str("--engine"), speed: speedFlag(str), note: str("--note"), force: flags.has("--force"), hold: !flags.has("--no-hold"), dryRun, + // His own line from an existing take (its number as --list shows it), the context synthesized around it. + postTake: str("--post-take"), }); } + if (str("--post-take") !== null) throw new NarrateError("--post-take is a thread read's (umtool posts narrate <p> <item> --take --thread --post-take <n>)"); if (flags.has("--thread")) throw new NarrateError("--thread goes with --take (umtool posts narrate <p> <item> --take --thread)"); if (flags.has("--take")) { const r = await makeTake(project, e, { diff --git a/umtool/lib/report/postTakeThread.test.mjs b/umtool/lib/report/postTakeThread.test.mjs @@ -0,0 +1,113 @@ +// A THREAD READ with his own line from an existing take (postThreadRead.mjs --post-take): the parent synthesized in +// its author's voice, his line the take's file as one part; the parts say where each came from; a thread take, a take +// out of range, a lost file refused; up to date only for the same take; the drift guard reads the take's part as the +// take it is; a re-read names it again; --speed still reaches the synthesized parts. No editor (a stub tts); temp dirs. +import assert from "node:assert/strict"; +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 { 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 { takeReads } from "umtool-report-to-video/cast"; +import { validatePostNarration } from "umtool-report-to-video/post-narration"; +import { postsCommand } from "./postsCli.mjs"; +import { postTakeOf, threadTake, upToDate, threadReadPlan } from "./postThreadRead.mjs"; +import { threadArgvOf } from "./castProject.mjs"; + +const ROOT = await mkdtemp(path.join(tmpdir(), "umtool-post-take-")); +after(() => rm(ROOT, { recursive: true, force: true })); +const wavOf = async (file, voice, seconds = 1.2) => { + await mkdir(path.dirname(file), { recursive: true }); + await writeFile(file, encodeWav16(withSilence(syntheticVoice({ ...voice, seconds }), { before: 0.2, after: 0.2 }))); +}; +const stubAsk = (asked) => async (body) => { + asked.push(body); + await wavOf(body.out, VOICE_B, 1); + return { jobId: `job-${asked.length}`, result: { wav: body.out } }; +}; + +const DIR = path.join(ROOT, "pt"); +const project = { id: "pt", dir: DIR }; +// p-1 answers @guest; its takes: 1 a recording, 2 that recording converted to a stock voice, 3 a thread read. +const T1 = { file: "narration/posts/1/take-1.recorded.wav", engine: "recorded", voice: "operator", seconds: 1.6, script: "My own line, recorded.", source: { kind: "recorded", voice: "operator" } }; +const T2 = { file: "narration/posts/1/take-2.derived.wav", engine: "derived", voice: "am_michael", seconds: 1.6, script: "My own line, recorded.", source: { kind: "take", from: "take-1.recorded" }, steps: [{ op: "convert", voice: "kokoro:am_michael" }] }; +const T3 = { file: "narration/posts/1/take-3.kokoro-thread.wav", engine: "kokoro", voice: "af_heart+am_michael", seconds: 3, script: "x", read: { kind: "thread", parents: "0" } }; +{ + await mkdir(DIR, { recursive: true }); + for (const t of [T1, T2, T3]) await wavOf(path.join(DIR, t.file), VOICE_A, 1.2); + await writeFile(path.join(DIR, "video.manifest.json"), JSON.stringify({ + schemaVersion: 1, slug: "pt", title: "Post take", provenance: { channelsDir: "../channels", channelSlug: "chan" }, + render: { width: 1920, height: 1080, fps: 30, postNarration: { engine: "kokoro", voice: "af_heart" } }, + timeline: [{ + type: "post", id: "p-1", post: "chan/1", platform: "x", author: "Host", handle: "host", date: "2026-10-30T10:00:00.000Z", text: "my words", + parents: [{ id: "20", handle: "guest", author: "The Guest", date: "2026-10-30T09:00:00.000Z", text: "the guest asks a question" }], + narration: { script: "My own line, recorded.", takes: [T1, T2, T3], pick: 1 }, + }], + }, null, 2)); + await mkdir(path.join(DIR, "narration"), { recursive: true }); + await writeFile(path.join(DIR, "narration", "voices.json"), JSON.stringify({ guest: "kokoro:bf_emma" })); +} +const manifest = async () => JSON.parse(await readFile(path.join(DIR, "video.manifest.json"), "utf8")); +const item = async () => (await manifest()).timeline[0]; +const posts = async (args) => { + const lines = []; + const code = await postsCommand(args, { root: ROOT, out: (s) => lines.push(s), err: (s) => lines.push(s) }); + return { code, text: lines.join("\n"), json: () => JSON.parse(lines.join("\n")) }; +}; + +test("the take a thread read's own line may be: 1-based as --list numbers them; a thread take or one out of range refused", async () => { + const e = await item(); + assert.equal(postTakeOf(e, 2).take.file, T2.file); + assert.throws(() => postTakeOf(e, 0), /--post-take takes a take's number/); + assert.throws(() => postTakeOf(e, 4), /has 3 take\(s\)/); + assert.throws(() => postTakeOf(e, 3), /is a thread read itself/); + assert.throws(() => postTakeOf(e, "x"), /--post-take takes/); +}); + +test("--post-take: the parent synthesized, his line the take; each part says where it came from; up to date for the same take only", async () => { + const e = await item(); + const asked = []; + const r = await threadTake(project, e, { red: null, ask: stubAsk(asked), lanes: null, postTake: 2, speed: 1.2 }); + assert.deepEqual(asked.map((b) => [b.voice, b.speed, b.text]), [["bf_emma", 1.2, "the guest asks a question"]], "only the parent asked of the editor, at --speed"); + assert.deepEqual(r.take.parts.map((p) => [p.role, p.voice, p.file.startsWith("narration/parts-cache/") ? "cache" : p.file, p.take ?? null]), [ + ["parent:0", "bf_emma", "cache", null], + ["post", "am_michael", T2.file, "take-2.derived"], + ]); + assert.equal(r.take.parts[1].text, "My own line, recorded."); + assert.deepEqual(r.take.read.postTake, { n: 2, file: T2.file }); + assert.equal(r.take.read.speed, 1.2); + assert.equal(r.take.engine, "kokoro", "the synthesized pieces' engine names the take"); + assert.match(r.take.file, /take-4\.kokoro-thread\.wav$/); + const after1 = await item(); + assert.deepEqual(validatePostNarration(after1), [], "the manifest takes it"); + assert.equal(after1.narration.pick, 3, "picked"); + assert.equal(after1.narration.script, "My own line, recorded.", "his script untouched"); + // Up to date: the same take, the same words -- another take is not. + const again = await threadTake(project, after1, { red: null, ask: stubAsk(asked), lanes: null, postTake: 2, speed: 1.2 }); + assert.equal(again.upToDate, true); + assert.equal(upToDate(after1, threadReadPlan(await manifest(), after1, { map: { guest: "kokoro:bf_emma" }, speed: 1.2, postTake: postTakeOf(after1, 1) })), false); + assert.equal(upToDate(after1, threadReadPlan(await manifest(), after1, { map: { guest: "kokoro:bf_emma" }, speed: 1.2 })), false, "a synthesized line is not the take's"); + // The drift guard reads his part as the converted take it is; the parent as synthesized. + const reads = takeReads(after1); + assert.deepEqual(reads.map((x) => [x.role, x.kind, x.voice]), [["parent:0", "tts", "bf_emma"], ["post", "converted", "am_michael"]]); + // A re-read names the same take again, by its number now. + assert.deepEqual(threadArgvOf(after1.narration.takes[3].read, { takes: after1.narration.takes }), ["--speed", "1.2", "--post-take", "2"]); +}); + +test("through the CLI: --post-take on a thread read; refused off one, on a thread take, and for a lost file", async () => { + let c = await posts(["narrate", "pt", "p-1", "--take", "--thread", "--post-take", "1", "--dry-run", "--json"]); + assert.equal(c.code, 0, c.text); + assert.deepEqual(c.json().pieces.map((p) => [p.role, p.voice, p.take?.n ?? null]), [["parent:0", "bf_emma", null], ["post", "operator", 1]]); + assert.deepEqual(c.json().parts.map((p) => p.take ?? null), [null, "take-1.recorded"]); + c = await posts(["narrate", "pt", "p-1", "--take", "--post-take", "1"]); + assert.equal(c.code, 2); + assert.match(c.text, /--post-take is a thread read's/); + c = await posts(["narrate", "pt", "p-1", "--take", "--thread", "--post-take", "3", "--dry-run", "--json"]); + assert.equal(c.code, 1); + assert.match(c.json().error, /is a thread read itself/); + await rm(path.join(DIR, T1.file)); + c = await posts(["narrate", "pt", "p-1", "--take", "--thread", "--post-take", "1", "--json"]); + assert.equal(c.code, 1); + assert.match(c.json().error, /its file .* is not there/); +}); diff --git a/umtool/lib/report/postThreadRead.mjs b/umtool/lib/report/postThreadRead.mjs @@ -7,8 +7,14 @@ // take, saved and picked in ONE write (one undo point). // // umtool posts narrate <p> <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] -// [--note "…"] [--force] [--no-hold] [--dry-run] [--json] +// [--no-quoted] [--no-linked] [--read-seen] [--voice-for <handle>=<voice>]… [--voice v] [--engine e] [--speed s] +// [--post-take <n>] [--note "…"] [--force] [--no-hold] [--dry-run] [--json] +// +// --post-take <n> (characters C3): HIS OWN LINE is an existing take of the item (its number as --list shows it, 1 = +// the first) -- a recorded read, or one converted to his character's voice -- not synthesized; the context pieces +// are synthesized as ever, in their authors' voices. The take's file is the post's one part (its script the part's +// words); the new take's parts record where each came from (a synthesized part its parts-cache file and voice, the +// take's its file and `take`: that take's id), and its `read` the take it used. A thread take is refused as the part. // // THE PIECES (post-thread.mjs chronoPieces): every context post the card draws with words, and his post, oldest // first (each at its own date; without dates: the parents oldest first, the quoted post, the linked posts, his). @@ -51,7 +57,7 @@ import { createHash } from "node:crypto"; import { mkdir, readdir, stat, writeFile } from "node:fs/promises"; import path from "node:path"; import { promisify } from "node:util"; -import { POST_PART_GAP, draftScript, nextTakeNumber, pickedTake, postIdOf, postNarrationKnobs, scriptParts, takeFileOf, takesDirOf } from "umtool-report-to-video/post-narration"; +import { POST_PART_GAP, draftScript, nextTakeNumber, pickedTake, postIdOf, postNarrationKnobs, scriptParts, takeFileOf, takeIdOf, takesDirOf } from "umtool-report-to-video/post-narration"; import { chronoPieces } from "umtool-report-to-video/post-thread"; import { cardText, parentsOf } from "umtool-report-to-video/post-item"; import { planContext } from "umtool-report-to-video/post-conversation"; @@ -82,7 +88,7 @@ export class ThreadReadError extends Error { export const THREAD_READ_USAGE = [ " umtool 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]", - " [--note \"…\"] [--force] [--no-hold] [--dry-run] [--json]", + " [--post-take <n>] [--note \"…\"] [--force] [--no-hold] [--dry-run] [--json]", " A THREAD READ: the post it answers (--parents all: every ancestor; none: no parent), the post it quotes, the posts", " its words link to and his words, in DATE order, each in its author's voice (the project's voice map, umtool posts", " voices; --voice-for handle=voice for this read) and at its character's SPEED (its synthetic preset's; --speed s:", @@ -93,6 +99,9 @@ export const THREAD_READ_USAGE = [ " PICKED in one write (one undo point). --dry-run: the pieces, voices and parts (cached or to synthesize), nothing", " asked. Up to date already (same words, same voices): left alone, exit 0 (--force: made again). Exit 1: a part", " could not be synthesized (the parts already made stay cached: run it 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; each part of the new take", + " says where it came from. A thread take, or a take whose file is gone, is refused.", ].join("\n"); /** @@ -152,7 +161,7 @@ export function seenIds(manifest, e) { * @param {{ red?: any, map?: Record<string, any>, cast?: Record<string, any>, item?: any, overrides?: Record<string, string>, parents?: string, * skip?: string[], quoted?: boolean, linked?: boolean, readSeen?: boolean, voice?: string | null, engine?: string | null, speed?: number | null }} [o] */ -export function threadReadPlan(manifest, e, { red = null, map = {}, cast = {}, item = null, overrides = {}, parents = "0", skip = [], quoted = true, linked = true, readSeen = false, voice = null, engine = null, speed = null } = {}) { +export function threadReadPlan(manifest, e, { red = null, map = {}, cast = {}, item = null, overrides = {}, parents = "0", skip = [], quoted = true, linked = true, readSeen = false, voice = null, engine = null, speed = null, postTake = null } = {}) { const render = manifest?.render ?? {}; const k = postNarrationKnobs(e, render); const eng = engine ?? e.narration?.engine ?? k.engine; @@ -215,40 +224,74 @@ export function threadReadPlan(manifest, e, { red = null, map = {}, cast = {}, i pieces.push({ role: p.role, handle: p.handle, date: p.date, voice: v.voice, engine: v.engine, from: v.from, ...(spd !== null ? { speed: spd } : {}), ...(v.character ? { character: v.character } : {}), written, text: said.text.trim(), lexicon: said.lexicon ?? [], slurs: said.slurs }); } if (!pieces.some((p) => p.role === "post")) throw new ThreadReadError(`${e.id} has no words of his own to read (--script "…" first)`); + // HIS LINE FROM A TAKE (--post-take): the take's file is the post's piece, its script its words; nothing synthesized. + if (postTake) { + const at = pieces.findIndex((p) => p.role === "post"); + const t = postTake.take; + const words = norm(t.script) || pieces[at].text; + pieces[at] = { + role: "post", handle: pieces[at].handle, date: pieces[at].date, voice: takeVoiceOf(t), from: "take", written: words, text: words, lexicon: [], slurs: t.slurs ?? null, + take: { n: postTake.n, id: takeIdOf(t), file: t.file, ...(t.engine ? { engine: t.engine } : {}) }, + }; + } const lexicon = [...new Map(pieces.flatMap((p) => p.lexicon).map((x) => [`${x.word.toLowerCase()}|${x.item ?? ""}`, x])).values()]; const states = pieces.map((p) => p.slurs).filter(Boolean); return { - engine: pieces.find((p) => p.role === "post")?.engine ?? eng, narrator, pieces, skipped, script, + // The read's engine: his piece's -- a take's line has none of a synthesizer's, so the first synthesized piece's. + engine: pieces.find((p) => p.role === "post" && !p.take)?.engine ?? pieces.find((p) => !p.take)?.engine ?? eng, narrator, pieces, skipped, script: postTake ? null : script, want: pieces.map((p) => p.text).join("\n\n"), voice: [...new Set(pieces.map((p) => p.voice))].join("+"), lexicon, slurs: states.includes("said") ? "said" : states[0] ?? null, }; } -/** The read's PARTS, pure: each piece's parts (scriptParts) with its voice, engine, role and cache key, in order. */ +/** A take's voice as a thread read's label says it: its voice (or recorded label) without an engine ("am_michael", "operator"). */ +export function takeVoiceOf(t) { + const v = str(t?.voice) || str(t?.label) || (t?.engine === "recorded" ? "recorded" : "take"); + return v.includes(":") ? v.slice(v.indexOf(":") + 1) : v; +} + +/** + * THE TAKE A THREAD READ's own line may be (--post-take n, as --list numbers them), checked: `{ n, take }`. Refused: no + * such take, a THREAD take (its own context in it), one with no file. + */ +export function postTakeOf(e, n) { + const takes = Array.isArray(e?.narration?.takes) ? e.narration.takes : []; + const k = Number(n); + if (!Number.isInteger(k) || k < 1) throw new ThreadReadError(`--post-take takes a take's number as --list shows it (1 = the first), not ${n}`); + if (k > takes.length) throw new ThreadReadError(`--post-take ${k}: ${e?.id} has ${takes.length} take(s)`); + const t = takes[k - 1]; + if (!t || typeof t.file !== "string" || !t.file) throw new ThreadReadError(`--post-take ${k}: that take has no file`); + if (/-thread\.wav$/.test(t.file) || t.read?.kind === "thread") throw new ThreadReadError(`--post-take ${k} is a thread read itself (${t.file}): name a take of his line alone`); + return { n: k, take: t }; +} + +/** The read's PARTS, pure: each piece's parts (scriptParts) with its voice, engine, role and cache key, in order -- a take's line one part, its file. */ export function readParts(plan) { return plan.pieces.flatMap((pc, piece) => { + if (pc.take) return [{ piece, para: 0, role: pc.role, voice: pc.voice, text: pc.text, file: pc.take.file, take: pc.take.id, key: null }]; const eng = pc.engine ?? plan.engine; return scriptParts(pc.text).map((q) => ({ piece, para: q.para, role: pc.role, voice: pc.voice, engine: eng, ...(pc.speed !== undefined ? { speed: pc.speed } : {}), text: q.text, key: partKey(eng, pc.voice, q.text, pc.speed ?? null) })); }); } /** Each piece's `engine:voice` (and its speed, when it has one), in order, once each -- what a read sounds like, for "is it up to date". */ -const voiceSig = (rows, fallback) => [...new Set(rows.map((p) => `${p.engine ?? fallback}:${p.voice}${typeof p.speed === "number" && p.speed !== 1 ? `x${p.speed}` : ""}`))].join("+"); +const voiceSig = (rows, fallback) => [...new Set(rows.map((p) => (p.take ? `take:${typeof p.take === "object" ? p.take.id : p.take}` : `${p.engine ?? fallback}:${p.voice}${typeof p.speed === "number" && p.speed !== 1 ? `x${p.speed}` : ""}`)))].join("+"); /** * THE JOIN's TIMES, pure: each part's start in the take, its length, the gap before it (POST_PART_GAP: a new piece, * a new paragraph, inside one) -- the parts meta as `take-<n>.parts.json` holds it -- and the take's length. * `para` is the piece × 100 + the paragraph (post-thread.mjs reads a piece as `para` div 100). */ -export function joinTimes(parts, seconds, { fileOf = (p) => `${PARTS_CACHE}/${p.key}.wav` } = {}) { +export function joinTimes(parts, seconds, { fileOf = (p) => (p.take ? p.file : `${PARTS_CACHE}/${p.key}.wav`) } = {}) { let t = 0; const meta = parts.map((p, i) => { const prev = i > 0 ? parts[i - 1] : null; const gap = !prev ? 0 : p.piece !== prev.piece ? POST_PART_GAP.piece : p.para !== prev.para ? POST_PART_GAP.para : POST_PART_GAP.inside; t += gap; const s = Number(seconds[i]); - const row = { n: i + 1, para: p.piece * 100 + p.para, text: p.text, voice: p.voice, ...(p.engine ? { engine: p.engine } : {}), ...(typeof p.speed === "number" ? { speed: p.speed } : {}), role: p.role, piece: p.piece, file: fileOf(p), start: r3(t), seconds: r3(s), gapBefore: gap }; + // A part from a take (--post-take) says which (`take`: its id); a synthesized one its parts-cache file and voice. + const row = { n: i + 1, para: p.piece * 100 + p.para, text: p.text, voice: p.voice, ...(p.engine ? { engine: p.engine } : {}), ...(typeof p.speed === "number" ? { speed: p.speed } : {}), role: p.role, piece: p.piece, file: fileOf(p), ...(p.take ? { take: p.take } : {}), start: r3(t), seconds: r3(s), gapBefore: gap }; t += s; return row; }); @@ -256,13 +299,15 @@ export function joinTimes(parts, seconds, { fileOf = (p) => `${PARTS_CACHE}/${p. } /** The `read` record of a take: how it was asked for (only what differs from the defaults). */ -export function readRecordOf({ parents = "0", skip = [], quoted = true, linked = true, readSeen = false, overrides = {}, voice = null, speed = null }) { +export function readRecordOf({ parents = "0", skip = [], quoted = true, linked = true, readSeen = false, overrides = {}, voice = null, speed = null, postTake = null }) { return { kind: "thread", parents: parentsSelector(parents), ...(skip?.length ? { skip: [...skip] } : {}), ...(quoted ? {} : { quoted: false }), ...(linked ? {} : { linked: false }), ...(readSeen ? { seen: true } : {}), ...(Object.keys(overrides ?? {}).length ? { voiceFor: { ...overrides } } : {}), ...(voice ? { voice } : {}), // The speed the command asked for the whole read (`--speed`); a character's own is its preset's, not the read's. ...(typeof speed === "number" && Number.isFinite(speed) ? { speed } : {}), + // His line from a take (--post-take): its number then, and its file. + ...(postTake ? { postTake: { n: postTake.n, file: postTake.take.file } } : {}), }; } @@ -270,6 +315,8 @@ export function readRecordOf({ parents = "0", skip = [], quoted = true, linked = export function upToDate(e, plan) { const t = pickedTake(e); if (!t || norm(t.script) !== norm(plan.want) || str(t.voice) !== plan.voice || (t.engine ?? "orpheus") !== plan.engine) return false; + // His line from a take: the same take's file, or not up to date. + if (str(t.read?.postTake?.file) !== str(plan.pieces.find((p) => p.take)?.take?.file)) return false; // A take whose parts say their voices: each piece in the same engine and voice, at the same speed. const parts = Array.isArray(t.parts) ? t.parts.filter((p) => typeof p?.voice === "string") : []; if (!parts.length) return !plan.pieces.some((p) => typeof p.speed === "number"); @@ -296,7 +343,7 @@ export async function threadTake(project, e, opts = {}) { const { manifest: m0 = null, red: red0 = undefined, map: map0 = undefined, cast: cast0 = undefined, item: item0 = undefined, overrides = {}, parents = "0", skip = [], quoted = true, linked = true, readSeen = false, voice = null, engine = null, speed = null, note = null, force = false, hold = true, dryRun = false, - ask = null, lanes: lanes0 = undefined, emit = () => {}, editor = null, signals = false, + ask = null, lanes: lanes0 = undefined, emit = () => {}, editor = null, signals = false, postTake: postTakeN = null, } = opts; const manifest = m0 ?? (await readManifest(project.dir)); if (!manifest) throw new ThreadReadError(`${project.id} has no manifest`); @@ -307,11 +354,14 @@ export async function threadTake(project, e, opts = {}) { const map = map0 !== undefined ? map0 : L.map; const cast = cast0 !== undefined ? cast0 : L.castMap; const item = item0 !== undefined ? item0 : L?.itemOf(e) ?? null; - const plan = threadReadPlan(manifest, e, { red, map, cast, item, overrides, parents, skip, quoted, linked, readSeen, voice, engine, speed }); + const postTake = postTakeN === null || postTakeN === undefined ? null : postTakeOf(e, postTakeN); + const plan = threadReadPlan(manifest, e, { red, map, cast, item, overrides, parents, skip, quoted, linked, readSeen, voice, engine, speed, postTake }); const parts = readParts(plan); const cacheDir = path.join(project.dir, ...PARTS_CACHE.split("/")); - const wavOf = (p) => path.join(cacheDir, `${p.key}.wav`); + const wavOf = (p) => (p.take ? path.join(project.dir, ...p.file.split("/")) : path.join(cacheDir, `${p.key}.wav`)); const have = await Promise.all(parts.map((p) => fileThere(wavOf(p)))); + const lost = parts.find((p, i) => p.take && !have[i]); + if (lost) throw new ThreadReadError(`--post-take ${postTake.n}: its file ${lost.file} is not there`); const base = { plan, parts: parts.map((p, i) => ({ ...p, cached: have[i] })), fresh: 0, cached: have.filter(Boolean).length, jobs: [], lane: null, dryRun }; if (!force && upToDate(e, plan)) return { ...base, upToDate: true }; if (dryRun) return { ...base, upToDate: false }; @@ -409,12 +459,12 @@ export async function threadTake(project, e, opts = {}) { file: rel, engine: plan.engine, voice: plan.voice, seconds: mt.seconds ?? total, source: { kind: "tts", engine: plan.engine, voice: plan.voice, script: plan.want }, script: plan.want, at: new Date().toISOString(), - note: note ?? `thread read: ${plan.pieces.map((p) => `${p.role} (${p.engine && p.engine !== plan.engine ? `${p.engine}:` : ""}${p.voice})`).join(" + ")}`, + note: note ?? `thread read: ${plan.pieces.map((p) => `${p.role} (${p.take ? `take ${p.take.n}: ` : p.engine && p.engine !== plan.engine ? `${p.engine}:` : ""}${p.voice})`).join(" + ")}`, ...(Number.isFinite(mt.lufs) ? { lufs: mt.lufs } : {}), parts: meta, ...(plan.slurs ? { slurs: plan.slurs } : {}), ...(plan.lexicon.length ? { lexicon: plan.lexicon } : {}), - read: readRecordOf({ parents, skip, quoted, linked, readSeen, overrides, voice, speed }), + read: readRecordOf({ parents, skip, quoted, linked, readSeen, overrides, voice, speed, postTake }), }; const patch = { addTake: take, ...(plan.script ? { script: plan.script } : {}) }; const { result, editNotes } = await withEditNotes(project, async () => updatePostNarration(project.dir, e.id, patch, { token: await manifestToken(project.dir) })); @@ -446,19 +496,19 @@ export async function threadCommand(project, e, o) { } throw err; } - const pieces = r.plan.pieces.map((p) => ({ role: p.role, handle: p.handle, date: p.date, voice: p.voice, engine: p.engine, from: p.from, ...(p.speed !== undefined ? { speed: p.speed } : {}), ...(p.character ? { character: p.character } : {}), words: p.text.split(/\s+/).filter(Boolean).length, ...(p.lexicon.length ? { lexicon: p.lexicon } : {}) })); + const pieces = r.plan.pieces.map((p) => ({ role: p.role, handle: p.handle, date: p.date, voice: p.voice, engine: p.engine, from: p.from, ...(p.take ? { take: p.take } : {}), ...(p.speed !== undefined ? { speed: p.speed } : {}), ...(p.character ? { character: p.character } : {}), words: p.text.split(/\s+/).filter(Boolean).length, ...(p.lexicon.length ? { lexicon: p.lexicon } : {}) })); const guard = r.take ? await guardOf(project, e.id) : null; if (json) { out(JSON.stringify({ ok: true, id: e.id, upToDate: r.upToDate, dryRun: r.dryRun, engine: r.plan.engine, voice: r.plan.voice, pieces, skipped: r.plan.skipped, - parts: r.parts.map((p) => ({ role: p.role, voice: p.voice, engine: p.engine, ...(p.speed !== undefined ? { speed: p.speed } : {}), key: p.key, cached: p.cached, text: p.text })), + parts: r.parts.map((p) => ({ role: p.role, voice: p.voice, engine: p.engine, ...(p.speed !== undefined ? { speed: p.speed } : {}), ...(p.take ? { take: p.take, file: p.file } : { key: p.key }), cached: p.cached, text: p.text })), fresh: r.fresh, cached: r.cached, jobs: r.jobs, lane: r.lane, ...(r.take ? { take: r.take, pick: r.result.narration?.pick ?? null, token: r.result.token, snapshot: r.result.snapshot ?? null, guard } : {}), }, null, 2)); return 0; } out(`${e.id}: a thread read of ${pieces.length} piece(s), ${r.parts.length} part(s) (${r.cached} cached${r.dryRun ? `, ${r.parts.length - r.cached} to synthesize` : ""})`); - for (const p of pieces) out(` ${p.role.padEnd(9)} ${(p.engine !== r.plan.engine ? `${p.engine}:${p.voice}` : p.voice).padEnd(6)} ${p.from === "cast" ? "(cast) " : p.from === "item" ? `(the item's character: ${p.character}) ` : p.from === "project" && p.character ? `(this video's character: ${p.character}) ` : ""}${p.speed !== undefined ? `×${p.speed} ` : ""}${p.handle ? `@${p.handle}` : ""}${p.date ? ` ${p.date.slice(0, 16)}` : ""} ${p.words} words${p.lexicon ? ` (said: ${p.lexicon.map((x) => `${x.word} -> ${x.say}`).join(", ")})` : ""}`); + for (const p of pieces) out(` ${p.role.padEnd(9)} ${(p.take ? p.voice : p.engine !== r.plan.engine ? `${p.engine}:${p.voice}` : p.voice).padEnd(6)} ${p.take ? `(take ${p.take.n}: ${p.take.file}) ` : ""}${p.from === "cast" ? "(cast) " : p.from === "item" ? `(the item's character: ${p.character}) ` : p.from === "project" && p.character ? `(this video's character: ${p.character}) ` : ""}${p.speed !== undefined ? `×${p.speed} ` : ""}${p.handle ? `@${p.handle}` : ""}${p.date ? ` ${p.date.slice(0, 16)}` : ""} ${p.words} words${p.lexicon ? ` (said: ${p.lexicon.map((x) => `${x.word} -> ${x.say}`).join(", ")})` : ""}`); for (const s of r.plan.skipped) out(` (not read: ${s.role}${s.id ? ` ${s.id}` : ""} -- ${s.why})`); if (r.upToDate) { out(` up to date: the picked take already reads this, in these voices (--force makes it again)`); diff --git a/umtool/lib/report/postsCli.mjs b/umtool/lib/report/postsCli.mjs @@ -198,7 +198,7 @@ export const POSTS_USAGE = [ " none: the rule as it stands", ].join("\n"); -const VALUED = new Set(["--in-take", "--set", "--attach", "--flag", "--author", "--id", "--crop", "--since", "--until", "--replies", "--order", "--limit", "--after", "--script", "--note", "--voice", "--engine", "--speed", "--pick", "--linger", "--derive", "--op", "--pitch", "--semitones", "--delete", "--match", "--target", "--occurrence", "--at", "--scale", "--hold", "--lead", "--ease", "--highlight", "--worker", "--without", "--drop-parts", "--text", "--place", "--rewind", "--zone", "--gap", "--from-scale", "--color", "--outline", "--outline-width", "--size", "--face", "--sfx", "--volume", "--bar", "--bar-style", "--tempo-for", "--tempo", "--parts", "--stretch", "--yell-gain", "--yell-style", "--pause", "--revoice", "--say", "--xfade", "--splice", "--parents", "--skip-parent", "--voice-for", "--item", "--recording", "--as", "--label", "--out", "--trim-span"]); +const VALUED = new Set(["--in-take", "--set", "--attach", "--flag", "--author", "--id", "--crop", "--since", "--until", "--replies", "--order", "--limit", "--after", "--script", "--note", "--voice", "--engine", "--speed", "--pick", "--linger", "--derive", "--op", "--pitch", "--semitones", "--delete", "--match", "--target", "--occurrence", "--at", "--scale", "--hold", "--lead", "--ease", "--highlight", "--worker", "--without", "--drop-parts", "--text", "--place", "--rewind", "--zone", "--gap", "--from-scale", "--color", "--outline", "--outline-width", "--size", "--face", "--sfx", "--volume", "--bar", "--bar-style", "--tempo-for", "--tempo", "--parts", "--stretch", "--yell-gain", "--yell-style", "--pause", "--revoice", "--say", "--xfade", "--splice", "--parents", "--skip-parent", "--voice-for", "--item", "--recording", "--as", "--label", "--out", "--trim-span", "--post-take"]); /** The valued flags that may be given more than once (each value kept, in order). */ const MULTI = new Set(["--skip-parent", "--voice-for", "--trim-span"]); const SLUG_RE = /^[A-Za-z0-9._-]+$/; diff --git a/umtool/report-to-video/cast.mjs b/umtool/report-to-video/cast.mjs @@ -596,10 +596,18 @@ export function takeReads(e, take = playing(e)) { const parts = Array.isArray(take.parts) ? take.parts : []; if (parts.some((p) => typeof p?.role === "string" && typeof p?.voice === "string")) { const seen = new Map(); + const takes = Array.isArray(e?.narration?.takes) ? e.narration.takes : []; for (const p of parts) { if (typeof p?.role !== "string" || typeof p?.voice !== "string") continue; const key = p.role; if (seen.has(key)) continue; + // A part that IS another take of the item (a thread read's --post-take): read as that take reads. + if (typeof p.take === "string") { + const src = takes.find((x) => x !== take && isObj(x) && typeof x.file === "string" && (x.file === p.file || x.file.split("/").pop().replace(/\.wav$/i, "") === p.take)); + const r = src && !isThreadTake(src) ? takeReads(e, src)[0] : null; + seen.set(key, r ? { ...r, role: p.role, handle: handleOfRole(e, p.role) } : { handle: handleOfRole(e, p.role), role: p.role, engine: null, voice: p.voice, kind: "recorded" }); + continue; + } seen.set(key, { handle: handleOfRole(e, p.role), role: p.role, engine: str(p.engine) || str(take.engine) || null, voice: p.voice, kind: "tts" }); } return [...seen.values()]; diff --git a/umtool/report-to-video/post-narration.mjs b/umtool/report-to-video/post-narration.mjs @@ -198,7 +198,8 @@ const STEP_KEYS = new Set(["op", "engine", "voice", "pitch", "semitones", "param // `engine`: the part's own when it is not the take's (a cast voice that names its engine: postThreadRead.mjs). // `tempo`: the part's reading speed in the take's file against its first read (a `tempo` step's; absent: 1). // `speed`: the speed the part was synthesized at (its character's preset's, or the read's --speed; absent: 1). -const PART_KEYS = new Set(["n", "para", "text", "file", "start", "seconds", "gapBefore", "note", "at", "jobId", "role", "voice", "engine", "piece", "tempo", "speed"]); +// `take`: a thread read's part that IS one of the item's takes (postThreadRead.mjs --post-take): that take's id. +const PART_KEYS = new Set(["n", "para", "text", "file", "start", "seconds", "gapBefore", "note", "at", "jobId", "role", "voice", "engine", "piece", "tempo", "speed", "take"]); const VOICE_RE = /^[A-Za-z0-9][A-Za-z0-9_.+-]{0,63}$/; /** Orpheus's expressive tags (narration.mjs NARRATION_TAGS, the editor's list). */ const TAGS = ["laugh", "chuckle", "sigh", "cough", "sniffle", "groan", "yawn", "gasp"]; @@ -709,6 +710,7 @@ export function validatePostNarration(e) { if (p.tempo !== undefined && !numIn(p.tempo, POST_NARRATION_LIMITS.tempo)) errors.push(`${pw}.tempo must be ${POST_NARRATION_LIMITS.tempo.join("–")} (its reading speed in the take)`); if (p.role !== undefined && !(typeof p.role === "string" && /^(post|quoted|parent:\d|media:\d|linked:\d)$/.test(p.role))) errors.push(`${pw}.role must be post, quoted, parent:<i>, linked:<i> or media:<i> (the text it reads)`); if (p.engine !== undefined && !POST_NARRATION_ENGINES.includes(p.engine)) errors.push(`${pw}.engine must be one of ${POST_NARRATION_ENGINES.join(", ")}`); + if (p.take !== undefined && !(typeof p.take === "string" && n.takes.some((x) => x !== t && takeIdOf(x) === p.take))) errors.push(`${pw}.take must be the id of another of its takes (the take this part is)`); }); } });