Archilyzer · Source

archilyzer

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

commit af58faf7873387a946cea735f08f0f47a4860505
parent 55053e8246097d25bba98bdea5d6261aea208583
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed, 11 Nov 2026 17:16:11 -0500

umtool: a converted read's pitch -- --pitch / --semitones on posts narrate --derive and --recording, the cast's convert entry carries them (cast set --convert-pitch, --convert-semitones), the Voices page says them, a take's step keeps what was run; docs and changelog

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

Diffstat:
MOPERATING.md | 24++++++++++++++++++++++--
Meditor/CHANGELOG.md | 1+
Mumtool/app/api/report/voices/route.ts | 5++++-
Mumtool/components/projects/VoicesPanel.tsx | 22+++++++++++++++++++---
Mumtool/docs/cli.md | 10+++++-----
Mumtool/docs/knobs.md | 39+++++++++++++++++++++++++++++++++++----
Mumtool/lib/cli/groups.mjs | 8++++----
Mumtool/lib/cli/verbs.mjs | 8++++++--
Mumtool/lib/report/cast.test.mjs | 56++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/lib/report/castCli.mjs | 43+++++++++++++++++++++++++++++++++----------
Mumtool/lib/report/postNarration.test.mjs | 24++++++++++++++++++++++--
Mumtool/lib/report/postNarrationCli.mjs | 61+++++++++++++++++++++++++++++++++++++++++++++++++++----------
Mumtool/lib/report/postsCli.mjs | 2+-
Mumtool/report-to-video/cast.mjs | 49++++++++++++++++++++++++++++++++++++++++++++++---
Mumtool/report-to-video/cast.test.mjs | 14+++++++++++++-
Mumtool/report-to-video/post-narration.mjs | 7++++++-
16 files changed, 324 insertions(+), 49 deletions(-)

