commit d1b07dd1b5626136d137a3a9c00c6efd7a71f5bf parent bb735b4ef244f1aedb9ac9aec986f2c6d7d4e36d Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st> Date: Wed, 11 Nov 2026 19:09:49 -0500 umtool: review fixes -- an anonymous character's shown name is said to be umtool's own surfaces' (the on-screen card is not anonymised yet); a read's speed is the flag's, then the item's own, then its character's; a view written back with its preset changed keeps the change (the old way of setting a voice still counts); posts voices ls answers through this video's characters; a re-voice is asked at its part's speed; the record page keeps a recording with its character's trim; the Voices spec covers presets, this video's characters and an item's own Co-Authored-By: Claude <noreply@anthropic.com> Diffstat:
23 files changed, 252 insertions(+), 64 deletions(-)
diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md @@ -1,7 +1,7 @@ # Changelog ## [Unreleased] -- **umtool: a character is a preset, and a video can have characters of its own.** The operator wanted "a preset of voice and other settings" per character, applied to that author's posts, anonymous characters with their own profile per video, a pool reused across videos, and different presets for synthetic and recorded voices. A cast character now carries two presets. `synthetic` is the stock voice and its speed. `recorded` is what a recording of them is made into: the stock voice it is converted to, the engine, the pitch and semitones, whether it is cleaned first, whether its edges are trimmed and how much room is kept, and a one-line direction for the person reading, which is never sent to a model. An existing `cast.json` (`voice`, `convert`) reads as these presets, and the first write makes it version 2; `umtool cast undo` puts the old file back. A video's own characters live in `<project>/narration/characters.json`, for people who must not enter the pool. An anonymous one is shown and said under a shown name, "Anon 1", "Anon 2" by default. `narration/voices.json` keeps working and is not rewritten. A post item can name its own character (`umtool posts character <p> <item> <id>`, `--clear`). One read asks, first hit wins: the command's flags, the item's character, the video's character for the author, the cast's, the narrator's, the default. `umtool cast project <p>` prints the answer and its source for each author. A thread read ignored `--speed`: each part is now asked at its character's speed, and `--speed` sets every part. A recording made a read (`posts narrate --recording`) applies its character's clean and trim settings; `--clean`, `--no-clean`, `--trim` and `--no-trim` override them for one read. The Voices page edits both presets, keeps the video's own characters, and has "Add to the pool" and "Keep in this video only"; none of it needs an agent. New: `umtool cast set <id> --speed --enhance --trim --trim-pad --direction`, `umtool cast project <p> add|set|rm|undo|pool|keep`. A convert target is still always a stock synthetic voice, and the disclosure line is unchanged. Not built yet: the on-screen card does not use an anonymous character's shown name, and the record page does not show the direction (umtool/docs/knobs.md, "A character is a preset"). +- **umtool: a character is a preset, and a video can have characters of its own.** The operator wanted "a preset of voice and other settings" per character, applied to that author's posts, anonymous characters with their own profile per video, a pool reused across videos, and different presets for synthetic and recorded voices. A cast character now carries two presets. `synthetic` is the stock voice and its speed. `recorded` is what a recording of them is made into: the stock voice it is converted to, the engine, the pitch and semitones, whether it is cleaned first, whether its edges are trimmed and how much room is kept, and a one-line direction for the person reading, which is never sent to a model. An existing `cast.json` (`voice`, `convert`) reads as these presets, and the first write makes it version 2; `umtool cast undo` puts the old file back. A video's own characters live in `<project>/narration/characters.json`, for people who must not enter the pool. An anonymous one goes by a shown name, "Anon 1", "Anon 2" by default, on the Voices page, in `umtool cast project` and in a recording's note, and is refused the pool. `narration/voices.json` keeps working and is not rewritten. A post item can name its own character (`umtool posts character <p> <item> <id>`, `--clear`). One read asks, first hit wins: the command's flags, the item's character, the video's character for the author, the cast's, the narrator's, the default. `umtool cast project <p>` prints the answer and its source for each author. A thread read ignored `--speed`: each part is now asked at its character's speed, and `--speed` sets every part. A recording made a read (`posts narrate --recording`) applies its character's clean and trim settings; `--clean`, `--no-clean`, `--trim` and `--no-trim` override them for one read. The Voices page edits both presets, keeps the video's own characters, and has "Add to the pool" and "Keep in this video only"; none of it needs an agent. New: `umtool cast set <id> --speed --enhance --trim --trim-pad --direction`, `umtool cast project <p> add|set|rm|undo|pool|keep`. A convert target is still always a stock synthetic voice, and the disclosure line is unchanged. Not built yet: the on-screen card is not anonymised (a cut still shows the post's author for an anonymous character), and the record page does not show the direction (umtool/docs/knobs.md, "A character is a preset"). - **A converted read can follow your pitch.** Converting a recorded read to a stock voice threw the voice acting away. On 11 Nov, reads with a median pitch of 128, 212, 225 and 237 Hz all came out at 196–199 Hz, and a 152–321 Hz range came out as 165–240 Hz: both converters speak at the stock voice's own pitch. `pnpm ops voice-convert` now takes `"pitch"`: `target` (as before), `source` (the pitch you read at: raise your voice and the result rises) or `contour` (your rises and falls, moved as a whole to the stock voice's register), and `"semitones"` (-12 to 12) moves a followed pitch. The same read that came out at 197 Hz now comes out at 211 Hz with a 148–314 Hz range, against 212 Hz and 152–321 Hz read. `source` and `contour` are seed-vc's, on its f0-conditioned model: optional files, fetched by `archilyzer voice setup --engine seed-vc --with f0` (1.49 GB). An install without them converts as before, and a followed pitch is refused naming that command; openvoice refuses a pitch it cannot follow. It takes about 1.7 times as long, and more memory (5.8 GB at its peak on a take of 20 s or more). `settings.voice.convert.pitch` and `.semitones` are the defaults (`target`, 0). In umtool a character keeps its pitch in the cast (`umtool cast set <id> --convert-pitch contour --convert-semitones 2`, shown on Voices), and `--pitch` / `--semitones` on `posts narrate … --recording` or `--derive <n> --op convert` set it for one read; the post bench's **run AI on take** has the same two controls for a convert on seed-vc, starting from the character's. The disclosure line is unchanged. - **The dashboard says when a media drive is not answering, slow, or not mounted.** A stalled external drive used to show only on `/storage` and in channel badges, so the editor looked broken with nothing on its front page saying why. The dashboard now opens with one card per storage location in trouble: **not answering** (an alert: pages and polls skip the drive, and its channels' jobs wait until it answers), **answering slowly** (everything still runs, just late), or **not mounted** (only when some channel's media is on it). Each card links to `/storage` and to that location's channels. On `/storage` each location has a **Drive** line that says when the drive last answered and how long it took (for example "answering — 12 ms (a read in the editor), last at 11:42"), and a **slow** chip appears next to Available when two reads in a row on it take half the 3-second limit or more (one long read is not enough). `pnpm ops get storage` reports the same for each location under `rows[].drive`: `state` (`ok`, `slow`, `stalled` or `unmounted`), `since`, `lastOkAt`, `latencyMs`, the cause and the one-line text. - **A transcription or backfill run waits while its channel's media drive is not answering.** Before, a run that started while the drive answered kept going after the drive stalled. Each next video asked the stalled drive for its audio, waited about 30 seconds and failed. Now the run pauses at the next video and says so in its log ("Holding: the media drive "…" is not answering (since 11:35) — no new transcription starts until it answers again"), then resumes by itself when the drive answers. If it has held for 5 minutes, the run checks the drive itself from a separate process, and it logs that it is still holding every 10 minutes. A run also follows a channel that is moved to another drive while it runs. A video that is refused because the drive is not answering is skipped, not added to the channel's failed-transcriptions list, and is transcribed on a later run. A downloaded video is also not moved into a saved-video store on a drive that is not answering. It stays in the video's folder, and a later pass stores it. diff --git a/umtool/app/api/report/post-narration/route.ts b/umtool/app/api/report/post-narration/route.ts @@ -22,7 +22,7 @@ import { itemReadVoice } from "@/lib/report/readVoice.mjs"; import { projectRedaction } from "@/lib/report/postRedaction.mjs"; import { spokenRead } from "umtool-report-to-video/post-redact"; import { recordedPresetOf, shownNameOf } from "umtool-report-to-video/cast"; -import { readLayers } from "@/lib/report/characterLayers.mjs"; +import { readLayers, recordedTrimFor } from "@/lib/report/characterLayers.mjs"; import { derivePitchOf, deriveRefusalOf, stepPitchOf } from "@/lib/report/derivePitch.mjs"; export const dynamic = "force-dynamic"; @@ -255,8 +255,9 @@ async function postHere(request: Request) { const dir = path.join(r.project.dir, ...takesDirOf(pid).split("/")); await mkdir(dir, { recursive: true }); const rel = takeFileOf(pid, nextTakeNumber(e, await readdir(dir).catch(() => [])), engine, voice); - // Its speed: the one asked for, else its character's (the synthetic preset's that answered for the voice). - const askedSpeed = body.speed === undefined || body.speed === null ? (said as { speed?: number }).speed : Number(body.speed); + // Its speed: the one asked for, else the item's own (`narration.speed`), else its character's (the synthetic + // preset's that answered for the voice) -- makeTake's order. + const askedSpeed = body.speed === undefined || body.speed === null ? (e.narration as { speed?: number } | undefined)?.speed ?? (said as { speed?: number }).speed : Number(body.speed); const speed = askedSpeed === undefined || askedSpeed === null || engine === "orpheus" ? undefined : Number(askedSpeed); // What the voice SAYS: the script with every redacted term left out (post-redact.mjs), each slur as the cut's // filter has it (post-slurs.mjs) and the project's pronunciation lexicon applied (post-say.mjs); the script is kept as written. The bench cannot word-time a take as it is made, @@ -400,7 +401,8 @@ async function record(request: Request) { } const script = form.get("script"); const note = form.get("note"); - const kept = await keepRecording(r.project, e, parts, { label, manifest: m, note: note ? String(note) : null, script: script === null ? null : String(script) }); + // Its character's recorded preset says whether its edges are trimmed, and the room kept (characterLayers.mjs). + const kept = await keepRecording(r.project, e, parts, { label, manifest: m, note: note ? String(note) : null, script: script === null ? null : String(script), trim: await recordedTrimFor(r.project.dir, e) }); return Response.json({ ok: true, take: kept.take, gain: kept.gain, target: kept.target, token: kept.result.token, entry: kept.result.entry }, { headers: noStore }); } catch (err) { return fail(err); diff --git a/umtool/app/api/report/voices/route.ts b/umtool/app/api/report/voices/route.ts @@ -251,7 +251,7 @@ export async function POST(request: Request) { } if (op === "character-keep") { const who = s("who"); - if (!/^@?[A-Za-z0-9_.-]{1,64}$/.test(who)) return Response.json({ error: "keep takes a cast character's id, or an author (@handle)" }, { status: 400 }); + if (!/^@?[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$/.test(who)) return Response.json({ error: "keep takes a cast character's id, or an author (@handle)" }, { status: 400 }); return answer(await cli(["project", project.id, "keep", who, ...(b.anonymous === true ? ["--anonymous"] : []), ...(s("shown") ? ["--shown", s("shown")] : [])])); } if (op === "item-character") { diff --git a/umtool/components/projects/CharacterPresets.tsx b/umtool/components/projects/CharacterPresets.tsx @@ -14,7 +14,7 @@ import { cn } from "@/lib/utils"; // and semitones, cleaned or not, its edges trimmed or not and the room kept, and a DIRECTION // -- one line for the person reading, never sent to a model) -- the cast's or this video's own // ProjectCharacters THIS VIDEO's OWN characters (narration/characters.json): people who must not enter the pool -// (anonymous ones are shown and said under "Anon 1" …), add one, remove one, undo, "Add to the +// (anonymous ones go by "Anon 1" … here and in recording notes; the cut's card is not anonymised yet), add one, remove one, undo, "Add to the // pool"; and the post items that name a character of their own // --------------------------------------------------------------------------- @@ -151,7 +151,7 @@ export function PresetEditor({ <input data-preset-name="" value={f.name} onChange={(e) => set("name", e.target.value)} maxLength={80} className={cn(input, "w-44")} /> </label> {c.anonymous && ( - <label className={lab} title="what the card and the read call them: never their own name"> + <label className={lab} title="the name it goes by on this page, in `umtool cast project` and in a recording's note — the cut's on-screen card is not anonymised yet: it still shows the post's author"> <span className="text-muted">shown as</span> <input data-preset-shown="" value={f.shown} onChange={(e) => set("shown", e.target.value)} maxLength={80} className={cn(input, "w-32")} /> </label> @@ -250,7 +250,7 @@ export function ProjectCharacters({ <section data-project-characters={own.length}> <h2 className="micro mb-1.5"> this video's own characters · {own.length} - <span className="ml-2 normal-case tracking-normal text-muted">people who stay out of the pool — an anonymous one is shown and said under its shown name, never its own</span> + <span className="ml-2 normal-case tracking-normal text-muted">people who stay out of the pool — an anonymous one goes by its shown name here and in recording notes; the cut's on-screen card is not anonymised yet</span> </h2> {charactersError && <p className="m-0 mb-1 text-doubt-text" data-project-characters-error="">this video's characters are not read: {charactersError}</p>} {own.length > 0 && ( @@ -260,7 +260,7 @@ export function ProjectCharacters({ <tr key={c.id} data-project-character={c.id} className={cn(open === c.id && "bg-panel-2")}> <td className={cell}> <span className="font-medium">{c.anonymous ? c.shown : c.name}</span> - {c.anonymous && <span className="ml-1.5 rounded-[3px] border border-seam-2 px-1 text-[10.5px] text-doubt-text" title={`anonymous: shown and said as “${c.shown}” (your own label: ${c.name})`}>anonymous</span>} + {c.anonymous && <span className="ml-1.5 rounded-[3px] border border-seam-2 px-1 text-[10.5px] text-doubt-text" title={`anonymous: “${c.shown}” on this page, in cast project and in recording notes (your own label: ${c.name}) — the cut's on-screen card still shows the post's author`}>anonymous</span>} <span className="ml-1.5 font-mono text-[11px] text-muted">{(c.handles ?? []).map((h) => `@${h}`).join(" ")}</span> </td> <td className={cn(cell, "font-mono")}> diff --git a/umtool/components/projects/VoicesPanel.tsx b/umtool/components/projects/VoicesPanel.tsx @@ -302,7 +302,7 @@ export default function VoicesPanel({ project, posts, initialWho = null }: { pro <span className="ml-1.5 font-mono text-[11px] text-muted">{c.handles.map((h) => `@${h}`).join(" ")}</span> {c.character && c.character.layer !== "project" && <span className="ml-1.5 rounded-[3px] border border-seam-2 px-1 text-[10.5px] text-signal-text" title="in the cast: the same voice in every project">cast</span>} {c.character?.layer === "project" && <span className="ml-1.5 rounded-[3px] border border-seam-2 px-1 text-[10.5px] text-text-2" data-voices-layer="project" title="a character of this video only">this video</span>} - {c.character?.anonymous && <span className="ml-1.5 rounded-[3px] border border-seam-2 px-1 text-[10.5px] text-doubt-text" title={`anonymous: shown and said as “${c.character.shown}”, never its own name`}>anonymous</span>} + {c.character?.anonymous && <span className="ml-1.5 rounded-[3px] border border-seam-2 px-1 text-[10.5px] text-doubt-text" title={`anonymous: “${c.character.shown}” on this page, in cast project and in recording notes — the cut's on-screen card is not anonymised yet: it still shows the post's author`}>anonymous</span>} </td> <td className={cell}> <span className="font-mono text-[12px]" data-voice-now={c.voice.spec}>{pretty(c.voice.spec)}</span> diff --git a/umtool/docs/cli.md b/umtool/docs/cli.md @@ -24,7 +24,7 @@ Inbox cannot disagree about what is wrong with one. | `links <project> [--json] [--fix]` | do the clip QRs open on their sites? `corpus.json` → the channel's manifest → `slugToPage` → the shard's record, one request at a time, shards from the cue cache; recorded in `out/links.json`, which `check` reads (`link-dead` blocking, `links-unverified`, `links-unchecked`); `--fix` rewrites a Twitch id the site serves as `v<id>`, and a Rumble folder id (the URL slug) as the embed id the site serves (the clip gets `siteVideo`); **exit 1** when a link is dead ([knobs.md](knobs.md#do-the-qr-links-open)). The same record dates each site's deploy: a cited video newer than it is `site-deploy-behind` ([knobs.md](knobs.md#the-sites-the-links-depend-on)) | | `cast [ls] \| add <id> --name … --voice <engine:voice> [--handles a,b] [--speakers …] [--speed s] [--convert-engine e] [--convert-voice v] [--convert-pitch target\|source\|contour] [--convert-semitones n] [--enhance on\|off] [--trim on\|off] [--trim-pad ms] [--direction "…"] [--narrator] \| set <id> … \| rm <id> \| undo [--json]` | **THE CAST** (`<reports>/.umtool/cast.json`, [knobs.md](knobs.md#the-cast-each-characters-voice-in-every-project-and-the-voices-page)): the characters across projects, one writer, an undo point a write. **A character is a PRESET**, two of them ([knobs.md](knobs.md#a-character-is-a-preset)): `synthetic` -- the STOCK voice it reads in (`--voice`) and its speed (`--speed` 0.5–2; Orpheus has none) -- and `recorded` -- what a recording of them is made into: the stock voice (`--convert-voice`; a file or a recording is refused), the engine, the **pitch** the converted read lands on (`--convert-pitch`: `target` the stock voice's own, `source` the pitch it was read at, `contour` the read's rises and falls at the stock voice's register; `--convert-semitones` -12…12 moves a followed one), whether it is cleaned first (`--enhance`), its edges trimmed to speech (`--trim`, `--trim-pad` the ms kept either side) and a `--direction` (one line for the person reading, never sent to a model). `set` lays the flags given over the presets; `default` for one takes that key off; `--no-convert`, `--no-speed`. A version 1 file (`voice`, `convert` at a character's top) reads as these presets and the first write makes it version 2 (`undo` puts the old file back). A followed pitch on an engine that has none, semitones with nothing followed, a speed or a pad out of range: **exit 1** | | `cast project <project> [--json]` · `cast use <project> <character\|@handle> <voice> [--everywhere]` · `cast reread <project> <character> [--dry-run]` | a project's characters: each one's voice now (and speed) and **where it comes from** -- the chain one read asks, first hit wins: the command's flags, the item's own character (`posts character`), this video's character for the author (then its voice map), the cast's, the narrator's, the default -- what a recording of them is made into, its stale reads; this video's own characters; the items that name their own. `use`: the voice for this project (its own character's when it has one for them, else the voice map) or everywhere, and the re-reads that asks for | -| `cast project <project> add <id> [--name "…"] [--voice <engine:voice>] [--handles a,b] [--anonymous [--shown "…"]] [the preset flags]` · `set <id> … [--no-voice] [--no-anonymous]` · `rm <id>` · `undo` · `pool <id>` · `keep <character\|@handle> [--anonymous]` `[--json]` | **THIS VIDEO's OWN CHARACTERS** (`<project>/narration/characters.json`, [knobs.md](knobs.md#this-videos-own-characters-and-an-items-own)): the cast's shape and the cast's writer (a token, an undo point a write, atomic, a broken file never overwritten), for people who must not enter the pool. `--anonymous`: shown on screen and said under a **shown name**, never its own (`--shown`; default the next of `Anon 1`, `Anon 2` …). `--voice` is optional here: a character with none leaves the voice to the layers under it. `narration/voices.json` keeps working under it (a handle in it reads as a character with only a synthetic voice) and is never rewritten by these. `pool <id>` (**Add to the pool**) moves one into the cast -- an anonymous one, or an id the cast has, is refused; `keep` (**Keep in this video only**) copies a cast character here (its presets changed for this video alone), or gives an author with no character one, in the voice they read in now. A refusal: **exit 1**, nothing written | +| `cast project <project> add <id> [--name "…"] [--voice <engine:voice>] [--handles a,b] [--anonymous [--shown "…"]] [the preset flags]` · `set <id> … [--no-voice] [--no-anonymous]` · `rm <id>` · `undo` · `pool <id>` · `keep <character\|@handle> [--anonymous]` `[--json]` | **THIS VIDEO's OWN CHARACTERS** (`<project>/narration/characters.json`, [knobs.md](knobs.md#this-videos-own-characters-and-an-items-own)): the cast's shape and the cast's writer (a token, an undo point a write, atomic, a broken file never overwritten), for people who must not enter the pool. `--anonymous`: it goes by a **shown name** (`--shown`; default the next of `Anon 1`, `Anon 2` …) on the Voices page, in `cast project` and in a recording's note, and never enters the pool; **the on-screen card is not anonymised yet** (it still shows the post's author). `--voice` is optional here: a character with none leaves the voice to the layers under it. `narration/voices.json` keeps working under it (a handle in it reads as a character with only a synthetic voice) and is never rewritten by these. `pool <id>` (**Add to the pool**) moves one into the cast -- an anonymous one, or an id the cast has, is refused; `keep` (**Keep in this video only**) copies a cast character here (its presets changed for this video alone), or gives an author with no character one, in the voice they read in now. A refusal: **exit 1**, nothing written | | `cast audition <character\|@handle> --voices a,b,… [--project <p>] [--text "…" \| --item <id> \| --line <n> \| --stock] [--no-score \| --score-only] [--json] [--progress ndjson]` | **AN AUDITION**: one line read by 2-6 stock voices through the editor's tts op, levelled to -20 LUFS in `<p>/narration/auditions/` (cached), scored for closeness to the character's real voice (`speakers.json`; TitaNet, local) | | `speaker-check <project> [--clip <id> …] [--json] [--progress ndjson]` · `--set 'Name=<clip>,<channel>/<id>,channel:<slug>'` · `--remove <name>` · `--list` | which of the project's **named voices** (`speakers.json`) each clip is: TitaNet-small, local, against each voice's robust centroid → `<project>/speaker-check.json` (merged); the walk's **Speaker:** badge and **Check speaker** ([report-video.md](report-video.md#the-speaker-check-on-the-walk-which-of-several-voices)) | | `quote-check <project> [--clips a,b] [--pad S] [--json]` · `quote-check <project> --status` | **is each clip's quote in the seconds it plays?** The cut ±15 s of the source the render would cut it from, transcribed by the editor (`pnpm ops transcribe`, words on — its transcription lane), the quote found in those words and in the cues: `ok`, `moved` (heard more than 0.5 s from where the cues have it), `not-found`; rows in `quote-check.json`, stale when the cut or the quote changes; `check` blocks on `moved`/`not-found` (`clip-quote-moved`, `clip-quote-missing`), a take refuses them, `prep --status` counts them ([knobs.md](knobs.md#the-quote-check-is-the-quote-where-the-clip-plays)) | diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -1284,8 +1284,8 @@ names them; `--voice-for <handle>=<voice>` overrides it for one read, `--voice` answers, the post it quotes, the posts its words link to and his words, in DATE order (`post-thread.mjs` `chronoPieces`), each piece cleaned to be spoken (a context post's paraphrase when it has one), each in its author's voice and **at its character's speed** (its synthetic preset's, [below](#a-character-is-a-preset); `--speed <s>`: every -part at that one, recorded on the take's `read`; Orpheus has no speed and is asked none; his own words with no preset: -the item's `narration.speed`). Each part (a paragraph; a long one split at a sentence end) is synthesized ONCE through +part at that one, recorded on the take's `read`; his own words at the item's `narration.speed` when it has one -- the +flag, then the item's own, then the character's; Orpheus has no speed and is asked none). Each part (a paragraph; a long one split at a sentence end) is synthesized ONCE through the editor's tts op (a job on its queue, paced; the GPU and the heavy slot are the editor's) into `narration/parts-cache/<sha1(voice|text)>.wav` (a part at a speed: `…|x<speed>`, so the same words at another speed are another part; `parts[i].speed` says it) and reused by every read after -- a re-read after one word changed asks for @@ -1333,7 +1333,9 @@ their REAL voice goes by in a project's `speakers.json` -- a reference to compar default character). **A version 1 file** kept the voice in `voice` and the convert entry in `convert` at the character's top: those keys are READ as the presets (`upgradeCharacter`), a reader is handed a view that still says `voice` and `convert` (`charactersOf`), and the first write makes the file version 2 -- whose undo point is the -version 1 text, so `umtool cast undo` puts the old file back as it was. +version 1 text, so `umtool cast undo` puts the old file back as it was. **Before rolling umtool back**, undo the +cast change: `cast.json` becomes version 2 at the first write, and an older umtool build then reads the cast as empty +(and refuses to write it). **Every read asks one chain, first hit wins** (`post-say.mjs` `voiceSourceOf` / `resolvePieceVoice` for a synthesized read; `cast.mjs` `characterForRead` for a recording): **the command's flags** (`--voice-for`, `--voice`, `--speed`, @@ -1399,7 +1401,7 @@ human-filtered voices". A character carries two, picked by how the read is made: - **`synthetic`** -- a read the editor synthesizes: `voice` (`<engine>:<voice>`, a stock voice) and `speed` (0.5–2, the tts op's; absent: 1). Speed is the only parameter the tts op takes beside the voice (Orpheus's emotion is in the script, its `<sigh>` `<laugh>` tags; Orpheus has no speed and is asked none). It reaches a single take, the bench's - Re-take and every part of a thread read; `--speed` on the command wins. + Re-take and every part of a thread read; `--speed` on the command wins, then the item's own `narration.speed`. - **`recorded`** -- a recording of them made their read: `convert` `{engine, voice, pitch, semitones}` (the target is ALWAYS a stock synthetic voice: validation refuses a file, a path or a recording, in the cast and in a project's own characters), `enhance` (cleaned first by the editor's voice-enhance; absent: yes), `trim` `{on, padMs}` (its @@ -1415,8 +1417,10 @@ synthetic voice), never from a preset. **A project's own characters** (`<project>/narration/characters.json`, format `umtool-project-characters`; the cast's writer in `castStore.mjs` -- `projectCharactersWrite`: a token, an undo point a write in `characters.undo.json`, atomic, a broken file never overwritten) are the cast's shape, for people who must **not enter the pool**: they live -in that video only. One may be **`anonymous: true`** with a **`shown`** name -- what the read and the on-screen card -call them, never their own name; the default is the next unused of **"Anon 1", "Anon 2" …** (`cast.mjs` +in that video only. One may be **`anonymous: true`** with a **`shown`** name -- what the Voices page, `umtool cast +project` and a recording's note call them, never their own name. **The on-screen card is NOT anonymised yet**: a cut +still shows the post's author, so an anonymous character keeps someone out of the pool and off umtool's own surfaces, +not off the video. The default is the next unused of **"Anon 1", "Anon 2" …** (`cast.mjs` `ANON_NAME_PATTERN`, the one place the pattern is written). A preset is optional here: a character with no synthetic voice leaves the voice to the layers under it. It has no narrator (the narrator is the cast's). `narration/voices.json` keeps working under it and is never rewritten by these commands. diff --git a/umtool/e2e/voices.spec.ts b/umtool/e2e/voices.spec.ts @@ -19,6 +19,9 @@ import * as urls from "./urls"; // Use for this project -> the project's voice map; the lint's override note // a recording dropped on an item -> kept, converted to the character's stock voice // the cast: remove, undo +// a character's presets (CharacterPresets.tsx): Keep in this video only -> its voice, speed, clean, direction saved; +// an anonymous character of this video ("Anon 1"), never offered -- and refused -- the pool; an item read as a +// character of its own, and cleared // --------------------------------------------------------------------------- const HERE = path.dirname(fileURLToPath(import.meta.url)); @@ -27,6 +30,8 @@ const P = "reports/voices-fixture"; const DIR = path.join(FIXTURE, "reports", "voices-fixture"); const MANIFEST = path.join(DIR, "video.manifest.json"); const CAST = path.join(FIXTURE, ".umtool", "cast.json"); +// This video's own characters (lib/report/castStore.mjs projectCharactersWrite). +const CHARACTERS = path.join(DIR, "narration", "characters.json"); const SHOTS = process.env.E2E_VOICES_SHOTS ?? null; const REC = path.join(FIXTURE, "voices-recording.wav"); @@ -50,7 +55,7 @@ test.beforeAll(() => { }); const reset = () => { copyFileSync(`${MANIFEST}.pristine`, MANIFEST); - for (const f of [CAST, CAST.replace(/\.json$/, ".undo.json"), path.join(DIR, "narration", "voices.json")]) rmSync(f, { force: true }); + for (const f of [CAST, CAST.replace(/\.json$/, ".undo.json"), path.join(DIR, "narration", "voices.json"), CHARACTERS, CHARACTERS.replace(/\.json$/, ".undo.json")]) rmSync(f, { force: true }); for (const d of ["auditions", "uploads", "parts-cache"]) rmSync(path.join(DIR, "narration", d), { recursive: true, force: true }); for (const id of ["1", "2", "3"]) { const dir = path.join(DIR, "narration", "posts", id); @@ -124,8 +129,10 @@ test("each character's voice and where it comes from; an audition side by side w const confirm = box.locator("[data-reread-confirm]"); await expect(confirm).toHaveAttribute("data-reread-confirm", "1"); await expect(confirm.locator('[data-reread-item="p-1"]')).toContainText("post orpheus · zac → kokoro · am_michael"); - const cast = JSON.parse(readFileSync(CAST, "utf8")) as { characters: { id: string; voice: string; handles: string[] }[] }; - expect(cast.characters).toEqual([{ id: "hostman", name: "Host Man", handles: ["hostman"], voice: "kokoro:am_michael" }]); + // The cast on disk is version 2: the voice is the character's synthetic preset. + const cast = JSON.parse(readFileSync(CAST, "utf8")) as { version: number; characters: { id: string; synthetic: { voice: string }; handles: string[] }[] }; + expect(cast.version).toBe(2); + expect(cast.characters).toEqual([{ id: "hostman", name: "Host Man", handles: ["hostman"], synthetic: { voice: "kokoro:am_michael" } }]); await expect(page.locator('[data-voices-character="hostman"]')).toHaveAttribute("data-voice-from", "cast"); await expect(page.locator('[data-voices-character="hostman"] [data-voice-drift]')).toHaveAttribute("data-voice-drift", "1"); await shot(page, "3-reread-confirm", confirm); @@ -202,6 +209,74 @@ test("a recording dropped on an item: kept as recorded, converted to the charact expect(conv.voice).toBe("orpheus:zac"); }); +test("a character's presets; this video's own characters -- an anonymous one is Anon 1 and never enters the pool; an item's own character", async ({ page }) => { + type Own = { id: string; name: string; anonymous?: boolean; shown?: string; handles?: string[]; synthetic?: { voice?: string; speed?: number }; recorded?: { enhance?: boolean; direction?: string } }; + const own = () => (JSON.parse(readFileSync(CHARACTERS, "utf8")) as { format: string; characters: Own[] }).characters; + const itemCharacter = (id: string) => (entry(id).narration as { character?: string } | undefined)?.character ?? null; + await page.goto(urls.voicesHref(P)); + const host = page.locator('[data-voices-character="@hostman"]'); + await expect(host).toBeVisible({ timeout: 30_000 }); + // Keep in this video only: an author with no character gets one here, in the voice they read in now; its presets open. + await host.locator("[data-character-keep]").click(); + const ed = page.locator('[data-preset-editor="hostman"]'); + await expect(ed).toHaveAttribute("data-preset-scope", "project"); + expect(own().map((c) => [c.id, c.handles, c.synthetic?.voice])).toEqual([["hostman", ["hostman"], "orpheus:zac"]]); + const row = page.locator('[data-voices-character="hostman"]'); + await expect(row).toHaveAttribute("data-voice-from", "project"); + await expect(row.locator('[data-voices-layer="project"]')).toBeVisible(); + // Both presets, edited by hand: a Kokoro voice at 1.1, not cleaned, a direction for the reader. + await ed.locator('[data-preset-engine="voice"]').selectOption("kokoro"); + await ed.locator("[data-preset-speed]").fill("1.1"); + await ed.locator("[data-preset-enhance]").uncheck(); + await ed.locator("[data-preset-direction]").fill("higher, brisk, amused"); + await ed.locator("[data-preset-save]").click(); + await expect(page.locator("[data-voices-status]")).toContainText("its presets saved for this video only"); + const saved = own()[0]; + expect(saved.synthetic?.voice).toMatch(/^kokoro:/); + expect(saved.synthetic?.speed).toBe(1.1); + expect(saved.recorded).toEqual({ enhance: false, direction: "higher, brisk, amused" }); + await expect(row.locator("[data-voice-speed]")).toHaveAttribute("data-voice-speed", "1.1"); + await expect(page.locator('[data-project-character="hostman"]')).toContainText("not cleaned"); + await shot(page, "7-presets", ed); + // An anonymous character of this video's, for the guest: shown as Anon 1. + const mine = page.locator("[data-project-characters]"); + await mine.locator("[data-project-character-id]").fill("anon-a"); + await mine.locator("[data-project-character-handles]").fill("guest"); + await mine.locator("[data-project-character-anonymous]").check(); + await mine.locator("[data-project-character-add-go]").click(); + const anon = page.locator('[data-project-character="anon-a"]'); + await expect(anon).toContainText("Anon 1"); + await expect(anon).toContainText("anonymous"); + expect(own().find((c) => c.id === "anon-a")).toMatchObject({ anonymous: true, shown: "Anon 1", handles: ["guest"] }); + await expect(page.locator('[data-voices-character="anon-a"]')).toContainText("Anon 1"); + // It is never offered the pool -- and the route refuses it (the CLI's words), the cast untouched. + await expect(anon.locator("[data-character-pool]")).toHaveCount(0); + await expect(page.locator('[data-project-character="hostman"] [data-character-pool]')).toBeVisible(); + const refused = await page.evaluate(async (project) => { + const r = await fetch("/api/report/voices", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ project, op: "character-pool", id: "anon-a" }) }); + return { status: r.status, error: ((await r.json()) as { error?: string }).error ?? "" }; + }, P); + expect(refused.status).toBe(400); + expect(refused.error).toContain("anon-a is anonymous: it stays in this video"); + expect(existsSync(CAST)).toBe(false); + await shot(page, "8-own-characters", mine); + // An item read as a character of its own, then by its author's handle again. + await mine.locator("[data-item-character-item]").selectOption("p-3"); + await mine.locator("[data-item-character-pick]").selectOption("hostman"); + await mine.locator("[data-item-character-set]").click(); + const it = mine.locator('[data-item-character="p-3"]'); + await expect(it).toHaveAttribute("data-item-character-found", "yes"); + await expect(it).toContainText("this video's"); + expect(itemCharacter("p-3")).toBe("hostman"); + await it.locator("[data-item-character-clear]").click(); + await expect(it).toHaveCount(0); + expect(itemCharacter("p-3")).toBe(null); + // Undo: the last change to this video's characters (the anonymous one added) is taken back. + await mine.locator("[data-project-characters-undo]").click(); + await expect(anon).toHaveCount(0); + expect(own().map((c) => c.id)).toEqual(["hostman"]); +}); + test("the Cut tab's Reads and voices reaches the Voices page", async ({ page }) => { await page.goto(urls.projectHref(P, { tab: "cut" })); const { openPanel } = await import("./panels"); diff --git a/umtool/lib/cli/groups.mjs b/umtool/lib/cli/groups.mjs @@ -79,7 +79,7 @@ export const GROUPS = [ ["`cast project <project> [--json]` · `cast use <project> <character\\|@handle> <voice> [--everywhere]` · `cast reread <project> <character> [--dry-run]`", "a project's characters: each one's voice now (and speed) and **where it comes from** -- the chain one read asks, first hit wins: the command's flags, the item's own character (`posts character`), this video's character for the author (then its voice map), the cast's, the narrator's, the default -- what a recording of them is made into, its stale reads; this video's own characters; the items that name their own. `use`: the voice for this project (its own character's when it has one for them, else the voice map) or everywhere, and the re-reads that asks for"], ["`cast project <project> add <id> [--name \"…\"] [--voice <engine:voice>] [--handles a,b] [--anonymous [--shown \"…\"]] [the preset flags]` · `set <id> … [--no-voice] [--no-anonymous]` · `rm <id>` · `undo` · `pool <id>` · `keep <character\\|@handle> [--anonymous]` `[--json]`", - "**THIS VIDEO's OWN CHARACTERS** (`<project>/narration/characters.json`, [knobs.md](knobs.md#this-videos-own-characters-and-an-items-own)): the cast's shape and the cast's writer (a token, an undo point a write, atomic, a broken file never overwritten), for people who must not enter the pool. `--anonymous`: shown on screen and said under a **shown name**, never its own (`--shown`; default the next of `Anon 1`, `Anon 2` …). `--voice` is optional here: a character with none leaves the voice to the layers under it. `narration/voices.json` keeps working under it (a handle in it reads as a character with only a synthetic voice) and is never rewritten by these. `pool <id>` (**Add to the pool**) moves one into the cast -- an anonymous one, or an id the cast has, is refused; `keep` (**Keep in this video only**) copies a cast character here (its presets changed for this video alone), or gives an author with no character one, in the voice they read in now. A refusal: **exit 1**, nothing written"], + "**THIS VIDEO's OWN CHARACTERS** (`<project>/narration/characters.json`, [knobs.md](knobs.md#this-videos-own-characters-and-an-items-own)): the cast's shape and the cast's writer (a token, an undo point a write, atomic, a broken file never overwritten), for people who must not enter the pool. `--anonymous`: it goes by a **shown name** (`--shown`; default the next of `Anon 1`, `Anon 2` …) on the Voices page, in `cast project` and in a recording's note, and never enters the pool; **the on-screen card is not anonymised yet** (it still shows the post's author). `--voice` is optional here: a character with none leaves the voice to the layers under it. `narration/voices.json` keeps working under it (a handle in it reads as a character with only a synthetic voice) and is never rewritten by these. `pool <id>` (**Add to the pool**) moves one into the cast -- an anonymous one, or an id the cast has, is refused; `keep` (**Keep in this video only**) copies a cast character here (its presets changed for this video alone), or gives an author with no character one, in the voice they read in now. A refusal: **exit 1**, nothing written"], ["`cast audition <character\\|@handle> --voices a,b,… [--project <p>] [--text \"…\" \\| --item <id> \\| --line <n> \\| --stock] [--no-score \\| --score-only] [--json] [--progress ndjson]`", "**AN AUDITION**: one line read by 2-6 stock voices through the editor's tts op, levelled to -20 LUFS in `<p>/narration/auditions/` (cached), scored for closeness to the character's real voice (`speakers.json`; TitaNet, local)"], ], diff --git a/umtool/lib/cli/verbs.mjs b/umtool/lib/cli/verbs.mjs @@ -150,7 +150,7 @@ export const VERBS = Object.freeze([ // This video's OWN characters (<project>/narration/characters.json; castStore.mjs: one writer, an undo point a write). form("cast project add", "project", "a character of this video only (anonymous: shown under Anon 1 …)", [ project(), arg("id"), opt("--name", { help: "required unless --anonymous" }), opt("--voice", { help: "engine:voice (none: the layers under it)" }), opt("--handles", { help: "a,b" }), - bool("--anonymous", "shown and said under a shown name, never its own"), opt("--shown", { help: "the shown name (default: the next Anon n)" }), ...presetArgs(), opt("--note"), + bool("--anonymous", "goes by a shown name on umtool's pages; never enters the pool (the cut's card is not anonymised yet)"), opt("--shown", { help: "the shown name (default: the next Anon n)" }), ...presetArgs(), opt("--note"), ], { shape: "cast project <project> add <id>" }), form("cast project set", "project", "change a character of this video's", [ project(), arg("id"), opt("--name"), opt("--voice", { help: "engine:voice" }), opt("--handles"), opt("--shown"), ...presetArgs(), opt("--note"), opt("--add-handle"), opt("--remove-handle"), diff --git a/umtool/lib/report/castCli.mjs b/umtool/lib/report/castCli.mjs @@ -69,8 +69,9 @@ export const CAST_USAGE = [ " project, cast, narrator, default), its speed, its picked reads in another voice (drift: re-read them), the cast", " voices the project overrides, its reference; this video's own characters; the items that name their own.", " project <p> add|set|rm|undo: THIS VIDEO's OWN characters (<p>/narration/characters.json, one writer, an undo", - " point per write) -- the same shape, for people who must not enter the pool. --anonymous: shown on screen and", - ` said under a shown name, never its own (--shown; default the next of "${ANON_NAME_PATTERN.replace("{n}", "1")}", "${ANON_NAME_PATTERN.replace("{n}", "2")}" …). --voice is optional`, + " point per write) -- the same shape, for people who must not enter the pool. --anonymous: it goes by a SHOWN NAME", + ` (--shown; default the next of "${ANON_NAME_PATTERN.replace("{n}", "1")}", "${ANON_NAME_PATTERN.replace("{n}", "2")}" …) on the Voices page, in cast project and in a recording's note, and never`, + " enters the pool. The cut's ON-SCREEN CARD IS NOT ANONYMISED YET: it still shows the post's author. --voice is optional", " here: a character with none leaves the voice to the layers under it. pool <id>: it moves into the cast (an", " anonymous one is refused). keep <character|@handle>: a cast character copied here (its presets changed for this", " video only), or an author with no character given one here, in the voice they read in now.", diff --git a/umtool/lib/report/castStore.mjs b/umtool/lib/report/castStore.mjs @@ -22,7 +22,7 @@ import { createHash } from "node:crypto"; import { mkdir, readFile, rename, stat, writeFile } from "node:fs/promises"; import path from "node:path"; import { - CAST_FORMAT, CAST_VERSION, PROJECT_CHARACTERS_FILE, PROJECT_CHARACTERS_FORMAT, PROJECT_CHARACTERS_VERSION, characterView, emptyCast, emptyProjectCharacters, upgradeCharacter, + CAST_FORMAT, CAST_VERSION, PROJECT_CHARACTERS_FILE, PROJECT_CHARACTERS_FORMAT, PROJECT_CHARACTERS_VERSION, characterView, emptyCast, emptyProjectCharacters, foldWritten, upgradeCharacter, validateCast, validateProjectCharacters, } from "umtool-report-to-video/cast"; import { REPORTS_ROOT } from "../paths.mjs"; @@ -150,11 +150,13 @@ function writeKind(kind, file, mutate, { token = null, what = "an edit" } = {}) const read = await readKind(kind, file); if (read.error && read.exists) throw new CastError(`${read.error} -- fix the file first; nothing written`, 409); if (token !== null && token !== undefined && token !== read.token) throw new CastError(`${kind.what} changed since it was read (${token} -> ${read.token}): read it again`, 409); - // The mutation is handed version 2's characters (no `voice` / `convert` beside the presets: one it sets is the - // newer word, upgradeCharacter), and what is written is version 2's shape. + // The mutation is handed version 2's characters (no `voice` / `convert` beside the presets), and what is written + // is version 2's shape: a `voice` / `convert` it sets the old way is the newer word unless it changed the preset + // itself (cast.mjs foldWritten, against the character as it was handed). const chars = JSON.parse(JSON.stringify((read.cast.characters ?? []).map(upgradeCharacter))); + const was = new Map(chars.map((c) => [c?.id, JSON.parse(JSON.stringify(c))])); const result = mutate(chars) ?? {}; - const doc = kind.doc(chars.map(upgradeCharacter)); + const doc = kind.doc(chars.map((c) => foldWritten(c, was.get(c?.id) ?? null))); const errors = kind.validate(doc, path.basename(file)); if (errors.length) throw new CastError(`refused: ${errors.join("; ")}`); const points = [...(await readCastUndo(file)), { at: new Date().toISOString(), what, text: read.exists ? read.text : null }].slice(-CAST_UNDO_KEEP); diff --git a/umtool/lib/report/characterLayers.mjs b/umtool/lib/report/characterLayers.mjs @@ -9,10 +9,19 @@ // voice map reads as none too unless `strictMap` (a thread read refuses one, as before). // // Plain ESM. -import { castPresetMap, characterForRead, itemCharacterOf, itemPresetOf, projectPresetMap } from "umtool-report-to-video/cast"; +import { castPresetMap, characterForRead, itemCharacterOf, itemPresetOf, projectPresetMap, recordedPresetOf } from "umtool-report-to-video/cast"; import { castForProject, readProjectCharacters } from "./castStore.mjs"; /** + * The trim a recording of post item `e` is kept with (postRecord.mjs keepRecording's `trim`): its character's recorded + * preset's (cast.mjs characterForRead, recordedPresetOf) -- `{ on, padMs }` -- or null: no character, the recorder's own. + */ +export async function recordedTrimFor(dir, e) { + const who = (await readLayers(dir).catch(() => null))?.characterForRead(e) ?? null; + return who?.character ? recordedPresetOf(who.character).trim : null; +} + +/** * @param {string} dir the project's folder * @param {{ reportsRoot?: string, strictMap?: boolean }} [o] * @returns {Promise<{ castRead: any, projectRead: any, voiceMap: Record<string, string>, cast: any, project: any, diff --git a/umtool/lib/report/characters.test.mjs b/umtool/lib/report/characters.test.mjs @@ -15,7 +15,7 @@ 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 { CastError, castFile, castWrite, projectCharactersFile, projectCharactersWrite, readCast, readCastFile, readProjectCharacters, undoCast, undoProjectCharacters } from "./castStore.mjs"; import { castCommand } from "./castCli.mjs"; -import { readLayers } from "./characterLayers.mjs"; +import { readLayers, recordedTrimFor } from "./characterLayers.mjs"; import { importRecording, makeTake } from "./postNarrationCli.mjs"; import { postsCommand } from "./postsCli.mjs"; import { partKey, readParts, threadReadPlan, threadTake, upToDate } from "./postThreadRead.mjs"; @@ -87,6 +87,15 @@ test("the store: a version 1 cast reads as version 2, the first write makes it v assert.deepEqual(disk.characters[0], { id: "hostman", name: "Host Man", handles: ["hostman"], synthetic: { voice: "kokoro:am_michael", speed: 1.1 }, speakers: ["Host"] }); assert.deepEqual(disk.characters[1], { id: "me", name: "Me", handles: ["operator"], synthetic: { voice: "kokoro:bm_george" }, recorded: { convert: { engine: "seed-vc", pitch: "contour", semitones: 2 } }, narrator: true }); assert.equal(w.undo, 1); + // A view written back with its PRESET changed: the preset wins over the view's own alias (which still says the old voice). + const view = (await readCastFile(file)).cast.characters[0]; + await castWrite(file, (chars) => { chars[0] = { ...view, synthetic: { ...view.synthetic, voice: "kokoro:am_onyx" } }; }, { what: "a view, its preset changed" }); + assert.deepEqual(JSON.parse(await readFile(file, "utf8")).characters[0].synthetic, { voice: "kokoro:am_onyx", speed: 1.1 }); + // …and the old way of setting one (`c.voice = …`) is still the newer word; neither leaves an alias on disk. + await castWrite(file, (chars) => { chars[0].voice = "kokoro:am_michael"; }, { what: "the old way" }); + assert.deepEqual(JSON.parse(await readFile(file, "utf8")), disk); + await undoCast(file); + await undoCast(file); // A refusal writes nothing: a convert target that is a file. await assert.rejects(castWrite(file, (chars) => { chars[0].recorded = { convert: { voice: "narration/me.wav" } }; }), /never a file or a recording/); assert.deepEqual(JSON.parse(await readFile(file, "utf8")), disk); @@ -222,6 +231,16 @@ test("cast project: the chain's answer and its source for each author; a post it assert.match(r.text(), /a recording of them: converted to kokoro:am_puck; not cleaned; edges trimmed; direction: "flat, tired"/); assert.match(r.text(), /@stranger\s+kokoro:am_onyx\s+\(project\)/); + // `posts voices ls` answers through the same layers: this video's own character, the map, the cast. + r = await posts(["voices", "chars", "ls", "--json"]); + assert.equal(r.code, 0, r.text()); + const author = (h) => r.json().authors.find((a) => a.handle === h); + assert.deepEqual([author("guest").voice, author("guest").from, author("guest").own, author("guest").speed], ["kokoro:am_puck", "project", "anon-a", 0.9]); + assert.deepEqual([author("stranger").voice, author("stranger").from, author("stranger").own, author("stranger").mapped], ["kokoro:am_onyx", "project", undefined, true]); + assert.deepEqual([author("hostman").voice, author("hostman").from, author("hostman").character], ["kokoro:am_michael", "cast", "hostman"]); + r = await posts(["voices", "chars", "ls"]); + assert.match(r.text(), /@guest kokoro:am_puck ×0\.9 \(this video's character: anon-a\)/); + // A POST ITEM's OWN CHARACTER: p-4 (the stranger's) read as the cast's `me`. r = await posts(["character", "chars", "p-4", "ghost"]); assert.equal(r.code, 2); @@ -260,6 +279,12 @@ test("a preset's speed on a single take: the flag, then the character's, then th // The flag over it. t = await makeTake(project, await item("p-1"), { render: m.render, speed: 0.8, ask: stubAsk(asked), redaction: null }); assert.equal(asked.at(-1).speed, 0.8); + // The item's own speed (narration.speed: set on this one item) beats its character's; the flag beats both. + const own = { ...(await item("p-1")), narration: { ...(await item("p-1")).narration, speed: 0.7 } }; + t = await makeTake(project, own, { render: m.render, ask: stubAsk(asked), redaction: null }); + assert.equal(asked.at(-1).speed, 0.7); + t = await makeTake(project, own, { render: m.render, speed: 1.4, ask: stubAsk(asked), redaction: null }); + assert.equal(asked.at(-1).speed, 1.4); // The stranger (the voice map: no preset): no speed asked. t = await makeTake(project, await item("p-4"), { render: m.render, ask: stubAsk(asked), redaction: null }); assert.deepEqual([asked.at(-1).voice, "speed" in asked.at(-1)], ["am_onyx", false]); @@ -281,8 +306,9 @@ test("a thread read: each part at its character's speed, the flag over them all, assert.deepEqual(threadReadPlan(m, e2, { map: L.map, cast: L.castMap, speed: 1.4 }).pieces.map((p) => p.speed), [1.4, 1.4]); // Orpheus has no speed: a piece in it is asked none, whatever the flag says. assert.deepEqual(threadReadPlan(m, e2, { map: { guest: "orpheus:tara" }, cast: L.castMap, speed: 1.4 }).pieces.map((p) => [p.engine, p.speed ?? null]), [["orpheus", null], ["kokoro", 1.4]]); - // His own words with no preset: the item's own speed (narration.speed), as a single take. + // His own words at the item's own speed (narration.speed), as a single take -- over his character's; the others' untouched. assert.deepEqual(threadReadPlan(m, { ...e2, narration: { ...e2.narration, speed: 0.75 } }, { map: {}, cast: {} }).pieces.map((p) => [p.role, p.speed ?? null]), [["parent:0", null], ["post", 0.75]]); + assert.deepEqual(threadReadPlan(m, { ...e2, narration: { ...e2.narration, speed: 0.75 } }, { map: L.map, cast: L.castMap }).pieces.map((p) => [p.role, p.speed ?? null]), [["parent:0", 0.9], ["post", 0.75]]); // Made: the editor is asked each part at its speed, the take's parts keep it, and the same read again is up to date. const asked = []; @@ -386,6 +412,10 @@ test("a recording made a read with its character's recorded preset: clean off, t r = await importRecording(project, await item("p-3"), rec, { convert: false, ask: askOp }); const padded = (await item("p-3")).narration.takes.find((t) => t.file === r.takes[0].file).seconds; assert.ok(padded > trimmed + 0.3 && padded < whole, `the pad kept (${padded} s between ${trimmed} and ${whole})`); + // The record page's two paths ask the same preset (characterLayers.mjs recordedTrimFor): the room kept; none with no character. + assert.deepEqual(await recordedTrimFor(DIR, await item("p-3")), { on: true, padMs: 400 }); + assert.deepEqual(await recordedTrimFor(DIR, await item("p-1")), { on: true, padMs: null }, "the cast's character: trimmed, the recorder's own room"); + assert.deepEqual(await recordedTrimFor(DIR, { id: "x", handle: "nobody-at-all" }), { on: true, padMs: null }, "nobody's: the narrator's"); // --as: a character of this video's by id, the cast's by id; the item's own character before its author's. r = await importRecording(project, await item("p-1"), rec, { as: "anon-a", convert: false, ask: askOp }); assert.equal(r.character.layer, "flag"); diff --git a/umtool/lib/report/postNarrationCli.mjs b/umtool/lib/report/postNarrationCli.mjs @@ -77,8 +77,8 @@ export const NARRATE_USAGE = [ " character), this video's for the post's author, the cast's, the narrator. Its RECORDED PRESET says whether the", " read is cleaned and its edges trimmed to speech (and the room kept): --clean | --no-clean and --trim | --no-trim", " say otherwise for this read.", - " --speed <s> (--take, --take --thread): the speed the read is asked at (0.5-2; Orpheus has none) -- default its", - " character's (the synthetic preset's: umtool cast set <id> --speed), else the item's own. A thread read: every part.", + " --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.", " --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.", " --pitch target|source|contour [--semitones <n>] (a convert, by --derive or --recording): the PITCH the converted", @@ -341,9 +341,9 @@ export async function makeTake(project, e, { script = null, note = null, engine const said0 = await itemReadVoice(project, e, { render, engine, voice }); const eng = said0.engine; const vox = said0.voice; - // Its speed: the one asked for (--speed), else its character's (the synthetic preset's that answered for the - // voice), else the item's own (`narration.speed`). - const spd = speed ?? said0.speed ?? e.narration?.speed ?? null; + // Its speed: the one asked for (--speed), else the item's own (`narration.speed`: set on this one item), else its + // character's (the synthetic preset's that answered for the voice). + const spd = speed ?? e.narration?.speed ?? said0.speed ?? null; const pid = postIdOf(e); const dir = path.join(project.dir, ...takesDirOf(pid).split("/")); await mkdir(dir, { recursive: true }); diff --git a/umtool/lib/report/postRevoice.mjs b/umtool/lib/report/postRevoice.mjs @@ -210,12 +210,16 @@ export function revoicePlan(entry, { match, occurrence = 1, say, voice = null, x to: { lo: r3(Math.min(Math.max(to, b.end), Math.max(to - REVOICE_REACH_WIDE, b.end))), hi: r3(Math.min(total, to + REVOICE_REACH_WIDE, next ? next.end : total)) }, }; const v = voice ?? voiceOf(entry, take, parts[part], render); + const partSpeed = parts[part]?.speed ?? (parts.length ? null : take.speed ?? null); + const speed = typeof partSpeed === "number" && Number.isFinite(partSpeed) && partSpeed !== 1 && engine !== "orpheus" ? partSpeed : null; const spoken = red ? spokenOf(say, entry, red) : { text: say, lexicon: [] }; const fixedAt = (Array.isArray(entry.fx) ? entry.fx : []).filter((fx) => fin(fx?.at)).length; return { take, picked, recut, target, first, last, phrase: words.slice(first, last + 1).map((w) => w.w).join(" "), nominal: { from: r3(from), to: r3(Math.min(total, to)) }, windows, wide, - say, said: spoken.text, lexicon: spoken.lexicon, voice: v, engine, key: partKey(engine, v, spoken.text), part, xfade, fixedAt, + // The speed the part it sits in was synthesized at (its character's preset's, or the read's --speed): the phrase + // put in is asked at it too, so it does not sound slower or faster than the words around it. + say, said: spoken.text, lexicon: spoken.lexicon, voice: v, engine, ...(speed !== null ? { speed } : {}), key: partKey(engine, v, spoken.text, speed), part, xfade, fixedAt, }; } @@ -390,7 +394,7 @@ export async function revoiceTake(project, e, o) { const askTts = ask ?? (await import("umtool-report-to-video/narrate-via-editor")).askEditorTts; emit("note", { message: `re-voicing "${plan.phrase}" as "${plan.said}" (${plan.engine} · ${plan.voice}): asking the editor…` }); try { - ({ jobId = null } = (await askTts({ text: plan.said, engine: plan.engine, voice: plan.voice, out: wav }, { ...(editor ? { editor } : {}), emit })) ?? {}); + ({ jobId = null } = (await askTts({ text: plan.said, engine: plan.engine, voice: plan.voice, out: wav, ...(typeof plan.speed === "number" ? { speed: plan.speed } : {}) }, { ...(editor ? { editor } : {}), emit })) ?? {}); } catch (err) { throw new RevoiceError(`"${plan.said}" (${plan.voice}) was not synthesized: ${err instanceof Error ? err.message : err}`); } diff --git a/umtool/lib/report/postRevoice.test.mjs b/umtool/lib/report/postRevoice.test.mjs @@ -53,6 +53,26 @@ function tones(seconds, spans, { amp = 0.2, freq = 220 } = {}) { return x; } +test("a re-voice is asked at the speed its part was synthesized at (a character's preset's, the read's --speed); Orpheus has none", async () => { + const { partKey } = await import("./postThreadRead.mjs"); + const fast = (engine) => { + const e = item(); + const t = e.narration.takes[0]; + t.engine = engine; + t.parts[0].speed = 1.2; + return e; + }; + const p = revoicePlan(fast("kokoro"), ASK); + assert.equal(p.speed, 1.2); + assert.equal(p.key, partKey("kokoro", p.voice, p.said, 1.2), "another speed is another cached part"); + assert.notEqual(p.key, partKey("kokoro", p.voice, p.said)); + // The second part has no speed of its own: asked as before. + const q = revoicePlan(fast("kokoro"), { match: "4", occurrence: 2, say: "four" }); + assert.equal(q.speed, undefined); + assert.equal(q.key, partKey("kokoro", q.voice, q.said)); + assert.equal(revoicePlan(fast("orpheus"), ASK).speed, undefined); +}); + test("THE ASK: the phrase and #n, --say, --voice (auto: the piece's own), --xfade 0-0.2 (default 0.03); the refusals are usage errors", () => { assert.deepEqual(parseRevoice({ phrase: "20 10 4 0", say: " 20... 10... " }), { match: "20 10 4 0", occurrence: 1, say: "20... 10...", voice: null, xfade: 0.03, cut: null }); assert.deepEqual(parseRevoice({ phrase: "4#2", say: "four", voice: "auto", xfade: "0.05" }), { match: "4", occurrence: 2, say: "four", voice: null, xfade: 0.05, cut: null }); diff --git a/umtool/lib/report/postSay.mjs b/umtool/lib/report/postSay.mjs @@ -293,6 +293,9 @@ export async function voicesCommand(project, rest, { json = false, out = (s) => const k = postNarrationKnobs({}, manifest.render ?? {}); const castRead = await castForProject(project.dir); const cast = castVoiceMap(castRead.cast); + // The layers a read asks (characterLayers.mjs): this video's own characters over this map, then the cast -- so the + // table says what a read would say, and why. + const L = await (await import("./characterLayers.mjs")).readLayers(project.dir); // Every author a thread read could voice: the items' own, their parents', quoted and linked posts'. const authors = new Map(); const count = (h, own) => { @@ -312,9 +315,11 @@ export async function voicesCommand(project, rest, { json = false, out = (s) => } // Each author's voice as a context post, and WHERE it comes from: the project's map, the cast, the default. const rows = [...authors.values()].sort((a, b) => b.items + b.context - (a.items + a.context)).map((a) => { - const v = voiceSourceOf({ handle: a.handle, role: "parent:0" }, { map, cast, narrator: k.voice, engine: k.engine }); + const v = voiceSourceOf({ handle: a.handle, role: "parent:0" }, { map: L.map, cast: L.castMap, narrator: k.voice, engine: k.engine }); const c = characterOf(castRead.cast, a.handle); - return { ...a, voice: v.spec, from: v.from, mapped: a.handle in map, ...(c ? { character: c.id, castVoice: c.voice } : {}) }; + // `own`: this video's own character that answers for the handle (narration/characters.json), before the map. + const own = v.from === "project" && v.character ? v.character : null; + return { ...a, voice: v.spec, from: v.from, ...(typeof v.speed === "number" ? { speed: v.speed } : {}), mapped: a.handle in map, ...(own ? { own } : {}), ...(c ? { character: c.id, castVoice: c.voice } : {}) }; }); if (json) out(JSON.stringify({ ok: true, file: VOICES_FILE, voices: map, narrator: k.voice, engine: k.engine, cast: { file: castRead.file, characters: Object.keys(cast).length, ...(castRead.error ? { error: castRead.error } : {}) }, authors: rows }, null, 2)); else { @@ -322,7 +327,8 @@ export async function voicesCommand(project, rest, { json = false, out = (s) => for (const [h, v] of Object.entries(map)) out(` ${h === VOICE_MAP_OTHER ? "* (everyone else)" : `@${h}`} -> ${v}${cast[h] && cast[h] !== v ? ` (the cast says ${cast[h]}: overridden here)` : ""}`); if (castRead.error) out(` the cast is not read: ${castRead.error}`); if (rows.length) out(" the cut's authors, as a context post (their own items read in the narrator's voice unless mapped or cast):"); - for (const r of rows) out(` @${r.handle} ${r.voice} (${r.from === "project" ? "project" : r.from === "cast" ? `cast: ${r.character}` : "default"}) -- ${r.items} item(s), ${r.context} context post(s)`); + if (L.projectRead.error) out(` this video's own characters are not read: ${L.projectRead.error}`); + for (const r of rows) out(` @${r.handle} ${r.voice}${r.speed !== undefined ? ` ×${r.speed}` : ""} (${r.from === "project" ? (r.own ? `this video's character: ${r.own}${r.mapped ? "; the map's entry is under it" : ""}` : "project") : r.from === "cast" ? `cast: ${r.character}` : "default"}) -- ${r.items} item(s), ${r.context} context post(s)`); } return 0; } diff --git a/umtool/lib/report/postThreadRead.mjs b/umtool/lib/report/postThreadRead.mjs @@ -145,8 +145,8 @@ export function seenIds(manifest, e) { * `map`, `cast` and `item` are voiceSourceOf's layers (cast.mjs projectPresetMap, castPresetMap, itemPresetOf: an entry * a voice as written, or a character's preset `{ voice, speed?, character }`). Each piece's `engine` is its voice's * (a voice that names one), else the read's; `from` where its voice came from (post-say.mjs voiceSourceOf); `speed` - * the speed it is asked at (readSpeedOf: the command's `speed`, else its character's preset's, else the item's own - * for his words -- none for Orpheus, which has none, or at 1). The read's `engine` is his piece's. + * the speed it is asked at (readSpeedOf: the command's `speed`, else the item's own for his words, else its + * character's preset's -- none for Orpheus, which has none, or at 1). The read's `engine` is his piece's. * * @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] diff --git a/umtool/lib/report/recordSession.mjs b/umtool/lib/report/recordSession.mjs @@ -117,7 +117,9 @@ export async function finishSession(project, entry, { label = "operator", manife const p = doc.parts[String(n)]; parts.push({ file: path.join(dir, p.file), text: p.text, para: p.para }); } - const kept = await keepRecording(project, entry, parts, { label, manifest, script }); + // Its character's recorded preset says whether its edges are trimmed, and the room kept (characterLayers.mjs). + const { recordedTrimFor } = await import("./characterLayers.mjs"); + const kept = await keepRecording(project, entry, parts, { label, manifest, script, trim: await recordedTrimFor(project.dir, entry) }); await rm(dir, { recursive: true, force: true }); return kept; } diff --git a/umtool/report-to-video/cast.mjs b/umtool/report-to-video/cast.mjs @@ -33,7 +33,8 @@ // A PROJECT's OWN CHARACTERS (`<project>/narration/characters.json`, // PROJECT_CHARACTERS_FORMAT; the same store) are the same shape, with no // narrator and with `anonymous: true` + `shown` ("Anon 1") for a person who -// must not enter the pool: they live in that video only. +// must not enter the pool: they live in that video only. (The shown name is +// what umtool's own surfaces call them; the cut's card is not anonymised yet.) // // A project's `narration/voices.json` (post-say.mjs) stays the project's // OVERRIDE LAYER (a handle in it reads as a project character with only a @@ -116,15 +117,16 @@ const KEY_ORDER = ["id", "name", "anonymous", "shown", "handles", "synthetic", " /** * A character as VERSION 2 holds it, from either version (pure, a copy): `voice` read as `synthetic.voice`, `convert` - * as `recorded.convert`, and the keys in one order. A top-level `voice` / `convert`, where one is still written - * beside its preset, is the word that counts (a version 1 writer's `c.voice = …` on a character read as version 2; - * a view's own alias says what its preset says). Anything else is left as it is (validateCast says what is wrong). + * as `recorded.convert`, and the keys in one order. Where a preset says the key too, THE PRESET WINS: a top-level + * `voice` / `convert` beside it is a view's alias (characterView), which may be stale -- a view whose + * `synthetic.voice` was changed folds to the new value. (A writer's mutation that SETS `c.voice` the old way is told + * apart by what the character was before: foldWritten.) Anything else is left as it is (validateCast says what is wrong). */ export function upgradeCharacter(c) { if (!isObj(c)) return c; const { voice, convert, synthetic, recorded, ...rest } = c; - const syn = synthetic !== undefined && !isObj(synthetic) ? synthetic : { ...(synthetic ?? {}), ...(voice !== undefined ? { voice } : {}) }; - const rec = recorded !== undefined && !isObj(recorded) ? recorded : { ...(recorded ?? {}), ...(convert !== undefined ? { convert } : {}) }; + const syn = synthetic !== undefined && !isObj(synthetic) ? synthetic : { ...(voice !== undefined ? { voice } : {}), ...(synthetic ?? {}) }; + const rec = recorded !== undefined && !isObj(recorded) ? recorded : { ...(convert !== undefined ? { convert } : {}), ...(recorded ?? {}) }; const all = { ...rest, ...(!isObj(syn) || Object.keys(syn).length ? { synthetic: syn } : {}), ...(!isObj(rec) || Object.keys(rec).length ? { recorded: rec } : {}) }; const out = {}; for (const k of KEY_ORDER) if (k in all) out[k] = all[k]; @@ -132,6 +134,21 @@ export function upgradeCharacter(c) { return out; } +/** + * A character AS A WRITE LEAVES IT, folded to version 2 (pure): `c` what the mutation left, `before` the character it + * was handed (version 2's, no aliases; null: a new one). A top-level `voice` / `convert` on it was put there by the + * mutation -- the old way of setting one (`c.voice = …`) -- and is the newer word WHEN THE PRESET IS AS IT WAS; a + * preset the mutation changed itself wins (the top-level key is then a stale alias: a view written back). + */ +export function foldWritten(c, before = null) { + if (!isObj(c)) return c; + const out = { ...c }; + const same = (a, b) => JSON.stringify(a ?? null) === JSON.stringify(b ?? null); + if (out.voice !== undefined && isObj(out.synthetic) && out.synthetic.voice !== undefined && before && same(before.synthetic?.voice, out.synthetic.voice)) out.synthetic = { ...out.synthetic, voice: out.voice }; + if (out.convert !== undefined && isObj(out.recorded) && out.recorded.convert !== undefined && before && same(before.recorded?.convert, out.recorded.convert)) out.recorded = { ...out.recorded, convert: out.convert }; + return upgradeCharacter(out); +} + /** A cast document as version 2 holds it (upgradeCharacter each); a document that is not one is returned as it is. */ export function upgradeCast(doc) { if (!isObj(doc) || !Array.isArray(doc.characters) || doc.format !== CAST_FORMAT || !CAST_VERSIONS_READ.includes(doc.version)) return doc; @@ -139,9 +156,9 @@ export function upgradeCast(doc) { } /** A character's stock voice (`synthetic.voice`; version 1's `voice`), its speed, its convert entry -- of either shape. */ -export const characterVoice = (c) => (c?.voice !== undefined ? c.voice : isObj(c?.synthetic) ? c.synthetic.voice : undefined) ?? null; +export const characterVoice = (c) => (isObj(c?.synthetic) && c.synthetic.voice !== undefined ? c.synthetic.voice : c?.voice) ?? null; export const characterSpeed = (c) => (isObj(c?.synthetic) && typeof c.synthetic.speed === "number" ? c.synthetic.speed : null); -export const characterConvert = (c) => (c?.convert !== undefined ? c.convert : isObj(c?.recorded) ? c.recorded.convert : undefined); +export const characterConvert = (c) => (isObj(c?.recorded) && c.recorded.convert !== undefined ? c.recorded.convert : c?.convert); /** * A character as a READER is handed it: version 2's shape, AND the `voice` / `convert` its presets answer to (what @@ -275,7 +292,10 @@ export function projectCharactersOf(doc) { return (Array.isArray(doc?.characters) ? doc.characters : []).filter((c) => isObj(c) && CHARACTER_ID_RE.test(str(c.id)) && str(c.name).trim()).map(characterView); } -/** The name a character goes by on screen and in a read: an anonymous one's `shown` name, never its own. */ +/** + * The name a character goes by where umtool names it (the Voices page, `umtool cast project`, a recording's note): an + * anonymous one's `shown` name, never its own. The cut's on-screen card does NOT ask this yet: it shows the post's author. + */ export const shownNameOf = (c) => (c?.anonymous === true ? str(c.shown).trim() || ANON_NAME_PATTERN.replace("{n}", "1") : str(c?.name)); /** The next unused shown name of ANON_NAME_PATTERN among a project's characters ("Anon 3"). */ diff --git a/umtool/report-to-video/characters.test.mjs b/umtool/report-to-video/characters.test.mjs @@ -6,7 +6,7 @@ import assert from "node:assert/strict"; import { test } from "node:test"; import { - ANON_NAME_PATTERN, CAST_VERSION, PROJECT_CHARACTERS_FILE, castPresetMap, castVoiceMap, characterById, characterForRead, characterView, charactersOf, convertTargetOf, emptyCast, + ANON_NAME_PATTERN, CAST_VERSION, PROJECT_CHARACTERS_FILE, castPresetMap, castVoiceMap, characterById, characterForRead, characterView, charactersOf, convertTargetOf, emptyCast, foldWritten, emptyProjectCharacters, itemCharacterOf, itemPresetOf, nextAnonName, projectCharactersOf, projectPresetMap, recordedPresetOf, shownNameOf, upgradeCast, upgradeCharacter, validateCast, validateProjectCharacters, } from "./cast.mjs"; @@ -49,9 +49,21 @@ test("migration the other way: a reader is handed the presets AND the voice / co // A view written back is the same character: its `voice` says what its preset says. assert.deepEqual(upgradeCharacter(views[1]), v2.characters[1]); assert.deepEqual(characterView(views[1]), views[1]); - // A version 1 writer's `c.voice = …` on a character read as version 2 is the word that counts. - assert.deepEqual(upgradeCharacter({ ...v2.characters[0], voice: "kokoro:am_onyx" }).synthetic, { voice: "kokoro:am_onyx" }); - assert.deepEqual(upgradeCharacter({ ...v2.characters[0], synthetic: { voice: "kokoro:am_michael", speed: 1.1 }, voice: "kokoro:am_onyx" }).synthetic, { voice: "kokoro:am_onyx", speed: 1.1 }, "its speed kept"); + // A VIEW WHOSE PRESET WAS CHANGED folds to the new value: the preset wins over its own (now stale) alias. + const edited = { ...views[0], synthetic: { ...views[0].synthetic, voice: "kokoro:am_onyx", speed: 1.1 } }; + assert.equal(edited.voice, "kokoro:am_michael", "the alias still says the old voice"); + assert.deepEqual(upgradeCharacter(edited).synthetic, { voice: "kokoro:am_onyx", speed: 1.1 }); + assert.equal(characterView(edited).voice, "kokoro:am_onyx", "and a view of it says the new one"); + assert.deepEqual(upgradeCharacter({ ...views[1], recorded: { convert: { engine: "openvoice" } } }).recorded, { convert: { engine: "openvoice" } }); + // A WRITE's mutation that sets `c.voice` the old way, on the character it was handed (no alias): the newer word. + const handed = v2.characters[0]; + assert.deepEqual(foldWritten({ ...handed, voice: "kokoro:am_onyx" }, handed).synthetic, { voice: "kokoro:am_onyx" }); + assert.deepEqual(foldWritten({ ...v2.characters[1], convert: { engine: "openvoice" } }, v2.characters[1]).recorded, { convert: { engine: "openvoice" } }); + assert.deepEqual(foldWritten({ ...handed, synthetic: { voice: "kokoro:am_michael", speed: 1.1 }, voice: "kokoro:am_onyx" }, handed).synthetic, { voice: "kokoro:am_onyx", speed: 1.1 }, "its speed kept"); + // …but a mutation that changed the preset itself wins over a stale alias beside it (a view written back). + assert.deepEqual(foldWritten(edited, handed).synthetic, { voice: "kokoro:am_onyx", speed: 1.1 }); + assert.deepEqual(foldWritten({ id: "new", name: "New", handles: [], voice: "kokoro:am_echo" }, null).synthetic, { voice: "kokoro:am_echo" }, "a new character the old way"); + assert.equal(foldWritten(handed, handed).voice, undefined, "no alias is written"); }); test("validation: the presets' shape, in the cast -- a voice and a convert target are STOCK voices, never a file", () => { @@ -156,9 +168,10 @@ test("the chain for a synthesized read, first hit wins: flags, the item's charac assert.equal(itemPresetOf({ narration: {} }, layers), null); }); -test("the speed a part is asked at: the flag, the preset's, the item's own -- none for Orpheus, or at 1", () => { +test("the speed a part is asked at: the flag, the item's own, the preset's -- none for Orpheus, or at 1", () => { assert.equal(readSpeedOf({ flag: 1.3, preset: 1.1, own: 0.9, engine: "kokoro" }), 1.3); - assert.equal(readSpeedOf({ preset: 1.1, own: 0.9, engine: "kokoro" }), 1.1); + assert.equal(readSpeedOf({ preset: 1.1, own: 0.9, engine: "kokoro" }), 0.9, "set on the one item: it beats its character's"); + assert.equal(readSpeedOf({ preset: 1.1, engine: "kokoro" }), 1.1); assert.equal(readSpeedOf({ own: 0.9, engine: "kokoro" }), 0.9); assert.equal(readSpeedOf({ engine: "kokoro" }), null); assert.equal(readSpeedOf({ flag: 1.3, engine: "orpheus" }), null, "Orpheus has no speed"); diff --git a/umtool/report-to-video/post-say.mjs b/umtool/report-to-video/post-say.mjs @@ -323,12 +323,12 @@ export function resolvePieceVoice(piece, o) { } /** - * THE SPEED A PART IS ASKED AT, pure: the command's (`flag`), else the preset's (`preset`: the character's that - * answered for the voice), else the item's own (`own`: `narration.speed`, for its own words) -- and none (null) for - * an engine that has no speed (Orpheus), or at 1. + * THE SPEED A PART IS ASKED AT, pure: the command's (`flag`), else the item's own (`own`: `narration.speed`, for its + * own words -- set on that one item, it beats a character's), else the preset's (`preset`: the character's that + * answered for the voice) -- and none (null) for an engine that has no speed (Orpheus), or at 1. */ export function readSpeedOf({ flag = null, preset = null, own = null, engine = null } = {}) { - const v = [flag, preset, own].find((x) => typeof x === "number" && Number.isFinite(x)); + const v = [flag, own, preset].find((x) => typeof x === "number" && Number.isFinite(x)); return v === undefined || engine === "orpheus" || v === 1 ? null : v; }