diff --git a/OPERATING.md b/OPERATING.md @@ -916,21 +916,41 @@ pnpm ops get generation-usage pnpm archilyzer voice setup --engine deepfilternet --dry-run # what it fetches, how big; then without --dry-run pnpm archilyzer voice setup --engine openvoice pnpm archilyzer voice setup --engine seed-vc --check +pnpm archilyzer voice setup --engine seed-vc --with f0 # the optional f0 model (1.49 GB): a conversion that follows your pitch pnpm ops voice-enhance --json '{"file":"/abs/take.wav","out":"/abs/take.clean.wav"}' --wait pnpm ops voice-convert --json '{"file":"/abs/take.wav","out":"/abs/take.zac.wav","voice":"orpheus:zac"}' --wait umtool posts narrate <project> <item> --derive 1 --op enhance umtool posts narrate <project> <item> --derive 2 --op convert --voice zac --engine seed-vc +pnpm ops voice-convert --json '{"file":"/abs/take.wav","out":"/abs/take.bella.wav","voice":"kokoro:af_bella","engine":"seed-vc","pitch":"source","semitones":2}' --wait +umtool posts narrate <project> <item> --derive 2 --op convert --voice kokoro:af_bella --engine seed-vc --pitch contour +umtool cast set <character> --convert-engine seed-vc --convert-pitch contour --convert-semitones 2 ``` - Two editor ops over a speech recording, each a job on the `voice` queue, one at a time, its engine run behind the heavy slot with the engine's declared estimate (`settings.voice.heavyEstimateMB`): **enhance** (denoise, soften the - room, level by one static gain) and **convert** (the timing and pitch contour kept, the timbre swapped for a STOCK - synthetic voice). The result is a 48 kHz mono WAV exactly as long as the input; `out` is never inside the corpus. + room, level by one static gain) and **convert** (the timing kept, the timbre swapped for a STOCK + synthetic voice; the pitch as `pitch` says, below). The result is a 48 kHz mono WAV exactly as long as the input; `out` is never inside the corpus. umtool's derived takes are the usual caller: a new take from take n, the original kept, a parted take part by part. - **A convert target is a stock voice of our own TTS engines** — `orpheus:zac`, `orpheus:leah`, `kokoro:am_michael`, or a bare name one engine has (`zac`). A file, a path or a recording is refused, whatever it holds: these engines clone from seconds of audio, so no real person's voice is ever a target. Its reference (the voice reading "The North Wind and the Sun") is asked of the `tts` op the first time and kept under `settings.voice.home/targets/`. +- **The pitch a conversion lands on** is `pitch` (default `settings.voice.convert.pitch`, `target`): + - `target`: the stock voice's own pitch. The converter is given none of yours, so a read with a median of 128 Hz and + one of 237 Hz both come out near 197 Hz, and the range narrows — voice acting is flattened. + - `source`: the pitch you read at. Raise your voice for a character and the result is raised the same. + - `contour`: your rises and falls, moved as a whole so their median sits on the stock voice's. Read in your ordinary + voice and the character speaks in its own register with your intonation. + - `semitones` (-12 to 12) moves a followed pitch (`source`, `contour`); with `target` it is refused. + - `source` and `contour` are seed-vc's, on its f0-conditioned 44.1 kHz model: optional files, fetched by `voice setup + --engine seed-vc --with f0`. openvoice refuses them; without the files the op refuses, naming that command. An + install without them still converts at the target's pitch. It takes about twice as long as seed-vc's plain run and + declares its own estimate (`settings.voice.heavyEstimateMB["seed-vc-f0"]`). + - The result says what was done: `pitch`, `semitones`, and `f0` — the median pitch heard in the target's reference + and in your take, and the whole move applied, in semitones. + - In umtool a character keeps its pitch in the cast (`umtool cast set <id> --convert-pitch …`), so every recording + made that character's lands the same way; `--pitch` / `--semitones` on `posts narrate … --recording` or `--derive` + are for one read. - Engines (`settings.voice`): enhance `deepfilternet` (DeepFilterNet 3, the default) or `rnnoise` (ffmpeg's arnndn, nothing to install); convert `openvoice` (OpenVoice v2's converter, the default) or `seed-vc` (Seed-VC v1, closer to the target, several times slower). All on the CPU. `voice setup` says what it fetches first; `--check` lists diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ## [Unreleased] +- **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 twice as long. `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 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. - **The drive watch no longer overwrites a tier you change while it is pausing channels.** The five-minute storage watch, which pauses the channels on a drive that went away and restores them when it comes back, could save its change in the middle of yours and undo it. It now waits for the same settings lock that the channel-priority save uses. The editor's `dev` script also gives Node 16 file-access threads, as `start`, the systemd unit and the container already do. diff --git a/umtool/app/api/report/voices/route.ts b/umtool/app/api/report/voices/route.ts @@ -32,7 +32,7 @@ export const dynamic = "force-dynamic"; // POST { project, op: "use", who, voice, scope: "project" | "cast" } umtool cast use <p> <who> <voice> [--everywhere] // POST { project, op: "reread", who } QUEUED: one `posts narrate … --take [--thread …]` step per item // whose picked read says them in another voice (the argv built here) -// POST { project, op: "cast-rm", id } | { op: "cast-undo" } | { op: "cast-set", id, convertEngine?, narrator? } +// POST { project, op: "cast-rm", id } | { op: "cast-undo" } | { op: "cast-set", id, convertEngine?, convertPitch?, convertSemitones?, narrator? } // POST multipart { project, op: "recording", item, as?, clean?, convert?, file } a JOB: posts narrate <p> <item> // --recording <file> (kept, cleaned, converted to a STOCK voice) const headers = { "cache-control": "no-store" }; @@ -169,6 +169,9 @@ export async function POST(request: Request) { if (op === "cast-set") { const args = ["set", s("id")]; if (s("convertEngine")) args.push("--convert-engine", s("convertEngine")); + // The pitch a converted read lands on (castCli.mjs refuses what makes no sense). + if (s("convertPitch")) args.push("--convert-pitch", s("convertPitch")); + if (typeof b.convertSemitones === "number" || s("convertSemitones")) args.push("--convert-semitones", String(b.convertSemitones ?? s("convertSemitones"))); if (b.narrator === true || s("narrator") === "on") args.push("--narrator"); if (b.narrator === false || s("narrator") === "off") args.push("--no-narrator"); if (s("name")) args.push("--name", s("name")); diff --git a/umtool/components/projects/VoicesPanel.tsx b/umtool/components/projects/VoicesPanel.tsx @@ -26,13 +26,24 @@ type Voice = { engine: string; voice: string; spec: string; from: string }; type Drift = { id: string; handle: string; role: string; reads: string; want: string; from: string | null; kind: string; thread: boolean }; type Character = { key: string; name: string; handles: string[]; - character: { id: string; name: string; voice: string; convert?: { engine?: string; voice?: string }; note?: string; narrator?: boolean } | null; + character: { id: string; name: string; voice: string; convert?: Convert; note?: string; narrator?: boolean } | null; items: number; context: number; itemIds: string[]; contextIds: string[]; voice: Voice; contextVoice?: Voice; weight: string; reads: { id: string; role: string; spec: string; kind: string }[]; drift: Drift[]; speaker: string | null; lines: { item: string; text: string; own: boolean }[]; }; -type CastChar = { id: string; name: string; handles?: string[]; voice: string; convert?: { engine?: string; voice?: string }; speakers?: string[]; note?: string; narrator?: boolean }; +// What a recording of the character is made into: the stock voice, the engine, and the pitch the converted read +// lands on (`umtool cast set <id> --convert-pitch source|contour|target --convert-semitones n`). +type Convert = { engine?: string; voice?: string; pitch?: "target" | "source" | "contour"; semitones?: number }; +type CastChar = { id: string; name: string; handles?: string[]; voice: string; convert?: Convert; speakers?: string[]; note?: string; narrator?: boolean }; + +/** A convert entry's pitch in words — "follows your pitch", "your intonation at the voice's register +2 st" — "" for the stock voice's own. */ +function pitchWords(cv?: Convert): string { + if (!cv?.pitch || cv.pitch === "target") return ""; + const n = Number(cv.semitones) || 0; + const st = n ? ` ${n > 0 ? "+" : "−"}${Math.abs(n)} st` : ""; + return cv.pitch === "source" ? `follows your pitch${st}` : `your intonation at the voice's register${st}`; +} type Engine = { id: string; label: string; voices: string[]; defaultVoice: string; weight: string }; type View = { project: string; castFile: string | null; castError?: string; map: Record<string, string>; @@ -527,7 +538,7 @@ export default function VoicesPanel({ project, posts, initialWho = null }: { pro <option value="">as: the post&apos;s author (else the narrator)</option> {view.cast.map((c) => ( <option key={c.id} value={c.id}> - as {c.name} ({pretty(c.convert?.voice ?? c.voice)}) + as {c.name} ({pretty(c.convert?.voice ?? c.voice)}{pitchWords(c.convert) ? `, ${pitchWords(c.convert)}` : ""}) </option> ))} </select> @@ -580,6 +591,11 @@ export default function VoicesPanel({ project, posts, initialWho = null }: { pro <td className={cn(cell, "font-mono")}>{pretty(c.voice)}</td> <td className={cn(cell, "text-[11px] text-text-2")}> {c.convert ? `a recording → ${pretty(c.convert.voice ?? c.voice)}${c.convert.engine ? ` (${c.convert.engine})` : ""}` : ""} + {pitchWords(c.convert) && ( + <span data-cast-pitch={c.id} title={`the pitch a converted read lands on: ${c.convert?.pitch}${c.convert?.semitones ? `, ${c.convert.semitones} semitones` : ""} — umtool cast set ${c.id} --convert-pitch target|source|contour --convert-semitones <n>`}> + {` · pitch: ${pitchWords(c.convert)}`} + </span> + )} {c.speakers?.length ? ` · real voice: ${c.speakers.join(", ")}` : ""} {c.note ? ` · ${c.note}` : ""} </td> diff --git a/umtool/docs/cli.md b/umtool/docs/cli.md @@ -22,7 +22,7 @@ Inbox cannot disagree about what is wrong with one. | `check [<project>] [--json]` | **exit 1 on anything blocking** — including an `out/`, `clips/` or `share-*/` link whose drive is not there (`storage-unreachable`) | | `links <project> --embed-ids [--clips a,b] [--dry-run] [--json]` | the **published embed id**: every clip citing a Rumble URL-slug folder the archive does not serve gets `siteVideo` (the folder's `metadata.info.json` id, shareLine.mjs `siteVideoFor`), a citeUrl naming the folder moved with it; no network, one write, one undo point. The Cut tab's Project › Rumble cites ([knobs.md](knobs.md#the-inspector-panels-this-weeks-hand-edits-in-the-ui)) | | `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 …] [--convert-engine e] [--convert-voice v] [--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 and their STOCK voices, a layer under each project's voice map; one writer, an undo point a write | +| `cast [ls] \| add <id> --name … --voice <engine:voice> [--handles a,b] [--speakers …] [--convert-engine e] [--convert-voice v] [--convert-pitch target\|source\|contour] [--convert-semitones n] [--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 and their STOCK voices, a layer under each project's voice map; one writer, an undo point a write. A character's `convert` entry is what a recording of them is made into: the stock voice, the engine, and 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; `set` lays the flags given over the entry). A followed pitch on an engine that has none, or semitones with nothing followed: **exit 1** | | `cast project <project> [--json]` · `cast use <project> <character\|@handle> <voice> [--everywhere]` · `cast reread <project> <character> [--dry-run]` | a project's characters (each voice now, where it comes from, its stale reads), the voice for this project or everywhere, and the re-reads that asks for | | `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)) | @@ -133,7 +133,7 @@ Inbox cannot disagree about what is wrong with one. | `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] [--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 project's voice map, `posts voices`; his own: the narrator's), 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 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 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** | -| `posts narrate <project> <item> --recording <file> [--as <character>] [--no-clean] [--no-convert] [--label l]` | **a recording made a character's read**: kept (recorded), cleaned (voice-enhance), converted (voice-convert) to the character's STOCK voice, each a new take, the last picked | +| `posts narrate <project> <item> --recording <file> [--as <character>] [--no-clean] [--no-convert] [--pitch target\|source\|contour] [--semitones n] [--label l]` · `<item> --derive <n> --op convert [--engine e] [--voice v] [--pitch …] [--semitones n]` | **a recording made a character's read**: kept (recorded), cleaned (voice-enhance), converted (voice-convert) to the character's STOCK voice, each a new take, the last picked. **`--pitch`** is the pitch the converted read lands on ([knobs.md](knobs.md#the-pitch-a-converted-read-lands-on)): `target` the stock voice's own (the read's intonation flattened to it), `source` the pitch it was read at, `contour` the read's rises and falls moved to the stock voice's register; `--semitones` (-12…12) moves a followed one. Default: the character's `convert` entry, else the editor's `settings.voice.convert`. `source` and `contour` are seed-vc's, with its f0 model (`archilyzer voice setup --engine seed-vc --with f0`); what the editor cannot do it refuses in a sentence (**exit 1**); a value outside these, or a pitch on `--op enhance`: **exit 1** | | `posts fx <project> <item> add caption --match "…" --text "…" [--target post\|quoted\|parent:<i>] [--occurrence n] [--at s] [--lead s] [--hold s] [--place below\|above\|side]` · `add clock [--rewind auto\|on\|off] [--off]` · `set <n> [--text …] [--place …] [--rewind …]` | a post item's **caption** ([report-video.md](report-video.md#a-caption), [knobs.md](knobs.md#a-caption-a-chip-explaining-a-phrase-as-it-is-read)): a chip explaining a phrase (any script: CJK drawn), up as it is read -- `--at`, else the take's word timings, else the reading estimate -- held `--hold` s, by the phrase and never over a word read while it is up; it waits for a word zoom. Its **clock** ([knobs.md](knobs.md#the-clock-each-posts-own-time-on-its-card-run-between-items)): the post's own time on the card, run from the clock item before it (forward; a REWIND when earlier: `--rewind`), `--off` not on this item. Through `updatePostFx`, refused in the build's words (**exit 1**); a zoom's knob on a caption, or a caption's on a zoom (**exit 1**) | | `posts clock <project> [on\|off\|default] [--zone <IANA zone>] [--json]` | the cut's **clock** default (`render.posts.clock`, `updatePostClock`); bare, which items show it and their times | | `posts fx <project> <item> add slam --text "不動心" [--match "…" \| --at s] [--whole \| --per-glyph] [--gap s] [--hold s] [--from-scale x] [--color #rrggbb] [--outline #rrggbb] [--outline-width px] [--place over-match\|center] [--size px] [--face jp\|sc\|tc\|kr] [--sfx trailer-hit\|off] [--volume x] [--swell \| --no-swell] [--bar "…" [--bar-style dark\|gold\|plain]]` · `set <n> [those flags; --bar off clears it]` | a post item's **slam** ([report-video.md](report-video.md#a-slam), [knobs.md](knobs.md#a-slam-a-trailer-style-title-slam-over-a-word-as-it-is-read)): a corny trailer title slam -- each glyph huge, shrinking onto the card just above the matched words' line and HITTING (a flash, dust, the frame's punch, a trailer hit's boom: the teaser's generator, `trailer-hits.mjs`), gold with a black outline; the hits spread evenly over the words' spoken span (`--gap` spaces them, `--at` moves the first), held `--hold` s; `--bar` lands the glyphs on a translation bar (rising in at the first hit, faded with them); a caption up with it waits for it. Through `updatePostFx`, refused in the build's words (**exit 1**); a slam's knob on another effect, or another's on a slam (**exit 2**) | @@ -170,8 +170,8 @@ draft (the project's manifest); *project*: a project's other files, or reads; *c | `still <project> <clip> --at N [--take TAKE]` | one frame of a clip's fetched window at a source second, into shots/ | form · *project* | | `still <project> ls` | the pictures in the project's shots/ | form · *project* | | `cast ls` | the characters' voices across projects | form · *corpus* | -| `cast add <id> --name NAME --voice VOICE [--handles HANDLES] [--speakers SPEAKERS] [--convert-engine openvoice\|seed-vc] [--convert-voice CONVERT-VOICE] [--note NOTE] [--narrator]` | a character: name, stock voice, handles | form · *corpus* | -| `cast set <id> [--name NAME] [--voice VOICE] [--handles HANDLES] [--speakers SPEAKERS] [--convert-engine openvoice\|seed-vc] [--convert-voice CONVERT-VOICE] [--note NOTE] [--add-handle ADD-HANDLE] [--remove-handle REMOVE-HANDLE] [--no-convert] [--narrator] [--no-narrator]` | change a character | form · *corpus* | +| `cast add <id> --name NAME --voice VOICE [--handles HANDLES] [--speakers SPEAKERS] [--convert-engine openvoice\|seed-vc] [--convert-voice CONVERT-VOICE] [--convert-pitch target\|source\|contour] [--convert-semitones N] [--note NOTE] [--narrator]` | a character: name, stock voice, handles | form · *corpus* | +| `cast set <id> [--name NAME] [--voice VOICE] [--handles HANDLES] [--speakers SPEAKERS] [--convert-engine openvoice\|seed-vc] [--convert-voice CONVERT-VOICE] [--convert-pitch target\|source\|contour] [--convert-semitones N] [--note NOTE] [--add-handle ADD-HANDLE] [--remove-handle REMOVE-HANDLE] [--no-convert] [--narrator] [--no-narrator]` | change a character | form · *corpus* | | `cast rm <id>` | a character out of the cast (an undo point) | form · *corpus* | | `cast undo` | the cast as it was before its last write | form · *corpus* | | `cast project <project>` | the project's characters, their voices and drift | form · *project* | @@ -349,7 +349,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] [--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] [--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 voices <project> ls\|set\|remove [<handle>] [<voice>]` | the voice map a thread read uses | form · *draft* | | `posts fit <project> [<items>…] [--all] [--linger N] [--dry-run]` | narrated posts' videos cut to their best part | form · queued · *draft* | diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -1168,7 +1168,7 @@ the shape, the mix, recordings, parts, the best part). One writer for a post's n | a recorded take — your own read, part by part, kept as `take-<n>.recorded-<label>.wav`, picked | post bench, **record your read**: the mic, the level, **Record** (R) / **Stop** (S) / **Redo part** / **Next part**, **Keep** / **Discard**, **voice** (the label, default `operator`) | — | `POST` multipart `{project, id, label, script?, part[], text[], para[]}` | | a synthesized take — the editor's tts op, with direction | post bench, **Re-take with direction** (a note, a voice) | `umtool posts narrate <p> <item> --take [--note "…"] [--voice v] [--engine e] [--speed s]` · every missing one: `--all --take` | `op: "take"` → `{jobId, file}` · `GET ?project&id&job&file` keeps it when done | | a THREAD READ — the post it answers (or every ancestor), the post it quotes, the linked posts and his words, each in its author's voice, parts cached, one take picked ([below](#pronunciation-and-voices-the-lexicon-the-voice-map-a-thread-read)) | — | `umtool posts narrate <p> <item> --take --thread [--parents 0\|all] [--skip-parent <id>]… [--voice-for <handle>=<voice>]… [--dry-run] [--json]` | — | -| a derived take — a take run through the editor's `enhance` or `convert` (a stock synthetic voice: `zac`, `leah`, `orpheus:zac`, never a recording) into a NEW take, the original kept; enhance engines `deepfilternet` · `rnnoise`, convert `openvoice` · `seed-vc` (unnamed: the editor's settings.voice, recorded on the take); "not installed" until `archilyzer voice setup --engine <id>` | post bench, **run AI on take #n** (the op, an engine, a stock voice) → **Run → a new take**; a derived take's **Re-run**; a recording's **Re-record** with **then re-run the chain** | `umtool posts narrate <p> <item> --derive <n> --op enhance\|convert [--engine e] [--voice v]` | `op: "derive", from, op2, engine?, voice?` → `{jobId, file}` (or `{installed: false}`) · `GET ?project&id&job&file&derive=<from>&op=…` keeps it | +| a derived take — a take run through the editor's `enhance` or `convert` (a stock synthetic voice: `zac`, `leah`, `orpheus:zac`, never a recording) into a NEW take, the original kept; enhance engines `deepfilternet` · `rnnoise`, convert `openvoice` · `seed-vc` (unnamed: the editor's settings.voice, recorded on the take); "not installed" until `archilyzer voice setup --engine <id>`; a convert's **pitch** ([below](#the-pitch-a-converted-read-lands-on)) from a terminal | post bench, **run AI on take #n** (the op, an engine, a stock voice) → **Run → a new take**; a derived take's **Re-run**; a recording's **Re-record** with **then re-run the chain** | `umtool posts narrate <p> <item> --derive <n> --op enhance\|convert [--engine e] [--voice v] [--pitch target\|source\|contour] [--semitones n]` | `op: "derive", from, op2, engine?, voice?` → `{jobId, file}` (or `{installed: false}`) · `GET ?project&id&job&file&derive=<from>&op=…` keeps it | | delete a take (soft: its file to the post's `.trash/`) | post bench, the take's **Delete** | `--delete <n>` | `op: "delete", take` (an index) | | `narration.pick` — the take that plays | post bench, the take's **Pick** | `--pick <n>` (1 = the first, as `--list` shows) | `patch: {pick}` (an index) | | `narration.approved` — the picked take on this script, approved (a new script or pick takes it away) | post bench, **approved** | `--approve` · `--unapprove` | `patch: {approved: true \| null}` | @@ -1320,7 +1320,8 @@ different ones to compare … and try to maintain consistent voices for differen `castWrite` -- a token, an undo point a write, a broken file never overwritten): the CHARACTERS that recur across projects -- `{id, name, handles, voice, convert?, speakers?, avatar?, note?, narrator?}`. `voice` is a STOCK voice with its engine (`kokoro:am_michael`, `orpheus:zac`); `convert` the voice (and engine, openvoice | seed-vc) a -recording of them is converted to (default: `voice`); `speakers` the names their REAL voice goes by in a project's +recording of them is converted to (default: `voice`) and the **pitch** that converted read lands on (`pitch`, +`semitones`: [below](#the-pitch-a-converted-read-lands-on)); `speakers` the names their REAL voice goes by in a project's `speakers.json` -- a reference to compare a candidate with, never a target (the editor's convert op refuses a file; the cast holds no path). One character may be the `narrator` (a recording's default character). @@ -1349,12 +1350,12 @@ voice-convert) to the character's stock voice -- each a new take, the last picke | Knob | In umtool | From a terminal | Route | |---|---|---|---| -| the cast -- `<reports>/.umtool/cast.json` | **Voices** (`/projects/<p>/voices`, from the Cut tab's Reads and voices): **the cast** list, ✕ removes, **Undo the last cast change**; an audition's **Use everywhere** adds or changes a character | `umtool cast ls` · `add <id> --name … --voice kokoro:am_michael --handles a,b [--speakers Jeremy] [--convert-engine seed-vc] [--convert-voice …] [--narrator]` · `set <id> …` (`--add-handle`, `--remove-handle`, `--no-convert`) · `rm <id>` · `undo` | `POST /api/report/voices {op: "cast-rm" \| "cast-undo" \| "cast-set"}` | +| the cast -- `<reports>/.umtool/cast.json` | **Voices** (`/projects/<p>/voices`, from the Cut tab's Reads and voices): **the cast** list, ✕ removes, **Undo the last cast change**; an audition's **Use everywhere** adds or changes a character | `umtool cast ls` · `add <id> --name … --voice kokoro:am_michael --handles a,b [--speakers Jeremy] [--convert-engine seed-vc] [--convert-voice …] [--convert-pitch source\|contour\|target] [--convert-semitones n] [--narrator]` · `set <id> …` (`--add-handle`, `--remove-handle`, `--no-convert`) · `rm <id>` · `undo` | `POST /api/report/voices {op: "cast-rm" \| "cast-undo" \| "cast-set"}` | | a project's characters -- each one's voice now and where it comes from, its reads, its drift, its real voice | **Voices**: the characters table | `umtool cast project <p> [--json]` | `GET /api/report/voices?project` | | an audition | **Voices** → a character's **Audition**: the line, the candidates (engine, voice, Add), **Render** (a job: the editor's tts, then the closeness through the heavy slot), each played at one loudness, **▶ Play each in turn** (the real voice first) | `umtool cast audition <character\|@handle> --project <p> --voices kokoro:am_michael,kokoro:am_onyx,orpheus:zac [--text "…" \| --item <id> \| --line <n> \| --stock] [--no-score \| --score-only] [--json]` | `POST /api/report/voices {op: "audition", who, voices, text?, item?}` | | the voice a character reads in -- this project, or everywhere | an audition's **Use for this project** / **Use everywhere** | `umtool cast use <p> <character\|@handle> <voice> [--everywhere]` (the project's own override goes with `--everywhere`) | `POST … {op: "use", who, voice, scope}` | | the re-reads a voice change asks for | the confirm under the audition: the items, **Queue N re-reads** (steps of the queue: /jobs; each a new take, picked, awaiting approval) | `umtool cast reread <p> <character> [--dry-run]` | `POST … {op: "reread", who}` | -| a recording made a character's read | **Voices** → *a recording*: the item, as whom, drop a file, clean / convert, **Import** (a job) | `umtool posts narrate <p> <item> --recording <file> [--as <character>] [--no-clean] [--no-convert]` | `POST … multipart {op: "recording", item, as?, file}` | +| a recording made a character's read | **Voices** → *a recording*: the item, as whom, drop a file, clean / convert, **Import** (a job) | `umtool posts narrate <p> <item> --recording <file> [--as <character>] [--no-clean] [--no-convert] [--pitch …] [--semitones n]` | `POST … multipart {op: "recording", item, as?, file}` | ```sh umtool cast add thequartering --name TheQuartering --voice kokoro:am_michael --handles thequartering --speakers Jeremy @@ -1365,6 +1366,36 @@ umtool cast reread quartering-diet thequartering # each stale read m umtool posts narrate quartering-diet <item> --recording my-read.wav --as thequartering ``` +### The pitch a converted read lands on + +A converter given no pitch speaks every read at the STOCK voice's own: measured 11 Nov, reads with a median pitch of +128 to 237 Hz all came out at 196-199 Hz and a 152-321 Hz range came out as 165-240 Hz -- raising your voice for a +character, and most of your intonation, was thrown away. A convert's **pitch** says where the result's pitch comes +from (the editor's `voice-convert`: `pitch`, `semitones`): + +- **`target`** -- the stock voice's own pitch, as before. Either engine; the default until a character or + `settings.voice.convert.pitch` says otherwise. +- **`source`** -- the pitch you read at, as you read it: raise your voice and the result rises, drop it and it drops. + For a read ACTED at the character's pitch. +- **`contour`** -- your rises and falls, moved as a whole so their median sits on the stock voice's median: read in + your ordinary voice, and the character speaks in its own register with your intonation. +- **`semitones`** (-12 to 12) then moves a followed pitch (`source`, `contour`) up or down. With `target` it is + refused: nothing is followed to move. + +`source` and `contour` are **seed-vc's**, on its f0-conditioned model -- optional files, `archilyzer voice setup +--engine seed-vc --with f0` (1.49 GB); it is about twice as slow as seed-vc at the target's pitch. openvoice has one +pitch and refuses another; a followed pitch without the f0 files is refused naming that command. A parted take's +`contour` is measured once, on the whole take, and used for every part. + +| Knob | In umtool | From a terminal | Route | +|---|---|---|---| +| a character's convert pitch -- `convert.pitch`, `convert.semitones` in the cast: what every recording made that character's lands on | **Voices**: the cast row says it ("pitch: follows your pitch +2 st"), and the recording form's *as …* choice | `umtool cast set <id> --convert-engine seed-vc --convert-pitch source\|contour\|target [--convert-semitones n]` (the flags given are laid over the entry; `--no-convert` clears it) | `POST /api/report/voices {op: "cast-set", id, convertPitch?, convertSemitones?}` | +| one read's pitch -- this conversion only, over the character's | — | `umtool posts narrate <p> <item> --recording <file> [--as <character>] --pitch source\|contour\|target [--semitones n]` · `--derive <n> --op convert --engine seed-vc [--voice v] --pitch … [--semitones n]` | the editor's `POST /api/ops/voice-convert {…, pitch?, semitones?}` | +| the default for every conversion that names none | — | `settings.voice.convert.pitch`, `.semitones` ([SETTINGS.md](../../SETTINGS.md)) | — | + +A converted take's step keeps the pitch it was run at (`steps: [{op: "convert", engine, voice, pitch, semitones}]`), +so `--list` and a re-run say it; the target's own pitch is not recorded. + ## A caption (a chip explaining a phrase as it is read) `fx: [{kind: "caption", match, text, …}]` on a post item ([report-video.md](report-video.md#a-caption): the shape, diff --git a/umtool/lib/cli/groups.mjs b/umtool/lib/cli/groups.mjs @@ -72,8 +72,8 @@ export const GROUPS = [ " project's characters and their drift, an audition of candidate voices (scored against the real voice)", ], docs: [ - ["`cast [ls] \\| add <id> --name … --voice <engine:voice> [--handles a,b] [--speakers …] [--convert-engine e] [--convert-voice v] [--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 and their STOCK voices, a layer under each project's voice map; one writer, an undo point a write"], + ["`cast [ls] \\| add <id> --name … --voice <engine:voice> [--handles a,b] [--speakers …] [--convert-engine e] [--convert-voice v] [--convert-pitch target\\|source\\|contour] [--convert-semitones n] [--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 and their STOCK voices, a layer under each project's voice map; one writer, an undo point a write. A character's `convert` entry is what a recording of them is made into: the stock voice, the engine, and 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; `set` lays the flags given over the entry). A followed pitch on an engine that has none, or semitones with nothing followed: **exit 1**"], ["`cast project <project> [--json]` · `cast use <project> <character\\|@handle> <voice> [--everywhere]` · `cast reread <project> <character> [--dry-run]`", "a project's characters (each voice now, where it comes from, its stale reads), the voice for this project or everywhere, and the re-reads that asks for"], ["`cast audition <character\\|@handle> --voices a,b,… [--project <p>] [--text \"…\" \\| --item <id> \\| --line <n> \\| --stock] [--no-score \\| --score-only] [--json] [--progress ndjson]`", @@ -1026,8 +1026,8 @@ export const GROUPS = [ "**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 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**"], - ["`posts narrate <project> <item> --recording <file> [--as <character>] [--no-clean] [--no-convert] [--label l]`", - "**a recording made a character's read**: kept (recorded), cleaned (voice-enhance), converted (voice-convert) to the character's STOCK voice, each a new take, the last picked"], + ["`posts narrate <project> <item> --recording <file> [--as <character>] [--no-clean] [--no-convert] [--pitch target\\|source\\|contour] [--semitones n] [--label l]` · `<item> --derive <n> --op convert [--engine e] [--voice v] [--pitch …] [--semitones n]`", + "**a recording made a character's read**: kept (recorded), cleaned (voice-enhance), converted (voice-convert) to the character's STOCK voice, each a new take, the last picked. **`--pitch`** is the pitch the converted read lands on ([knobs.md](knobs.md#the-pitch-a-converted-read-lands-on)): `target` the stock voice's own (the read's intonation flattened to it), `source` the pitch it was read at, `contour` the read's rises and falls moved to the stock voice's register; `--semitones` (-12…12) moves a followed one. Default: the character's `convert` entry, else the editor's `settings.voice.convert`. `source` and `contour` are seed-vc's, with its f0 model (`archilyzer voice setup --engine seed-vc --with f0`); what the editor cannot do it refuses in a sentence (**exit 1**); a value outside these, or a pitch on `--op enhance`: **exit 1**"], ["`posts fx <project> <item> add caption --match \"…\" --text \"…\" [--target post\\|quoted\\|parent:<i>] [--occurrence n] [--at s] [--lead s] [--hold s] [--place below\\|above\\|side]` · `add clock [--rewind auto\\|on\\|off] [--off]` · `set <n> [--text …] [--place …] [--rewind …]`", "a post item's **caption** ([report-video.md](report-video.md#a-caption), [knobs.md](knobs.md#a-caption-a-chip-explaining-a-phrase-as-it-is-read)): a chip explaining a phrase (any script: CJK drawn), up as it is read -- `--at`, else the take's word timings, else the reading estimate -- held `--hold` s, by the phrase and never over a word read while it is up; it waits for a word zoom. Its **clock** ([knobs.md](knobs.md#the-clock-each-posts-own-time-on-its-card-run-between-items)): the post's own time on the card, run from the clock item before it (forward; a REWIND when earlier: `--rewind`), `--off` not on this item. Through `updatePostFx`, refused in the build's words (**exit 1**); a zoom's knob on a caption, or a caption's on a zoom (**exit 1**)"], ["`posts clock <project> [on\\|off\\|default] [--zone <IANA zone>] [--json]`", diff --git a/umtool/lib/cli/verbs.mjs b/umtool/lib/cli/verbs.mjs @@ -130,10 +130,13 @@ export const VERBS = Object.freeze([ form("cast ls", "corpus", "the characters' voices across projects", [], { shape: "cast ls" }), form("cast add", "corpus", "a character: name, stock voice, handles", [ arg("id"), opt("--name", { required: true }), opt("--voice", { required: true, help: "engine:voice" }), opt("--handles", { help: "a,b" }), opt("--speakers", { help: "Name,…" }), - pick("--convert-engine", ["openvoice", "seed-vc"]), opt("--convert-voice", { help: "engine:voice" }), opt("--note"), bool("--narrator", "the recordings' default character"), + pick("--convert-engine", ["openvoice", "seed-vc"]), opt("--convert-voice", { help: "engine:voice" }), + pick("--convert-pitch", ["target", "source", "contour"], { help: "the pitch a converted read lands on" }), num("--convert-semitones", { help: "-12…12, moves a followed pitch" }), + opt("--note"), bool("--narrator", "the recordings' default character"), ]), form("cast set", "corpus", "change a character", [ arg("id"), opt("--name"), opt("--voice", { help: "engine:voice" }), opt("--handles"), opt("--speakers"), pick("--convert-engine", ["openvoice", "seed-vc"]), opt("--convert-voice"), + pick("--convert-pitch", ["target", "source", "contour"], { help: "the pitch a converted read lands on" }), num("--convert-semitones", { help: "-12…12, moves a followed pitch" }), opt("--note"), opt("--add-handle"), opt("--remove-handle"), bool("--no-convert"), bool("--narrator"), bool("--no-narrator"), ]), form("cast rm", "corpus", "a character out of the cast (an undo point)", [arg("id")]), @@ -460,7 +463,8 @@ function posts() { 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"), - num("--limit"), bool("--force"), file("--recording", { help: "a person's recording (a file of the project) made the read" }), opt("--as"), dry(), + 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(), ], { ...Q, ...POST_ITEM }), p("say", "draft", "the pronunciation lexicon", [pick("op", ["ls", "add", "remove", "try", "stale"], { required: true }), arg("word", { required: false, allowAt: true, help: "the word or phrase (try: the text)" }), arg("spoken", { required: false }), bool("--case"), opt("--item"), opt("--note")], { shape: "posts say <project> <op>" }), diff --git a/umtool/lib/report/cast.test.mjs b/umtool/lib/report/cast.test.mjs @@ -122,6 +122,30 @@ test("umtool cast ls/add/set/rm/undo: the characters across projects", async () r = await cast(["ls", "--json"]); assert.deepEqual(r.json().characters.map((c) => [c.id, c.voice, c.handles.join(",")]), [["hostman", "orpheus:zac", "hostman"], ["me", "kokoro:bm_george", "operator"]]); assert.equal(r.json().characters[1].narrator, true); + // The pitch a converted read lands on: laid over the convert entry, what makes no sense refused. + r = await cast(["set", "me", "--convert-pitch", "contour", "--convert-semitones", "2", "--json"]); + assert.equal(r.code, 0, r.text()); + assert.deepEqual(r.json().character.convert, { engine: "seed-vc", pitch: "contour", semitones: 2 }); + r = await cast(["set", "me", "--convert-voice", "kokoro:af_bella", "--json"]); + assert.deepEqual(r.json().character.convert, { engine: "seed-vc", pitch: "contour", semitones: 2, voice: "kokoro:af_bella" }, "the other keys kept"); + r = await cast(["ls"]); + assert.match(r.text(), /convert: seed-vc -> kokoro:af_bella, pitch contour \+2 st/); + r = await cast(["set", "me", "--convert-pitch", "target", "--json"]); + assert.deepEqual(r.json().character.convert, { engine: "seed-vc", pitch: "target", voice: "kokoro:af_bella" }, "the target's own pitch drops the semitones"); + for (const [args, re] of [ + [["--convert-pitch", "high"], /--convert-pitch is one of target, source, contour/], + [["--convert-semitones", "13"], /--convert-semitones is a number from -12 to 12/], + [["--convert-semitones", "2"], /semitones moves a followed pitch/], + [["--convert-engine", "openvoice", "--convert-pitch", "source"], /pitch "source" is seed-vc's: openvoice lands every read on the target's own pitch/], + ]) { + r = await cast(["set", "me", ...args]); + assert.equal(r.code, 1, args.join(" ")); + assert.match(r.text(), re); + } + assert.deepEqual((await readCast(ROOT)).cast.characters[1].convert, { engine: "seed-vc", pitch: "target", voice: "kokoro:af_bella" }, "a refusal writes nothing"); + r = await cast(["set", "me", "--no-convert"]); + r = await cast(["set", "me", "--convert-engine", "seed-vc"]); + assert.equal(r.code, 0, r.text()); r = await cast(["rm", "me"]); assert.equal(r.code, 0); r = await cast(["undo"]); @@ -278,4 +302,36 @@ test("a recording made a character's read: kept, cleaned (when the editor can), assert.equal(after.narration.takes[0].engine, "recorded", "the original kept"); assert.equal(r.disclosure, "Narration: voice converted to a synthetic voice (openvoice · kokoro:af_heart)"); await assert.rejects(importRecording(project, e, rec, { as: "nobody", ask: askOp }), /no such character/); + assert.equal("pitch" in picked.steps[0], false, "no pitch asked, none recorded"); + // THE PITCH: the character's own (its convert entry) goes to the editor, a flag for this read beats it, and the + // step keeps what the editor says it ran. + const bodies = []; + const askPitch = async (route, body) => { + if (route.endsWith("voice-enhance")) return askOp(route, body); + bodies.push(body); + await wavOf(body.out, VOICE_A, 2); + return { jobId: `conv-${bodies.length + 1}`, result: { engine: body.engine ?? "openvoice", voice: body.voice, pitch: body.pitch ?? "target", ...(body.pitch && body.pitch !== "target" ? { semitones: body.semitones ?? 0 } : {}) } }; + }; + await castWrite(castFile(ROOT), (chars) => { + const g = chars.find((c) => c.id === "guest"); + g.convert = { ...(g.convert ?? {}), engine: "seed-vc", pitch: "contour", semitones: 2 }; + return { changed: "updated" }; + }, { what: "set guest's convert pitch" }); + const own = await importRecording(project, (await manifest()).timeline.find((x) => x.id === "p-3"), rec, { ask: askPitch }); + assert.deepEqual([bodies[0].engine, bodies[0].pitch, bodies[0].semitones], ["seed-vc", "contour", 2]); + assert.equal(own.takes.at(-1).step, "converted to kokoro:af_heart (pitch: contour +2 st)"); + let now = (await manifest()).timeline.find((x) => x.id === "p-3"); + let step = now.narration.takes[now.narration.pick].steps[0]; + assert.deepEqual([step.pitch, step.semitones], ["contour", 2]); + await importRecording(project, now, rec, { pitch: "source", semitones: -1, ask: askPitch }); + assert.deepEqual([bodies[1].pitch, bodies[1].semitones], ["source", -1]); + // This read at the stock voice's own pitch: the character's semitones go with its pitch. + const flat = await importRecording(project, (await manifest()).timeline.find((x) => x.id === "p-3"), rec, { pitch: "target", ask: askPitch }); + assert.equal(bodies[2].pitch, "target"); + assert.equal("semitones" in bodies[2], false); + assert.equal(flat.takes.at(-1).step, "converted to kokoro:af_heart"); + now = (await manifest()).timeline.find((x) => x.id === "p-3"); + step = now.narration.takes[now.narration.pick].steps[0]; + assert.equal("pitch" in step, false); + assert.equal(own.disclosure, "Narration: voice converted to a synthetic voice (seed-vc · kokoro:af_heart)", "the disclosure line is what it was"); }); diff --git a/umtool/lib/report/castCli.mjs b/umtool/lib/report/castCli.mjs @@ -4,7 +4,7 @@ // // umtool cast [ls] [--json] // umtool cast add <id> --name "…" --voice <engine:voice> [--handles a,b] [--speakers Name,…] [--convert-engine e] -// [--convert-voice <engine:voice>] [--avatar …] [--note "…"] [--narrator] [--json] +// [--convert-voice <engine:voice>] [--convert-pitch target|source|contour] [--convert-semitones n] [--avatar …] [--note "…"] [--narrator] [--json] // umtool cast set <id> [the same flags] [--add-handle h] [--remove-handle h] [--no-convert] [--no-narrator] [--json] // umtool cast rm <id> [--json] · umtool cast undo [--json] // umtool cast project <p> [--json] @@ -15,7 +15,7 @@ // // Plain ESM: the CLI runs under bare node. import path from "node:path"; -import { CAST_CONVERT_ENGINES, characterOf, charactersOf, findCharacter, isQualifiedVoice } from "umtool-report-to-video/cast"; +import { CAST_CONVERT_ENGINES, CAST_CONVERT_PITCH, CAST_SEMITONES_MAX, characterOf, convertPitchErrors, convertPitchLabel, charactersOf, findCharacter, isQualifiedVoice } from "umtool-report-to-video/cast"; import { handleKey, voiceRefOf } from "umtool-report-to-video/post-say"; import { REPORTS_ROOT, resolveProject } from "../projects/core.mjs"; import { readManifest } from "../projects/report.mjs"; @@ -24,7 +24,8 @@ import { CastError, castFile, castForProject, castWrite, readCast, undoCast } fr export const CAST_USAGE = [ "usage: umtool cast [ls] [--json]", " umtool cast add <id> --name \"…\" --voice <engine:voice> [--handles a,b] [--speakers Name,…] [--convert-engine openvoice|seed-vc]", - " [--convert-voice <engine:voice>] [--avatar …] [--note \"…\"] [--narrator] [--json]", + " [--convert-voice <engine:voice>] [--convert-pitch target|source|contour] [--convert-semitones <n>]", + " [--avatar …] [--note \"…\"] [--narrator] [--json]", " umtool cast set <id> [those flags] [--add-handle h] [--remove-handle h] [--no-convert] [--no-narrator] [--json]", " umtool cast rm <id> [--json]", " umtool cast undo [--json]", @@ -36,7 +37,10 @@ export const CAST_USAGE = [ "", " THE CAST (<reports>/.umtool/cast.json, one writer, an undo point per write): the characters that recur across", " projects -- an id, a name, their handles (X handles / channel slugs), the STOCK voice they read in (engine:voice),", - " optionally the voice a recording of them is converted to (--convert-voice, its engine --convert-engine), the", + " optionally the voice a recording of them is converted to (--convert-voice, its engine --convert-engine) and the", + " PITCH that read lands on (--convert-pitch: target = the stock voice's own, the read's intonation flattened to it;", + " 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; source and contour are seed-vc's, with its f0 model), the", " names their REAL voice goes by in a project's speakers.json (--speakers: a reference to compare with, never a", " target), and one --narrator (a recording's default character). A project's narration/voices.json overrides it", " (umtool posts voices); every read asks the same function: the read's own voice, the project's map, the cast, the", @@ -53,7 +57,7 @@ export const CAST_USAGE = [ " each, picked, awaiting approval). Exit 0 done · 1 refused or failed · 2 usage.", ].join("\n"); -const VALUED = new Set(["--name", "--voice", "--handles", "--speakers", "--convert-engine", "--convert-voice", "--avatar", "--note", "--add-handle", "--remove-handle", "--voices", "--project", "--text", "--item", "--line", "--progress"]); +const VALUED = new Set(["--name", "--voice", "--handles", "--speakers", "--convert-engine", "--convert-voice", "--convert-pitch", "--convert-semitones", "--avatar", "--note", "--add-handle", "--remove-handle", "--voices", "--project", "--text", "--item", "--line", "--progress"]); const splitList = (v) => String(v ?? "").split(",").map((x) => x.trim()).filter(Boolean); function parse(args) { @@ -84,15 +88,33 @@ function fieldsOf(p) { if (p.str("--speakers") !== null) f.speakers = splitList(p.str("--speakers")); if (p.str("--avatar") !== null) f.avatar = p.str("--avatar"); if (p.str("--note") !== null) f.note = p.str("--note"); - if (p.str("--convert-engine") !== null || p.str("--convert-voice") !== null) { + if (["--convert-engine", "--convert-voice", "--convert-pitch", "--convert-semitones"].some((k) => p.str(k) !== null)) { const ce = p.str("--convert-engine"); if (ce !== null && !CAST_CONVERT_ENGINES.includes(ce)) throw new CastError(`--convert-engine is ${CAST_CONVERT_ENGINES.join(" or ")}`); - f.convert = { ...(ce ? { engine: ce } : {}), ...(p.str("--convert-voice") ? { voice: p.str("--convert-voice") } : {}) }; + const cp = p.str("--convert-pitch"); + if (cp !== null && !CAST_CONVERT_PITCH.includes(cp)) throw new CastError(`--convert-pitch is one of ${CAST_CONVERT_PITCH.join(", ")}`); + const cs = p.str("--convert-semitones") === null ? null : Number(p.str("--convert-semitones")); + if (cs !== null && !(p.str("--convert-semitones").trim() !== "" && Number.isFinite(cs) && Math.abs(cs) <= CAST_SEMITONES_MAX)) throw new CastError(`--convert-semitones is a number from -${CAST_SEMITONES_MAX} to ${CAST_SEMITONES_MAX}`); + // Only the keys given: `set` lays them over the character's entry (convertOver), `add` takes them as they are. + f.convert = { ...(ce ? { engine: ce } : {}), ...(p.str("--convert-voice") ? { voice: p.str("--convert-voice") } : {}), ...(cp ? { pitch: cp } : {}), ...(cs !== null ? { semitones: cs } : {}) }; } return f; } -const line = (c) => `${c.id.padEnd(16)} ${c.voice.padEnd(20)} ${c.name}${c.handles?.length ? ` ${c.handles.map((h) => `@${h}`).join(" ")}` : ""}${c.convert ? ` convert: ${c.convert.engine ?? "default"} -> ${c.convert.voice ?? c.voice}` : ""}${c.speakers?.length ? ` real voice: ${c.speakers.join(", ")}` : ""}${c.narrator ? " (the narrator)" : ""}${c.note ? ` -- ${c.note}` : ""}`; +/** + * A convert entry with the flags' keys laid over it, and what makes no sense together refused in a sentence: the + * target's own pitch drops the semitones (nothing is followed to move), 0 semitones is no entry. + */ +function convertOver(before, given) { + const cv = { ...(before ?? {}), ...given }; + if (given.pitch === "target" && given.semitones === undefined) delete cv.semitones; + if (cv.semitones === 0) delete cv.semitones; + const wrong = convertPitchErrors(cv); + if (wrong.length) throw new CastError(`convert: ${wrong[0]} (--convert-engine seed-vc --convert-pitch source|contour)`); + return cv; +} + +const line = (c) => `${c.id.padEnd(16)} ${c.voice.padEnd(20)} ${c.name}${c.handles?.length ? ` ${c.handles.map((h) => `@${h}`).join(" ")}` : ""}${c.convert ? ` convert: ${c.convert.engine ?? "default"} -> ${c.convert.voice ?? c.voice}${convertPitchLabel(c.convert) ? `, pitch ${convertPitchLabel(c.convert)}` : ""}` : ""}${c.speakers?.length ? ` real voice: ${c.speakers.join(", ")}` : ""}${c.narrator ? " (the narrator)" : ""}${c.note ? ` -- ${c.note}` : ""}`; async function projectOf(ref, reportsRoot) { const r = await resolveProject(ref, reportsRoot); @@ -164,13 +186,14 @@ export async function castCommand(args, { reportsRoot = REPORTS_ROOT, log = cons if (sub === "add") { if (at >= 0) throw new CastError(`${id} is in the cast already (umtool cast set ${id} …)`); if (!f.name || !f.voice) throw new CastError('cast add takes --name "…" and --voice <engine:voice>'); - const c = { id, name: f.name, handles: f.handles ?? [], voice: f.voice, ...(f.convert ? { convert: f.convert } : {}), ...(f.speakers ? { speakers: f.speakers } : {}), ...(f.avatar ? { avatar: f.avatar } : {}), ...(f.note ? { note: f.note } : {}), ...(p.has("--narrator") ? { narrator: true } : {}) }; + const c = { id, name: f.name, handles: f.handles ?? [], voice: f.voice, ...(f.convert ? { convert: convertOver(null, f.convert) } : {}), ...(f.speakers ? { speakers: f.speakers } : {}), ...(f.avatar ? { avatar: f.avatar } : {}), ...(f.note ? { note: f.note } : {}), ...(p.has("--narrator") ? { narrator: true } : {}) }; if (c.narrator) for (const x of chars) delete x.narrator; chars.push(c); return { changed: "added", character: c }; } if (at < 0) throw new CastError(`no ${id} in the cast (umtool cast ls)`); - const c = { ...chars[at], ...f }; + // The convert flags are laid over the entry: --convert-pitch alone keeps its engine and voice. + const c = { ...chars[at], ...f, ...(f.convert ? { convert: convertOver(chars[at].convert, f.convert) } : {}) }; for (const h of p.all("--add-handle").map(handleKey)) if (h && !c.handles.includes(h)) c.handles = [...c.handles, h]; for (const h of p.all("--remove-handle").map(handleKey)) c.handles = c.handles.filter((x) => x !== h); if (p.has("--no-convert")) delete c.convert; diff --git a/umtool/lib/report/postNarration.test.mjs b/umtool/lib/report/postNarration.test.mjs @@ -8,7 +8,7 @@ import { tmpdir } from "node:os"; import path from "node:path"; import { after, test } from "node:test"; import { postsCommand } from "./postsCli.mjs"; -import { importPatches, makeTake, mixPatchOf } from "./postNarrationCli.mjs"; +import { importPatches, makeTake, mixPatchOf, pitchFlags } from "./postNarrationCli.mjs"; import { fitPostItem, rmsFrames, scanAttachment, scoreWindows } from "./postFit.mjs"; import { manifestToken, updatePostNarration } from "./manifest.mjs"; import { postItemPlan } from "umtool-report-to-video/post-item"; @@ -292,6 +292,7 @@ test("a DERIVED take: run through the editor's op into a new take, the original }); assert.equal(asked.at(-1).route, "/api/ops/voice-enhance"); assert.equal("voice" in asked.at(-1).body, false); + assert.equal("pitch" in asked.at(-1).body, false); assert.equal(e1.take.voice, "operator"); assert.deepEqual([e1.take.steps[0].op, e1.take.steps[0].engine, e1.take.steps[0].voice], ["enhance", "deepfilternet", undefined]); // A convert that named no target: the stock voice the editor landed on. @@ -302,7 +303,26 @@ test("a DERIVED take: run through the editor's op into a new take, the original assert.equal("voice" in asked.at(-1).body, false); assert.equal(c1.take.voice, "zac"); assert.deepEqual([c1.take.steps[0].engine, c1.take.steps[0].voice], ["openvoice", "zac"]); - for (const k of [3, 2]) await deleteTake(p, (await manifest(p)).timeline[0], k); + // A convert's PITCH goes as asked, and the step keeps what the editor says it ran. + const c2 = await deriveTake(p, (await manifest(p)).timeline[0], { + from: 0, op: "convert", engine: "seed-vc", voice: "kokoro:af_bella", pitch: "contour", semitones: 2, + ask: async (route, body) => { asked.push({ route, body }); wav(body.out, 1.5); return { jobId: "job-p", result: { op: "convert", engine: "seed-vc", voice: "af_bella", pitch: "contour", semitones: 2, f0: { targetHz: 197.5, sourceHz: 208.8, shiftSemitones: 1.04 } } }; }, + }); + assert.deepEqual([asked.at(-1).body.pitch, asked.at(-1).body.semitones], ["contour", 2]); + assert.deepEqual([c2.take.steps[0].pitch, c2.take.steps[0].semitones, c2.take.voice], ["contour", 2, "af_bella"]); + // Asked of an enhance, a pitch is not sent; the flags' values are checked in their own names. + const e2 = await deriveTake(p, (await manifest(p)).timeline[0], { + from: 0, op: "enhance", pitch: "source", semitones: 2, + ask: async (route, body) => { asked.push({ route, body }); wav(body.out, 1.5); return { jobId: "job-e2", result: { op: "enhance", engine: "deepfilternet" } }; }, + }); + assert.deepEqual(["pitch" in asked.at(-1).body, "semitones" in asked.at(-1).body, "pitch" in e2.take.steps[0]], [false, false, false]); + const flag = (o) => pitchFlags((k) => o[k] ?? null); + assert.deepEqual(flag({}), {}); + assert.deepEqual(flag({ "--pitch": "source", "--semitones": "-2.5" }), { pitch: "source", semitones: -2.5 }); + assert.throws(() => flag({ "--pitch": "up" }), /--pitch is one of target, source, contour \(got up\)/); + assert.throws(() => flag({ "--semitones": "20" }), /--semitones is a number from -12 to 12 \(got 20\)/); + assert.throws(() => flag({ "--semitones": "" }), /--semitones is a number/); + for (const k of [5, 4, 3, 2]) await deleteTake(p, (await manifest(p)).timeline[0], k); // An op the editor has no engine for. const { OpNotInstalled } = await import("umtool-report-to-video/narrate-via-editor"); await assert.rejects( diff --git a/umtool/lib/report/postNarrationCli.mjs b/umtool/lib/report/postNarrationCli.mjs @@ -26,6 +26,7 @@ import { promisify } from "node:util"; import { NARRATION_INDEX, POST_DERIVE_OPS, POST_DERIVE_ROUTES, derivedFileOf, draftScript, takeIdOf, isNarrated, nextTakeNumber, pickedTake, postIdOf, postNarrationKnobs, takeFileOf, takesDirOf, } from "umtool-report-to-video/post-narration"; +import { CAST_CONVERT_PITCH, CAST_SEMITONES_MAX } from "umtool-report-to-video/cast"; import { excerptSpansOf, postItemPlan, postReadText } from "umtool-report-to-video/post-item"; import { partRoles } from "umtool-report-to-video/post-thread"; import { spokenRead } from "umtool-report-to-video/post-redact"; @@ -45,6 +46,9 @@ export const NARRATE_USAGE = [ " [--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=… rate=… pace=fast|normal] [--json]", " umtool posts narrate <project> <item> --recording <file> [--as <character>] [--no-clean] [--no-convert]", + " [--pitch target|source|contour] [--semitones <n>]", + " umtool posts narrate <project> <item> --derive <n> --op enhance|convert [--engine e] [--voice v]", + " [--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] [--force] [--dry-run]", " umtool posts narrate <project> <item> … --in-take <take> any of these on a TAKE of the project: the pick, a new", @@ -71,6 +75,12 @@ export const NARRATE_USAGE = [ " narrator) -- each a new take, the last picked, the disclosure line said.", " --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", + " read lands on -- target: the stock voice's own (the read's intonation is flattened to it); source: the pitch it", + " was read at (raise your voice and it rises); contour: the read's rises and falls, moved as a whole to the stock", + " voice's register; --semitones (-12 to 12) then moves a followed pitch. Default: the character's own (umtool cast", + " set <id> --convert-pitch …), else the editor's (settings.voice.convert). source and contour are seed-vc's, with", + " its f0 model (archilyzer voice setup --engine seed-vc --with f0); the editor refuses what it cannot do.", " A narrated post lasts lead + its read + tail + linger (1.8 s); a longer video is cut to that -- its best part,", " pace=fast plays a post (or, with --cut, every post) back to back: lead 0.1, tail 0.15, ramp 0.3, linger 0.45 --", " unless it sets one itself; pace=normal the cut's gaps.", @@ -522,6 +532,7 @@ export async function narrateCommand(project, words, flags, { json = false, dryR // A RECORDING made a character's read: kept as a take (the original), cleaned, converted to its stock voice. const r = await importRecording(project, e, str("--recording"), { as: str("--as"), label: str("--label") ?? "operator", clean: !flags.has("--no-clean"), convert: !flags.has("--no-convert"), note: str("--note"), + ...pitchFlags(str), emit: (_ev, f) => !json && f?.message && out(f.message), }); if (json) out(JSON.stringify({ ok: true, id: e.id, ...r }, null, 2)); @@ -537,7 +548,9 @@ export async function narrateCommand(project, words, flags, { json = false, dryR if (!Number.isInteger(k) || k < 1) throw new NarrateError("--derive takes a take's number as --list shows it (1 = the first)"); const op = str("--op") ?? ""; try { - const r = await deriveTake(project, e, { from: k - 1, op, engine: str("--engine"), voice: str("--voice"), emit: (_ev, f) => !json && f?.message && out(f.message) }); + const pitched = pitchFlags(str); + if (op !== "convert" && (pitched.pitch !== undefined || pitched.semitones !== undefined)) throw new NarrateError("--pitch and --semitones are a convert's (--op convert): an enhance keeps the read's own pitch"); + const r = await deriveTake(project, e, { from: k - 1, op, engine: str("--engine"), voice: str("--voice"), ...pitched, emit: (_ev, f) => !json && f?.message && out(f.message) }); if (json) out(JSON.stringify({ ok: true, id: e.id, take: r.take, token: r.result.token }, null, 2)); else out(`${e.id}: take ${r.take.file} (${r.take.seconds} s), from take ${k} by ${op}, picked`); return 0; @@ -659,16 +672,34 @@ export async function fitCommand(project, refs, { all = false, linger = null, js return 0; } +/** `--pitch` / `--semitones` as a convert takes them (only those given); a value the editor would refuse anyway is refused here, in the flag's name. */ +export function pitchFlags(str) { + const out = {}; + const p = str("--pitch"); + if (p !== null) { + if (!CAST_CONVERT_PITCH.includes(p)) throw new NarrateError(`--pitch is one of ${CAST_CONVERT_PITCH.join(", ")} (got ${p || "nothing"})`); + out.pitch = p; + } + const s = str("--semitones"); + if (s !== null) { + const n = Number(s); + if (s.trim() === "" || !Number.isFinite(n) || Math.abs(n) > CAST_SEMITONES_MAX) throw new NarrateError(`--semitones is a number from -${CAST_SEMITONES_MAX} to ${CAST_SEMITONES_MAX} (got ${s || "nothing"})`); + out.semitones = n; + } + return out; +} + /** * A DERIVED TAKE (post-narration.mjs: "run AI on recorded voice"): take * `from` (an index) run through the editor's `op` (`enhance`, `convert`) into * a NEW take -- source `{kind: "take", from: <its id>}`, its step recorded -- * the original untouched; a parted take part by part (its parts kept). The * editor's op is a job (`POST /api/ops/voice-enhance|voice-convert` with - * `{file, out, engine?, voice?, params?, parts?}`); one it has no engine for - * throws OpNotInstalled. + * `{file, out, engine?, voice?, pitch?, semitones?, params?, parts?}`); one it has no engine for + * throws OpNotInstalled. A convert's `pitch` / `semitones` (the pitch the read lands on: the editor's voice-convert) + * go as asked and are kept on the take's step as the editor says it ran them. */ -export async function deriveTake(project, e, { from, op, engine = null, voice = null, params = null, emit = () => {}, editor = null, ask = null } = {}) { +export async function deriveTake(project, e, { from, op, engine = null, voice = null, pitch = null, semitones = null, params = null, emit = () => {}, editor = null, ask = null } = {}) { const takes = e.narration?.takes ?? []; const t = takes[from]; if (!t) throw new NarrateError(`${e.id} has no take ${from + 1}`); @@ -688,6 +719,7 @@ export async function deriveTake(project, e, { from, op, engine = null, voice = const body = { file: abs(t.file), out: abs(rel), ...(engine ? { engine } : {}), ...(target ? { voice: target } : {}), ...(params ? { params } : {}), + ...(op === "convert" && pitch ? { pitch } : {}), ...(op === "convert" && typeof semitones === "number" ? { semitones } : {}), ...(parts ? { parts: t.parts.map((p, k) => ({ file: abs(p.file), out: abs(parts[k].file) })) } : {}), }; const askOp = ask ?? (await import("umtool-report-to-video/narrate-via-editor")).askEditorOp; @@ -697,11 +729,15 @@ export async function deriveTake(project, e, { from, op, engine = null, voice = // The editor's defaults, when the ask named none: the engine it ran, the stock voice it landed on. const ran = engine ?? (typeof said?.engine === "string" ? said.engine : null); const landed = op === "convert" ? (target ?? (typeof said?.voice === "string" ? said.voice : null)) : null; + // The pitch it landed on, as the editor ran it (its default when none was asked); the target's own is not a step's news. + const ranPitch = op === "convert" ? (typeof said?.pitch === "string" ? said.pitch : pitch) : null; + const ranSemitones = typeof said?.semitones === "number" ? said.semitones : semitones; + const pitched = ranPitch && ranPitch !== "target" ? { pitch: ranPitch, ...(typeof ranSemitones === "number" && ranSemitones !== 0 ? { semitones: ranSemitones } : {}) } : {}; const take = { // A take's voice is the bare stock voice ("am_michael"); its step keeps the target as asked ("kokoro:am_michael"). file: rel, engine: "derived", voice: (landed ? String(landed).split(":").pop() : null) ?? t.voice ?? "?", seconds: m.seconds ?? t.seconds, source: { kind: "take", from: takeIdOf(t) }, - steps: [{ op, ...(ran ? { engine: ran } : {}), ...(landed ? { voice: landed } : {}), ...(params ? { params } : {}), ranAt: new Date().toISOString(), job: jobId }], + steps: [{ op, ...(ran ? { engine: ran } : {}), ...(landed ? { voice: landed } : {}), ...pitched, ...(params ? { params } : {}), ranAt: new Date().toISOString(), job: jobId }], script: t.script ?? e.narration?.script ?? "", at: new Date().toISOString(), jobId, ...(Number.isFinite(m.lufs) ? { lufs: m.lufs } : {}), ...(parts ? { parts } : {}), }; @@ -715,16 +751,17 @@ export async function deriveTake(project, e, { from, op, engine = null, voice = * as a RECORDED take (postRecord.mjs keepRecording: trimmed, levelled -- the original, never overwritten), then a * derived take CLEANED by the editor's voice-enhance (skipped, and said, when it has no engine for it), then a * derived take CONVERTED by its voice-convert to the character's STOCK voice (cast.mjs convertTargetOf: its convert - * voice, else its voice) -- the character `as` names (an id, a handle), else the post's author's in the cast, else + * voice, else its voice) at the PITCH asked (`pitch`, `semitones`), else the character's own (its convert entry's), + * else the editor's -- the character `as` names (an id, a handle), else the post's author's in the cast, else * the cast's narrator; none: kept as recorded (and cleaned). Each step a new take, the last one picked, with the * disclosure line the cut will carry. Returns `{ takes: [{ step, file }], picked, notes, disclosure, character }`. */ -export async function importRecording(project, e0, file, { as = null, label = "operator", clean = true, convert = true, note = null, emit = () => {}, editor = null, ask = null } = {}) { +export async function importRecording(project, e0, file, { as = null, label = "operator", clean = true, convert = true, pitch = undefined, semitones = undefined, note = null, emit = () => {}, editor = null, ask = null } = {}) { const abs = path.resolve(String(file ?? "")); if (!(await stat(abs).catch(() => null))?.isFile()) throw new NarrateError(`--recording takes a sound file (no ${file})`); const { keepRecording } = await import("./postRecord.mjs"); const { castForProject } = await import("./castStore.mjs"); - const { characterOf, convertTargetOf, findCharacter, narratorOf } = await import("umtool-report-to-video/cast"); + const { characterOf, convertPitchLabel, convertTargetOf, findCharacter, narratorOf } = await import("umtool-report-to-video/cast"); const { postNarrationDisclosure } = await import("umtool-report-to-video/post-narration"); const castRead = await castForProject(project.dir); const character = as ? findCharacter(castRead.cast, String(as).replace(/^@+/, "")) : characterOf(castRead.cast, e0.handle) ?? narratorOf(castRead.cast); @@ -753,9 +790,13 @@ export async function importRecording(project, e0, file, { as = null, label = "o if (!character) notes.push("not converted: no character to convert to (--as <character>, or the post's author or a narrator in the cast: umtool cast add …)"); else { const target = convertTargetOf(character); + // The pitch asked for this read, else the character's; semitones asked of the target's own pitch are dropped + // with it (a character kept at "contour +2" read once with --pitch target). + const pitched = { pitch: pitch ?? target.pitch ?? null, semitones: semitones ?? (pitch === "target" ? null : target.semitones ?? null) }; try { - const r = await deriveTake(project, e, { from, op: "convert", engine: target.engine, voice: target.voice, emit, editor, ask }); - takes.push({ step: `converted to ${target.voice}`, file: r.take.file }); + const r = await deriveTake(project, e, { from, op: "convert", engine: target.engine, voice: target.voice, ...pitched, emit, editor, ask }); + const how = convertPitchLabel(r.take.steps?.[0]); + takes.push({ step: `converted to ${target.voice}${how ? ` (pitch: ${how})` : ""}`, file: r.take.file }); e = await fresh(); } catch (err) { if (err?.name !== "OpNotInstalled" && !/not installed/i.test(String(err?.message))) throw err; diff --git a/umtool/lib/report/postsCli.mjs b/umtool/lib/report/postsCli.mjs @@ -195,7 +195,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", "--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"]); +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"]); /** The valued flags that may be given more than once (each value kept, in order). */ const MULTI = new Set(["--skip-parent", "--voice-for"]); const SLUG_RE = /^[A-Za-z0-9._-]+$/; diff --git a/umtool/report-to-video/cast.mjs b/umtool/report-to-video/cast.mjs @@ -10,6 +10,8 @@ // "handles": ["thequartering"], // X handles / channel slugs (no @, lower case) // "voice": "kokoro:am_michael", // <tts engine>:<stock voice> // "convert": { "engine": "seed-vc", "voice": "kokoro:am_michael" }, // a recording made his (optional) +// // + "pitch": "source" | "contour" | "target", "semitones": -12…12 -- the pitch a +// // converted read lands on (seed-vc; the editor's voice-convert, CAST_CONVERT_PITCH) // "speakers": ["Jeremy"], // his REAL voice's name in a project's speakers.json // "avatar": "…", "note": "…", "narrator": true } ] } // @@ -37,6 +39,14 @@ export const CAST_KEYS = Object.freeze(["id", "name", "handles", "voice", "conve /** The tts engines a cast voice may name (the editor's tts op), and the convert engines (its voice-convert op). */ export const CAST_TTS_ENGINES = TTS_ENGINE_IDS; export const CAST_CONVERT_ENGINES = Object.freeze(["openvoice", "seed-vc"]); +/** + * The pitch a converted read lands on (the editor's voice-convert, common/lib/voiceApps.ts VoicePitch): the stock + * voice's own (`target`), the pitch it was read at (`source`), or the read's rises and falls at the stock voice's + * register (`contour`); `semitones` moves a followed one. The engines that can follow a pitch. + */ +export const CAST_CONVERT_PITCH = Object.freeze(["target", "source", "contour"]); +export const CAST_PITCH_ENGINES = Object.freeze(["seed-vc"]); +export const CAST_SEMITONES_MAX = 12; /** Which engine is heavy to run (the operator's rule: Orpheus pins ~8.5 GB; Kokoro first). */ export const ENGINE_WEIGHT = Object.freeze({ kokoro: "fast", "espeak-ng": "fast", orpheus: "heavy" }); @@ -84,8 +94,9 @@ export function validateCast(doc, where = "cast.json") { if (!isQualifiedVoice(c.voice)) errors.push(`${w}.voice must be a STOCK voice with its engine, "<${CAST_TTS_ENGINES.join("|")}>:<voice>" (got ${JSON.stringify(c.voice)})`); if (c.convert !== undefined) { const cv = c.convert; - if (!isObj(cv) || Object.keys(cv).some((k) => !["engine", "voice"].includes(k))) errors.push(`${w}.convert must be {engine?, voice?}`); + if (!isObj(cv) || Object.keys(cv).some((k) => !["engine", "voice", "pitch", "semitones"].includes(k))) errors.push(`${w}.convert must be {engine?, voice?, pitch?, semitones?}`); else { + errors.push(...convertPitchErrors(cv).map((m) => `${w}.convert.${m}`)); if (cv.engine !== undefined && !CAST_CONVERT_ENGINES.includes(cv.engine)) errors.push(`${w}.convert.engine must be one of ${CAST_CONVERT_ENGINES.join(", ")}`); if (cv.voice !== undefined && !isQualifiedVoice(cv.voice)) errors.push(`${w}.convert.voice must be a STOCK voice, "<engine>:<voice>" (never a file or a recording)`); } @@ -130,9 +141,41 @@ export function castVoiceMap(cast) { return out; } -/** A character's convert target -- what a recording is made into: its convert voice, else its voice. */ +/** + * What is wrong with a convert entry's pitch (`{engine?, pitch?, semitones?}`), as sentences that start at the key: + * the mode is one of CAST_CONVERT_PITCH, the semitones a number within CAST_SEMITONES_MAX, a followed pitch is an + * engine's that can follow one (CAST_PITCH_ENGINES; an entry with no engine takes the editor's default, which answers + * for itself), and semitones move a FOLLOWED pitch. The editor's op refuses the same things in its own words. + */ +export function convertPitchErrors(cv) { + const errors = []; + const { engine, pitch, semitones } = cv ?? {}; + if (pitch !== undefined && !CAST_CONVERT_PITCH.includes(pitch)) errors.push(`pitch must be one of ${CAST_CONVERT_PITCH.join(", ")}`); + if (semitones !== undefined && !(typeof semitones === "number" && Number.isFinite(semitones) && Math.abs(semitones) <= CAST_SEMITONES_MAX)) errors.push(`semitones must be a number from -${CAST_SEMITONES_MAX} to ${CAST_SEMITONES_MAX}`); + if (errors.length) return errors; + const follows = pitch === "source" || pitch === "contour"; + if (follows && engine !== undefined && !CAST_PITCH_ENGINES.includes(engine)) errors.push(`pitch "${pitch}" is ${CAST_PITCH_ENGINES.join(", ")}'s: ${engine} lands every read on the target's own pitch`); + if (semitones && !follows) errors.push(`semitones moves a followed pitch: it needs pitch source or contour`); + return errors; +} + +/** How a convert entry's (or a step's) pitch is said: "contour +2 st", "source", "" for the target's own. */ +export function convertPitchLabel(cv) { + if (!cv?.pitch || cv.pitch === "target") return ""; + const n = Number(cv.semitones) || 0; + return n ? `${cv.pitch} ${n > 0 ? "+" : "−"}${Math.abs(n)} st` : cv.pitch; +} + +/** + * A character's convert target -- what a recording is made into: its convert voice, else its voice -- and, when the + * entry says one, the pitch the read lands on (`pitch`, `semitones`; absent: the editor's default). + */ export function convertTargetOf(c) { - return { engine: c?.convert?.engine ?? null, voice: c?.convert?.voice ?? c?.voice ?? null }; + const cv = c?.convert; + return { + engine: cv?.engine ?? null, voice: cv?.voice ?? c?.voice ?? null, + ...(cv?.pitch !== undefined ? { pitch: cv.pitch } : {}), ...(cv?.semitones !== undefined ? { semitones: cv.semitones } : {}), + }; } /** The names a character's real voice may go by in a project's speakers.json (lower case, no punctuation). */ diff --git a/umtool/report-to-video/cast.test.mjs b/umtool/report-to-video/cast.test.mjs @@ -4,7 +4,7 @@ import assert from "node:assert/strict"; import { test } from "node:test"; import { - castDrift, castVoiceMap, characterOf, convertTargetOf, emptyCast, findCharacter, isQualifiedVoice, narratorOf, speakerFor, takeReads, validateCast, voiceDrift, voiceRefOf, + castDrift, castVoiceMap, characterOf, convertPitchLabel, convertTargetOf, emptyCast, findCharacter, isQualifiedVoice, narratorOf, speakerFor, takeReads, validateCast, voiceDrift, voiceRefOf, } from "./cast.mjs"; import { resolvePieceVoice, validateVoiceMap, voiceForPiece, voiceOverridesOf, voiceSourceOf } from "./post-say.mjs"; @@ -34,6 +34,16 @@ test("validateCast: the shape, ids, one owner a handle, stock voices only, one n assert.ok(validateCast({ ...emptyCast(), characters: [{ ...Q, voice: "/tmp/jeremy.wav" }] }).some((e) => /STOCK voice with its engine/.test(e))); assert.ok(validateCast({ ...emptyCast(), characters: [{ ...Q, convert: { voice: "me.wav" } }] }).some((e) => /never a file/.test(e))); assert.ok(validateCast({ ...emptyCast(), characters: [{ ...Q, narrator: true }, S] }).some((e) => /one character at most is the narrator/.test(e))); + // The pitch a converted read lands on: a mode, semitones in range, and only what an engine can follow. + const conv = (convert) => validateCast({ ...emptyCast(), characters: [{ ...Q, convert }] }); + assert.deepEqual(conv({ engine: "seed-vc", pitch: "contour", semitones: 2 }), []); + assert.deepEqual(conv({ pitch: "source" }), [], "no engine: the editor's default answers for itself"); + assert.deepEqual(conv({ engine: "openvoice", pitch: "target" }), []); + assert.ok(conv({ pitch: "high" }).some((e) => /convert\.pitch must be one of target, source, contour/.test(e))); + assert.ok(conv({ pitch: "source", semitones: 13 }).some((e) => /convert\.semitones must be a number from -12 to 12/.test(e))); + assert.ok(conv({ engine: "openvoice", pitch: "contour" }).some((e) => /convert\.pitch "contour" is seed-vc's: openvoice lands every read on the target's own pitch/.test(e))); + assert.ok(conv({ engine: "seed-vc", semitones: 2 }).some((e) => /convert\.semitones moves a followed pitch/.test(e))); + assert.ok(conv({ engine: "seed-vc", speed: 2 }).some((e) => /convert must be \{engine\?, voice\?, pitch\?, semitones\?\}/.test(e))); assert.ok(validateCast({ ...emptyCast(), characters: [{ ...Q, handles: ["@TheQuartering"] }] }).some((e) => /lower case, no @/.test(e))); assert.ok(validateCast({ ...emptyCast(), characters: [{ ...Q, extra: 1 }] }).some((e) => /extra is not a character key/.test(e))); }); @@ -47,6 +57,8 @@ test("a character by handle, id or name; the narrator; a recording's target; the assert.deepEqual(castVoiceMap(cast), { thequartering: "kokoro:am_michael", madamsavvy: "orpheus:tara" }); assert.deepEqual(convertTargetOf(S), { engine: "seed-vc", voice: "orpheus:tara" }); assert.deepEqual(convertTargetOf({ ...Q, convert: { voice: "kokoro:am_onyx" } }), { engine: null, voice: "kokoro:am_onyx" }); + assert.deepEqual(convertTargetOf({ ...S, convert: { engine: "seed-vc", pitch: "contour", semitones: 2 } }), { engine: "seed-vc", voice: "orpheus:tara", pitch: "contour", semitones: 2 }); + assert.deepEqual([convertPitchLabel(undefined), convertPitchLabel({ pitch: "target" }), convertPitchLabel({ pitch: "source" }), convertPitchLabel({ pitch: "contour", semitones: 2 }), convertPitchLabel({ pitch: "source", semitones: -1.5 })], ["", "", "source", "contour +2 st", "source −1.5 st"]); const speakers = [{ name: "Jeremy" }, { name: "Melonie Mac" }]; assert.equal(speakerFor(Q, speakers)?.name, "Jeremy"); assert.equal(speakerFor({ id: "mm", name: "MelonieMac", handles: [] }, speakers)?.name, "Melonie Mac", "the name, its punctuation and case aside"); diff --git a/umtool/report-to-video/post-narration.mjs b/umtool/report-to-video/post-narration.mjs @@ -49,6 +49,8 @@ export const POST_TAKE_ENGINES = Object.freeze([...POST_NARRATION_ENGINES, "reco * { kind: "recorded", voice } a person's own read, recorded on the bench * { kind: "take", from: <take id> } DERIVED: a new take made from another * steps [{ op, engine?, params?, ranAt, job? }] the processing that made a derived take + * (a convert's also `voice`, the stock target, and -- when the read's pitch was FOLLOWED rather than + * flattened to the stock voice's -- `pitch: "source" | "contour"` and `semitones`, as the editor ran them) * * A derived take never overwrites the one it came from. Its ops are the * editor's (each a job, like tts): `enhance` (denoise, level, de-reverb) and @@ -190,7 +192,7 @@ const MIX_KEYS = ["lead", "tail", "ramp", "linger", "clip", "wet", "lowpassHz", const RENDER_KEYS = new Set([...MIX_KEYS.filter((k) => k !== "attach"), "engine", "voice", "follow", "thread"]); const ITEM_KEYS = new Set([...MIX_KEYS, "script", "excerpt", "engine", "voice", "speed", "takes", "pick", "approved", "off", "window"]); const TAKE_KEYS = new Set(["file", "engine", "voice", "seconds", "script", "at", "note", "speed", "lufs", "jobId", "parts", "label", "source", "steps", "words", "slurs", "lexicon", "read"]); -const STEP_KEYS = new Set(["op", "engine", "voice", "params", "ranAt", "job", "drop", "tempo", "spans", "pauses", "revoice"]); +const STEP_KEYS = new Set(["op", "engine", "voice", "pitch", "semitones", "params", "ranAt", "job", "drop", "tempo", "spans", "pauses", "revoice"]); // `role` (post-thread.mjs): the text a part reads -- "post", "quoted", "parent:<i>", "media:<i>"; `voice`, `piece`: the batch's; // `engine`: the part's own when it is not the take's (a cast voice that names its engine: postThreadRead.mjs). // `tempo`: the part's reading speed in the take's file against its first read (a `tempo` step's; absent: 1). @@ -661,6 +663,9 @@ export function validatePostNarration(e) { if (!isObj(st) || !(POST_DERIVE_OPS.includes(st.op) || POST_LOCAL_OPS.includes(st.op))) errors.push(`${tw}.steps[${k}].op must be one of ${[...POST_DERIVE_OPS, ...POST_LOCAL_OPS].join(", ")}`); else { for (const key of Object.keys(st)) if (!STEP_KEYS.has(key)) errors.push(`${tw}.steps[${k}].${key} is not a step key`); + // A convert's followed pitch, as the editor ran it. + if (st.pitch !== undefined && !["target", "source", "contour"].includes(st.pitch)) errors.push(`${tw}.steps[${k}].pitch must be target, source or contour`); + if (st.semitones !== undefined && !(fin(st.semitones) && Math.abs(st.semitones) <= 12)) errors.push(`${tw}.steps[${k}].semitones must be a number from -12 to 12`); // A re-join's record: what it left out (a piece, "part <n>", "url"). if (st.drop !== undefined && !(Array.isArray(st.drop) && st.drop.length <= 200 && st.drop.every((d) => typeof d === "string"))) errors.push(`${tw}.steps[${k}].drop must be a list of what it left out`); // A tempo step's record: each run of parts ("4-16", "21") and the tempo it reads at.