Archilyzer · Source

archilyzer

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

commit 553dafbf20ddc25547465b595da78312046af47c
parent 5a36e5f87389c122636f1d0b95450856c1a30435
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed, 11 Nov 2026 18:48:56 -0500

umtool: the Voices page edits a character's two presets (the cast's or this video's own), keeps this video's own characters (anonymous ones, Add to the pool, Keep in this video only) and the items read as a character of their own; the bench's take asks its character's speed

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

Diffstat:
Mumtool/app/api/report/post-narration/route.ts | 20+++++++++++++-------
Mumtool/app/api/report/voices/route.ts | 91+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
Aumtool/components/projects/CharacterPresets.tsx | 379+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/components/projects/VoicesPanel.tsx | 118++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------
4 files changed, 584 insertions(+), 24 deletions(-)

diff --git a/umtool/app/api/report/post-narration/route.ts b/umtool/app/api/report/post-narration/route.ts @@ -21,8 +21,8 @@ import { fitPostItem } from "@/lib/report/postFit.mjs"; import { itemReadVoice } from "@/lib/report/readVoice.mjs"; import { projectRedaction } from "@/lib/report/postRedaction.mjs"; import { spokenRead } from "umtool-report-to-video/post-redact"; -import { characterOf, convertTargetOf, narratorOf } from "umtool-report-to-video/cast"; -import { castForProject } from "@/lib/report/castStore.mjs"; +import { recordedPresetOf, shownNameOf } from "umtool-report-to-video/cast"; +import { readLayers } from "@/lib/report/characterLayers.mjs"; import { derivePitchOf, deriveRefusalOf, stepPitchOf } from "@/lib/report/derivePitch.mjs"; export const dynamic = "force-dynamic"; @@ -89,9 +89,12 @@ export async function GET(request: Request) { // What a convert of this post defaults to (`posts narrate --recording`'s rule: the author's character, else the narrator). const e = postsOf(m).find((x) => x.id === id); if (!e) return Response.json({ error: `no post item ${id}` }, { status: 404 }); - const { cast } = await castForProject(r.project.dir); - const c = characterOf(cast, String((e as { handle?: unknown }).handle ?? "")) ?? narratorOf(cast); - return Response.json({ character: c ? { id: c.id, name: c.name } : null, convert: c ? convertTargetOf(c) : null }, { headers: noStore }); + // The chain a recording asks (cast.mjs characterForRead): the item's own character, this video's for the author, the + // cast's, the narrator -- and its recorded preset (what the record page will read: the direction, clean, trim). + const who = (await readLayers(r.project.dir)).characterForRead(e); + const c = who?.character ?? null; + const preset = c ? recordedPresetOf(c) : null; + return Response.json({ character: c ? { id: c.id, name: shownNameOf(c), layer: who.layer } : null, convert: preset ? preset.convert : null, ...(preset ? { recorded: { enhance: preset.enhance, trim: preset.trim, direction: preset.direction } } : {}) }, { headers: noStore }); } if (id && job) { // A GET that WRITES the manifest (a job followed to done): the proxy passes reads, so an <img> on another site @@ -239,7 +242,8 @@ async function postHere(request: Request) { const k = postNarrationKnobs(e, (m.render ?? {}) as Record<string, unknown>); const script = String(body.script ?? e.narration?.script ?? "").trim(); if (!script) return Response.json({ error: `${id} has no script to read` }, { status: 400 }); - // The voice: the one asked for, the project's voice map, the CAST, the narrator's -- a single read's rule (readVoice.mjs). + // The voice: the one asked for, the item's own character, the project's characters and voice map, the CAST, the + // narrator's -- a single read's rule (readVoice.mjs). const said = await itemReadVoice(r.project, e, { render: (m.render ?? {}) as Record<string, unknown>, engine: typeof body.engine === "string" && body.engine ? body.engine : null, @@ -251,7 +255,9 @@ async function postHere(request: Request) { const dir = path.join(r.project.dir, ...takesDirOf(pid).split("/")); await mkdir(dir, { recursive: true }); const rel = takeFileOf(pid, nextTakeNumber(e, await readdir(dir).catch(() => [])), engine, voice); - const speed = body.speed === undefined || body.speed === null || engine === "orpheus" ? undefined : Number(body.speed); + // Its speed: the one asked for, else its character's (the synthetic preset's that answered for the voice). + const askedSpeed = body.speed === undefined || body.speed === null ? (said as { speed?: number }).speed : Number(body.speed); + const speed = askedSpeed === undefined || askedSpeed === null || engine === "orpheus" ? undefined : Number(askedSpeed); // What the voice SAYS: the script with every redacted term left out (post-redact.mjs), each slur as the cut's // filter has it (post-slurs.mjs) and the project's pronunciation lexicon applied (post-say.mjs); the script is kept as written. The bench cannot word-time a take as it is made, // so a beep falls back to skip here (the CLI's --take times it and beeps). diff --git a/umtool/app/api/report/voices/route.ts b/umtool/app/api/report/voices/route.ts @@ -32,7 +32,15 @@ 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?, convertPitch?, convertSemitones?, narrator? } +// POST { project, op: "cast-rm", id } | { op: "cast-undo" } | { op: "cast-set", id, convertEngine?, convertPitch?, convertSemitones?, narrator?, …the preset fields } +// POST { project, op: "character-set", scope: "cast" | "project", id, name?, voice?, speed?, convertEngine?, convertVoice?, convertPitch?, +// convertSemitones?, enhance?, trim?, trimPad?, direction?, handles?, anonymous?, shown? } a character's PRESETS (umtool cast set / +// cast project <p> set): "" or null for a field puts its default back +// POST { project, op: "character-add", id, name?, voice?, handles?, anonymous?, shown? } one of THIS VIDEO's own (cast project <p> add) +// POST { project, op: "character-rm", id } | { op: "characters-undo" } cast project <p> rm | undo +// POST { project, op: "character-pool", id } "Add to the pool": cast project <p> pool <id> +// POST { project, op: "character-keep", who, anonymous? } "Keep in this video only": cast project <p> keep <character|@handle> +// POST { project, op: "item-character", item, character: <id> | null } umtool posts character <p> <item> <id> | --clear // 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" }; @@ -50,6 +58,51 @@ async function cli(args: string[]) { return { code, json, error: code === 0 ? null : (json?.error as string | undefined) ?? (err.join("\n") || "refused") }; } +/** `umtool posts character …`, run here (its JSON, or its refusal in its words). */ +async function postsCli(args: string[]) { + const { postsCommand } = await import("@/lib/report/postsCli.mjs"); + const said: string[] = []; + const errs: string[] = []; + const code = await postsCommand([...args, "--json"], { root: REPORTS_ROOT, out: (x: string) => said.push(x), err: (x: string) => errs.push(x) }); + let json: Record<string, unknown> | null = null; + try { + json = JSON.parse(said.join("\n") || "null"); + } catch { + json = null; + } + return { code, json, error: code === 0 ? null : (errs.join("\n") || said.join("\n") || "refused").replace(/^umtool posts: /, "") }; +} + +/** + * A character's preset fields as the CLI's flags (castCli.mjs fieldsOf: it refuses what makes no sense). A field + * that is "" or null puts its default back; one that is absent is left as it is. + */ +function presetArgs(b: Record<string, unknown>): string[] { + const args: string[] = []; + const has = (k: string) => b[k] !== undefined; + const blank = (k: string) => b[k] === null || b[k] === ""; + const val = (k: string) => String(b[k]).trim(); + if (has("name") && !blank("name")) args.push("--name", val("name")); + if (has("handles")) args.push("--handles", (Array.isArray(b.handles) ? b.handles.map(String) : String(b.handles ?? "").split(",")).map((h) => h.trim()).filter(Boolean).join(",")); + if (has("voice")) args.push(...(blank("voice") ? ["--no-voice"] : ["--voice", val("voice")])); + if (has("speed")) args.push(...(blank("speed") ? ["--no-speed"] : ["--speed", val("speed")])); + if (has("convertEngine")) args.push("--convert-engine", blank("convertEngine") ? "default" : val("convertEngine")); + if (has("convertVoice")) args.push("--convert-voice", blank("convertVoice") ? "default" : val("convertVoice")); + if (has("convertPitch")) args.push("--convert-pitch", blank("convertPitch") ? "default" : val("convertPitch")); + if (has("convertSemitones")) args.push("--convert-semitones", blank("convertSemitones") ? "0" : val("convertSemitones")); + const onOff = (k: string) => (blank(k) ? "default" : b[k] === true || b[k] === "on" ? "on" : b[k] === false || b[k] === "off" ? "off" : val(k)); + if (has("enhance")) args.push("--enhance", onOff("enhance")); + if (has("trim")) args.push("--trim", onOff("trim")); + if (has("trimPad")) args.push("--trim-pad", blank("trimPad") ? "default" : val("trimPad")); + if (has("direction")) args.push("--direction", blank("direction") ? "" : val("direction")); + if (b.anonymous === true || b.anonymous === "on") args.push("--anonymous"); + if (b.anonymous === false || b.anonymous === "off") args.push("--no-anonymous"); + if (has("shown") && !blank("shown")) args.push("--shown", val("shown")); + if (b.narrator === true || b.narrator === "on") args.push("--narrator"); + if (b.narrator === false || b.narrator === "off") args.push("--no-narrator"); + return args; +} + /** The checkout's heavy-slot CLI, when this umtool sits in the checkout (speakerCheck.mjs's rule). */ function queueLockScript() { const file = path.join(/* turbopackIgnore: true */ UMTOOL_DIR, "..", "scripts", "queue-lock.mjs"); @@ -166,6 +219,8 @@ export async function POST(request: Request) { const r = await cli(["undo"]); return Response.json(r.code === 0 ? r.json : { error: r.error }, { status: r.code === 0 ? 200 : 400, headers }); } + const answer = (r: { code: number; json: Record<string, unknown> | null; error: string | null }) => Response.json(r.code === 0 ? r.json : { error: r.error }, { status: r.code === 0 ? 200 : 400, headers }); + const idOk = (v: string) => /^[a-z0-9][a-z0-9_-]{0,47}$/.test(v); if (op === "cast-set") { const args = ["set", s("id")]; if (s("convertEngine")) args.push("--convert-engine", s("convertEngine")); @@ -175,8 +230,36 @@ export async function POST(request: Request) { 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")); - const r = await cli(args); - return Response.json(r.code === 0 ? r.json : { error: r.error }, { status: r.code === 0 ? 200 : 400, headers }); + return answer(await cli(args)); + } + // A CHARACTER's PRESETS, the cast's or this video's own -- each the CLI's own command (castCli.mjs). + if (op === "character-set" || op === "character-add") { + const id = s("id"); + if (!idOk(id)) return Response.json({ error: "a character's id is lower case letters, digits, - and _" }, { status: 400 }); + const own = op === "character-add" || s("scope") === "project"; + const head = own ? ["project", project.id, op === "character-add" ? "add" : "set", id] : ["set", id]; + return answer(await cli([...head, ...presetArgs(b)])); + } + if (op === "character-rm") { + if (!idOk(s("id"))) return Response.json({ error: "which character?" }, { status: 400 }); + return answer(await cli(["project", project.id, "rm", s("id")])); + } + if (op === "characters-undo") return answer(await cli(["project", project.id, "undo"])); + if (op === "character-pool") { + if (!idOk(s("id"))) return Response.json({ error: "which character?" }, { status: 400 }); + return answer(await cli(["project", project.id, "pool", s("id")])); + } + if (op === "character-keep") { + const who = s("who"); + if (!/^@?[A-Za-z0-9_.-]{1,64}$/.test(who)) return Response.json({ error: "keep takes a cast character's id, or an author (@handle)" }, { status: 400 }); + return answer(await cli(["project", project.id, "keep", who, ...(b.anonymous === true ? ["--anonymous"] : []), ...(s("shown") ? ["--shown", s("shown")] : [])])); + } + if (op === "item-character") { + const item = s("item"); + if (!/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/.test(item)) return Response.json({ error: "which post item?" }, { status: 400 }); + const id = s("character"); + if (id && !idOk(id)) return Response.json({ error: "which character?" }, { status: 400 }); + return answer(await postsCli(["character", project.id, item, id || "--clear"])); } if (op === "recording") { const file = form?.get("file"); @@ -195,7 +278,7 @@ export async function POST(request: Request) { const job = startJob(`cast-recording ${project.id}`, [{ label: `${item}: the recording kept, cleaned, converted`, argv, cwd: path.join(/* turbopackIgnore: true */ UMTOOL_DIR, ".."), env: {}, timeoutMs: 45 * 60 * 1000 }], { project: project.id }); return Response.json({ ok: true, job: jobView(job), file: path.relative(project.dir, abs) }, { headers }); } - return Response.json({ error: "op must be audition, use, reread, cast-rm, cast-undo, cast-set or recording" }, { status: 400 }); + return Response.json({ error: "op must be audition, use, reread, cast-rm, cast-undo, cast-set, character-set, character-add, character-rm, characters-undo, character-pool, character-keep, item-character or recording" }, { status: 400 }); } catch (e) { const status = (e as { status?: number }).status ?? 400; return Response.json({ error: e instanceof Error ? e.message : String(e) }, { status, headers }); diff --git a/umtool/components/projects/CharacterPresets.tsx b/umtool/components/projects/CharacterPresets.tsx @@ -0,0 +1,379 @@ +"use client"; + +import { useState } from "react"; +import { buttonVariants } from "@/components/ui/button"; +import { cn } from "@/lib/utils"; + +// --------------------------------------------------------------------------- +// A CHARACTER IS A PRESET (components/projects/VoicesPanel.tsx; /api/report/voices; the CLI is `umtool cast set`, +// `umtool cast project <p> add|set|rm|undo|pool|keep`, `umtool posts character`). Works with the operator alone: +// every field is a form field, every write the CLI's own command -- nothing here needs an agent. +// +// PresetEditor one character's two presets: SYNTHETIC (the stock voice, its speed) and RECORDED (what a +// recording of them is made into: the stock voice it is converted to, the engine, the pitch +// and semitones, cleaned or not, its edges trimmed or not and the room kept, and a DIRECTION +// -- one line for the person reading, never sent to a model) -- the cast's or this video's own +// ProjectCharacters THIS VIDEO's OWN characters (narration/characters.json): people who must not enter the pool +// (anonymous ones are shown and said under "Anon 1" …), add one, remove one, undo, "Add to the +// pool"; and the post items that name a character of their own +// --------------------------------------------------------------------------- + +export type Convert = { engine?: string; voice?: string; pitch?: "target" | "source" | "contour"; semitones?: number }; +export type Synthetic = { voice?: string; speed?: number }; +export type Recorded = { convert?: Convert; enhance?: boolean; trim?: { on?: boolean; padMs?: number }; direction?: string }; +export type PresetCharacter = { + id: string; name: string; handles?: string[]; voice?: string; convert?: Convert; synthetic?: Synthetic; recorded?: Recorded; + speakers?: string[]; note?: string; narrator?: boolean; anonymous?: boolean; shown?: string; layer?: "cast" | "project"; +}; +export type Engine = { id: string; label: string; voices: string[]; defaultVoice: string; weight: string }; +export type ItemCharacter = { id: string; handle: string | null; character: string; found: boolean; layer: "cast" | "project" | null; name?: string; voice: { spec: string; from: string; speed?: number } }; +type Post = { id: string; handle: string; author: string; text: string }; +type PostFn = (body: Record<string, unknown>) => Promise<Record<string, unknown> | null>; + +const input = "rounded-[3px] border border-seam-2 bg-ground px-1.5 py-[3px] text-[11.5px] text-text outline-none focus:border-signal"; +const pretty = (spec: string) => spec.replace(":", " · "); + +/** A recorded preset in words: "a recording → kokoro · am_michael (seed-vc), pitch contour +2 st · not cleaned · …". */ +export function recordedWords(c: PresetCharacter): string { + const rec = c.recorded; + if (!rec) return ""; + const bits: string[] = []; + const cv = rec.convert; + if (cv) { + const n = Number(cv.semitones) || 0; + const pitch = cv.pitch && cv.pitch !== "target" ? `, pitch ${cv.pitch}${n ? ` ${n > 0 ? "+" : "−"}${Math.abs(n)} st` : ""}` : ""; + bits.push(`a recording → ${pretty(cv.voice ?? c.voice ?? "?")}${cv.engine ? ` (${cv.engine})` : ""}${pitch}`); + } + if (rec.enhance === false) bits.push("not cleaned"); + if (rec.trim?.on === false) bits.push("edges not trimmed"); + else if (typeof rec.trim?.padMs === "number") bits.push(`trim pad ${rec.trim.padMs} ms`); + if (rec.direction) bits.push(`direction: “${rec.direction}”`); + return bits.join(" · "); +} + +/** A stock voice picked as engine + voice; `none` (a label) offers "no voice of its own". */ +function VoicePick({ value, onChange, engines, none = null, name }: { value: string; onChange: (v: string) => void; engines: Engine[]; none?: string | null; name: string }) { + const at = value.indexOf(":"); + const eng = at > 0 ? value.slice(0, at) : ""; + const voice = at > 0 ? value.slice(at + 1) : ""; + const engine = engines.find((e) => e.id === eng) ?? null; + // A voice the editor's list does not carry (an older cast entry) stays selectable as it is. + const voices = engine ? (engine.voices.includes(voice) || !voice ? engine.voices : [voice, ...engine.voices]) : []; + return ( + <span className="inline-flex items-center gap-1"> + <select + data-preset-engine={name} + aria-label={`${name}: the engine`} + value={eng} + onChange={(e) => { + const next = engines.find((x) => x.id === e.target.value); + onChange(next ? `${next.id}:${next.defaultVoice || next.voices[0] || ""}` : ""); + }} + className={input} + > + {none !== null && <option value="">{none}</option>} + {none === null && !engine && <option value="">an engine…</option>} + {engines.map((e) => ( + <option key={e.id} value={e.id}> + {e.label} + </option> + ))} + </select> + {engine && ( + <select data-preset-voice={name} aria-label={`${name}: the voice`} value={voice} onChange={(e) => onChange(`${engine.id}:${e.target.value}`)} className={input}> + {voices.map((v) => ( + <option key={v} value={v}> + {v} + </option> + ))} + </select> + )} + </span> + ); +} + +type Form = { + name: string; shown: string; voice: string; speed: string; convertVoice: string; convertEngine: string; convertPitch: string; convertSemitones: string; + enhance: boolean; trim: boolean; trimPad: string; direction: string; +}; +const formOf = (c: PresetCharacter): Form => ({ + name: c.name ?? "", + shown: c.shown ?? "", + voice: c.synthetic?.voice ?? c.voice ?? "", + speed: typeof c.synthetic?.speed === "number" ? String(c.synthetic.speed) : "", + convertVoice: c.recorded?.convert?.voice ?? "", + convertEngine: c.recorded?.convert?.engine ?? "", + convertPitch: c.recorded?.convert?.pitch ?? "", + convertSemitones: typeof c.recorded?.convert?.semitones === "number" ? String(c.recorded.convert.semitones) : "", + enhance: c.recorded?.enhance !== false, + trim: c.recorded?.trim?.on !== false, + trimPad: typeof c.recorded?.trim?.padMs === "number" ? String(c.recorded.trim.padMs) : "", + direction: c.recorded?.direction ?? "", +}); + +/** + * ONE CHARACTER's PRESETS, editable: Save is `umtool cast set <id> …` (scope "cast": every project) or `umtool cast + * project <p> set <id> …` (scope "project": this video only). A field left empty is its default again. + */ +export function PresetEditor({ + c, scope, engines, convertEngines, busy, post, onSaved, onClose, +}: { + c: PresetCharacter; scope: "cast" | "project"; engines: Engine[]; convertEngines: string[]; busy: boolean; post: PostFn; onSaved: (what: string) => void; onClose: () => void; +}) { + // (The panel keys this editor by the character as it is stored: another one opened, or this one saved, is a new form.) + const [f, setF] = useState<Form>(() => formOf(c)); + const set = <K extends keyof Form>(k: K, v: Form[K]) => setF((x) => ({ ...x, [k]: v })); + const follows = f.convertPitch === "source" || f.convertPitch === "contour"; + const save = async () => { + const j = await post({ + op: "character-set", scope, id: c.id, + ...(f.name.trim() && f.name.trim() !== c.name ? { name: f.name.trim() } : {}), + ...(c.anonymous && f.shown.trim() && f.shown.trim() !== (c.shown ?? "") ? { shown: f.shown.trim() } : {}), + voice: f.voice, speed: f.voice ? f.speed : "", + convertVoice: f.convertVoice, convertEngine: f.convertEngine, convertPitch: f.convertPitch, convertSemitones: follows ? f.convertSemitones : "", + // On is the default: said only when it is off, so a preset nobody touched stays as short as it was. + enhance: f.enhance ? "" : "off", trim: f.trim ? (f.trimPad.trim() ? "on" : "") : "off", trimPad: f.trim ? f.trimPad.trim() : "", + direction: f.direction.trim(), + }); + if (j) onSaved(`${c.name}: its presets saved ${scope === "cast" ? "in the cast (every project)" : "for this video only"}`); + }; + const row = "flex flex-wrap items-center gap-x-3 gap-y-1.5"; + const lab = "inline-flex items-center gap-1.5"; + return ( + <section className="rounded-[4px] border border-seam-2 p-3" data-preset-editor={c.id} data-preset-scope={scope}> + <h2 className="micro mb-2"> + presets · {c.anonymous ? `${c.shown} (anonymous)` : c.name} + <span className="ml-2 normal-case tracking-normal text-muted">{scope === "cast" ? "the cast: the same in every project" : "this video only"}</span> + </h2> + <div className={row}> + <label className={lab}> + <span className="text-muted">name</span> + <input data-preset-name="" value={f.name} onChange={(e) => set("name", e.target.value)} maxLength={80} className={cn(input, "w-44")} /> + </label> + {c.anonymous && ( + <label className={lab} title="what the card and the read call them: never their own name"> + <span className="text-muted">shown as</span> + <input data-preset-shown="" value={f.shown} onChange={(e) => set("shown", e.target.value)} maxLength={80} className={cn(input, "w-32")} /> + </label> + )} + </div> + <h3 className="micro mb-1 mt-3">synthetic · a read the editor synthesizes</h3> + <div className={row}> + <span className={lab}> + <span className="text-muted">voice</span> + <VoicePick name="voice" value={f.voice} onChange={(v) => set("voice", v)} engines={engines} none={scope === "project" ? "none of its own (the cast's, the narrator's…)" : null} /> + </span> + <label className={lab} title="the tts op's speed, 0.5–2 (empty: 1). Orpheus has no speed: it is not asked one."> + <span className="text-muted">speed</span> + <input data-preset-speed="" type="number" min={0.5} max={2} step={0.05} value={f.speed} disabled={!f.voice} onChange={(e) => set("speed", e.target.value)} placeholder="1" className={cn(input, "w-16")} /> + {f.voice.startsWith("orpheus:") && f.speed && <span className="text-[11px] text-doubt-text">Orpheus has no speed</span>} + </label> + </div> + <h3 className="micro mb-1 mt-3">recorded · a recording of them, made their read</h3> + <div className={row}> + <span className={lab} title="always a STOCK synthetic voice: a file or a recording is never a target"> + <span className="text-muted">converted to</span> + <VoicePick name="convert" value={f.convertVoice} onChange={(v) => set("convertVoice", v)} engines={engines} none={f.voice ? `its own voice (${pretty(f.voice)})` : "its own voice"} /> + </span> + <label className={lab}> + <span className="text-muted">by</span> + <select data-preset-convert-engine="" value={f.convertEngine} onChange={(e) => set("convertEngine", e.target.value)} className={input}> + <option value="">the editor&apos;s default</option> + {convertEngines.map((e) => ( + <option key={e} value={e}> + {e} + </option> + ))} + </select> + </label> + <label className={lab} title="where the converted read's pitch comes from: the stock voice's own, the pitch you read at, or your rises and falls at the stock voice's register (source and contour are seed-vc's)"> + <span className="text-muted">pitch</span> + <select data-preset-pitch="" value={f.convertPitch} onChange={(e) => set("convertPitch", e.target.value)} className={input}> + <option value="">the editor&apos;s default</option> + <option value="target">target — the stock voice&apos;s own</option> + <option value="source">source — the pitch you read at</option> + <option value="contour">contour — your intonation, its register</option> + </select> + </label> + <label className={lab} title="moves a followed pitch (source, contour), −12…12"> + <span className="text-muted">semitones</span> + <input data-preset-semitones="" type="number" min={-12} max={12} step={0.5} value={follows ? f.convertSemitones : ""} disabled={!follows} onChange={(e) => set("convertSemitones", e.target.value)} placeholder="0" className={cn(input, "w-14")} /> + </label> + </div> + <div className={cn(row, "mt-1.5")}> + <label className="inline-flex items-center gap-1" title="the editor's voice-enhance (DeepFilterNet), before the convert"> + <input type="checkbox" data-preset-enhance="" checked={f.enhance} onChange={(e) => set("enhance", e.target.checked)} /> clean it first + </label> + <label className="inline-flex items-center gap-1" title="the silence (and a key click) before and after the words cut away"> + <input type="checkbox" data-preset-trim="" checked={f.trim} onChange={(e) => set("trim", e.target.checked)} /> trim its edges to speech + </label> + <label className={lab} title="the room kept either side of the words, milliseconds (empty: the recorder's own, 80 before and 150 after)"> + <span className="text-muted">pad</span> + <input data-preset-trim-pad="" type="number" min={0} max={2000} step={10} value={f.trim ? f.trimPad : ""} disabled={!f.trim} onChange={(e) => set("trimPad", e.target.value)} placeholder="default" className={cn(input, "w-20")} /> + <span className="text-muted">ms</span> + </label> + </div> + <label className="mt-1.5 flex flex-wrap items-center gap-1.5"> + <span className="text-muted">direction</span> + <input data-preset-direction="" value={f.direction} onChange={(e) => set("direction", e.target.value)} maxLength={200} placeholder="higher, brisk, amused" className={cn(input, "w-[26rem] max-w-full")} /> + <span className="text-[11px] text-muted">one line for the person reading — never sent to a model</span> + </label> + <div className="mt-2.5 flex flex-wrap gap-1.5"> + <button type="button" data-preset-save="" disabled={busy || !f.name.trim() || (scope === "cast" && !f.voice)} onClick={() => void save()} className={buttonVariants({ variant: "go", size: "sm" })}> + Save presets + </button> + <button type="button" data-preset-close="" onClick={onClose} className={buttonVariants({ variant: "quiet", size: "sm" })}> + Close + </button> + </div> + </section> + ); +} + +/** THIS VIDEO's OWN characters, and the items that name a character of their own. */ +export function ProjectCharacters({ + own, cast, itemCharacters, posts, charactersError, busy, post, onChanged, onOpen, open, +}: { + own: PresetCharacter[]; cast: PresetCharacter[]; itemCharacters: ItemCharacter[]; posts: Post[]; charactersError?: string; busy: boolean; post: PostFn; + onChanged: (what: string) => void; onOpen: (id: string) => void; open: string | null; +}) { + const [add, setAdd] = useState({ id: "", name: "", handles: "", anonymous: false, shown: "" }); + const [item, setItem] = useState({ item: posts[0]?.id ?? "", character: "" }); + const cell = "border-t border-seam px-2 py-1 align-top"; + const idOk = /^[a-z0-9][a-z0-9_-]{0,47}$/.test(add.id); + const send = async (body: Record<string, unknown>, what: string) => { + const j = await post(body); + if (j) onChanged(what); + return j; + }; + return ( + <section data-project-characters={own.length}> + <h2 className="micro mb-1.5"> + this video&apos;s own characters · {own.length} + <span className="ml-2 normal-case tracking-normal text-muted">people who stay out of the pool — an anonymous one is shown and said under its shown name, never its own</span> + </h2> + {charactersError && <p className="m-0 mb-1 text-doubt-text" data-project-characters-error="">this video&apos;s characters are not read: {charactersError}</p>} + {own.length > 0 && ( + <table className="w-full border-collapse"> + <tbody> + {own.map((c) => ( + <tr key={c.id} data-project-character={c.id} className={cn(open === c.id && "bg-panel-2")}> + <td className={cell}> + <span className="font-medium">{c.anonymous ? c.shown : c.name}</span> + {c.anonymous && <span className="ml-1.5 rounded-[3px] border border-seam-2 px-1 text-[10.5px] text-doubt-text" title={`anonymous: shown and said as “${c.shown}” (your own label: ${c.name})`}>anonymous</span>} + <span className="ml-1.5 font-mono text-[11px] text-muted">{(c.handles ?? []).map((h) => `@${h}`).join(" ")}</span> + </td> + <td className={cn(cell, "font-mono")}> + {c.voice ? pretty(c.voice) : <span className="font-sans text-muted">no voice of its own</span>} + {typeof c.synthetic?.speed === "number" ? ` ×${c.synthetic.speed}` : ""} + </td> + <td className={cn(cell, "text-[11px] text-text-2")}>{recordedWords(c)}</td> + <td className={cn(cell, "whitespace-nowrap text-right")}> + <button type="button" data-project-character-preset={c.id} onClick={() => onOpen(c.id)} className={buttonVariants({ variant: open === c.id ? "pressed" : "outline", size: "sm" })}> + Presets + </button>{" "} + {!c.anonymous && ( + <button + type="button" + data-character-pool={c.id} + disabled={busy || !c.voice} + title={c.voice ? "into the cast: the same presets in every project" : "a cast character has a stock voice: give it one first"} + onClick={() => void send({ op: "character-pool", id: c.id }, `${c.name} is in the pool now, for every project`)} + className={buttonVariants({ variant: "outline", size: "sm" })} + > + Add to the pool + </button> + )}{" "} + <button type="button" data-project-character-remove={c.id} disabled={busy} onClick={() => void send({ op: "character-rm", id: c.id }, `${c.anonymous ? c.shown : c.name} removed from this video's characters`)} className={buttonVariants({ variant: "quiet", size: "sm" })} aria-label={`remove ${c.anonymous ? c.shown : c.name} from this video's characters`}> + ✕ + </button> + </td> + </tr> + ))} + </tbody> + </table> + )} + <div className="mt-1.5 flex flex-wrap items-center gap-1.5" data-project-character-add=""> + <input data-project-character-id="" value={add.id} onChange={(e) => setAdd({ ...add, id: e.target.value.toLowerCase() })} placeholder="id (anon-1)" className={cn(input, "w-28")} aria-label="the new character's id" /> + <input data-project-character-name="" value={add.name} onChange={(e) => setAdd({ ...add, name: e.target.value })} placeholder={add.anonymous ? "your label for them (optional)" : "name"} className={cn(input, "w-44")} aria-label="the new character's name" /> + <input data-project-character-handles="" value={add.handles} onChange={(e) => setAdd({ ...add, handles: e.target.value })} placeholder="handles: a,b" className={cn(input, "w-40")} aria-label="the handles it covers" /> + <label className="inline-flex items-center gap-1"> + <input type="checkbox" data-project-character-anonymous="" checked={add.anonymous} onChange={(e) => setAdd({ ...add, anonymous: e.target.checked })} /> anonymous + </label> + {add.anonymous && <input data-project-character-shown="" value={add.shown} onChange={(e) => setAdd({ ...add, shown: e.target.value })} placeholder="shown as (Anon 1, Anon 2 …)" className={cn(input, "w-44")} aria-label="the name it is shown under" />} + <button + type="button" + data-project-character-add-go="" + disabled={busy || !idOk || (!add.anonymous && !add.name.trim())} + onClick={() => + void send({ op: "character-add", id: add.id, ...(add.name.trim() ? { name: add.name.trim() } : {}), ...(add.handles.trim() ? { handles: add.handles } : {}), ...(add.anonymous ? { anonymous: true, ...(add.shown.trim() ? { shown: add.shown.trim() } : {}) } : {}) }, `${add.id} is one of this video's characters`).then((j) => { + if (!j) return; + onOpen(add.id); + setAdd({ id: "", name: "", handles: "", anonymous: false, shown: "" }); + }) + } + className={buttonVariants({ variant: "outline", size: "sm" })} + > + Add a character + </button> + <button type="button" data-project-characters-undo="" disabled={busy} onClick={() => void send({ op: "characters-undo" }, "undone: the last change to this video's characters")} className={buttonVariants({ variant: "quiet", size: "sm" })}> + Undo the last change + </button> + </div> + + <h3 className="micro mb-1 mt-3"> + an item read as a character of its own · {itemCharacters.length} + <span className="ml-2 normal-case tracking-normal text-muted">its presets answer for that item before its author&apos;s handle does</span> + </h3> + {itemCharacters.length > 0 && ( + <ul className="m-0 mb-1.5 list-none p-0 text-[11.5px] text-text-2" data-item-characters={itemCharacters.length}> + {itemCharacters.map((it) => ( + <li key={it.id} data-item-character={it.id} data-item-character-found={it.found ? "yes" : "no"}> + <span className="font-mono">{it.id}</span> + {it.handle ? ` @${it.handle}` : ""} — read as <b>{it.name ?? it.character}</b> + {it.found ? ( + <> + {" "} + ({it.layer === "project" ? "this video's" : "the cast's"}): <span className="font-mono">{pretty(it.voice.spec)}</span> + {typeof it.voice.speed === "number" ? ` ×${it.voice.speed}` : ""} + </> + ) : ( + <span className="text-doubt-text"> — no such character: it reads as its author does ({pretty(it.voice.spec)})</span> + )}{" "} + <button type="button" data-item-character-clear={it.id} disabled={busy} onClick={() => void send({ op: "item-character", item: it.id, character: "" }, `${it.id}: read by its author's handle again`)} className="ink-link"> + clear + </button> + </li> + ))} + </ul> + )} + {posts.length > 0 && ( + <div className="flex flex-wrap items-center gap-1.5"> + <select data-item-character-item="" value={item.item} onChange={(e) => setItem({ ...item, item: e.target.value })} className={cn(input, "max-w-[22rem]")} aria-label="the post item"> + {posts.map((p) => ( + <option key={p.id} value={p.id}> + {p.id} @{p.handle}: {p.text} + </option> + ))} + </select> + <select data-item-character-pick="" value={item.character} onChange={(e) => setItem({ ...item, character: e.target.value })} className={input} aria-label="the character it is read as"> + <option value="">read as…</option> + {own.map((c) => ( + <option key={`p:${c.id}`} value={c.id}> + {c.anonymous ? c.shown : c.name} (this video) + </option> + ))} + {cast.filter((c) => !own.some((o) => o.id === c.id)).map((c) => ( + <option key={`c:${c.id}`} value={c.id}> + {c.name} (the cast) + </option> + ))} + </select> + <button type="button" data-item-character-set="" disabled={busy || !item.item || !item.character} onClick={() => void send({ op: "item-character", item: item.item, character: item.character }, `${item.item}: read as ${item.character}`)} className={buttonVariants({ variant: "outline", size: "sm" })}> + Set + </button> + </div> + )} + </section> + ); +} diff --git a/umtool/components/projects/VoicesPanel.tsx b/umtool/components/projects/VoicesPanel.tsx @@ -4,14 +4,19 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import { buttonVariants } from "@/components/ui/button"; import { cn } from "@/lib/utils"; import { jobsHref, postBenchHref } from "@/lib/hrefs"; +import { PresetEditor, ProjectCharacters, recordedWords, type ItemCharacter, type PresetCharacter } from "./CharacterPresets"; // --------------------------------------------------------------------------- // THE VOICES PANEL (components/projects/VoicesPage.tsx; /api/report/voices; the CLI is `umtool cast`). Works with // the operator alone: nothing here needs an agent. // // the characters every author the project's reads use, the voice each reads in NOW and where it comes from -// (cast · project · narrator · default), how many items it reads, its picked reads in another -// voice (drift), its real voice (speakers.json) -- Audition opens the box below for it +// (the item's own character · this video's · the cast · narrator · default), how many items it +// reads, its picked reads in another voice (drift), its real voice (speakers.json) -- Audition +// opens the box below for it; Presets opens its two presets (CharacterPresets.tsx); an author +// with no character: "Add to the pool" / "Keep in this video only" +// this video's own the characters that live in this video only (anonymous ones under a shown name), and the items +// read as a character of their own // the audition a line (its own words in this project, a stock line, or typed), 2-6 candidate stock voices // (Kokoro fast, Orpheus heavy), Render: a job (the editor's tts; then the closeness to the real // voice through the heavy slot), each candidate played side by side at ONE loudness, with its @@ -22,11 +27,11 @@ import { jobsHref, postBenchHref } from "@/lib/hrefs"; // a recording a person's read of an item made a character's: kept, cleaned, converted to its stock voice // --------------------------------------------------------------------------- -type Voice = { engine: string; voice: string; spec: string; from: string }; +type Voice = { engine: string; voice: string; spec: string; from: string; speed?: number; character?: 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?: Convert; note?: string; narrator?: boolean } | null; + character: (PresetCharacter & { layer: "cast" | "project" }) | null; items: number; context: number; itemIds: string[]; contextIds: string[]; voice: Voice; contextVoice?: Voice; weight: string; reads: { id: string; role: string; spec: string; kind: string }[]; @@ -35,7 +40,7 @@ type Character = { // 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 }; +type CastChar = PresetCharacter & { voice: string }; /** 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 { @@ -50,6 +55,8 @@ type View = { narrator: { engine: string; voice: string; spec: string; from: string; character: { id: string; name: string; voice: string } | null; recorded: { id: string; kind: string; voice: string }[] }; characters: Character[]; overrides: { handle: string; character: string; cast: string; project: string }[]; cast: CastChar[]; engines: Engine[]; convertEngines: string[]; running: { id: string; state: string; kind: string } | null; + // This video's own characters (narration/characters.json) and the items that name a character of their own. + own?: PresetCharacter[]; itemCharacters?: ItemCharacter[]; charactersError?: string; }; type Candidate = { spec: string; engine: string; voice: string; weight: string; key: string; rel: string; cached: boolean; seconds: number | null; lufs: number | null; score: number | null }; type Audition = { character: { id: string; name: string; handles: string[]; voice: string | null }; text: string; from: string; speaker: string | null; reference: string | null; candidates: Candidate[] }; @@ -58,7 +65,7 @@ type Post = { id: string; handle: string; author: string; text: string }; const whoOf = (c: Character) => (c.character ? c.character.id : `@${c.handles[0]}`); const pretty = (spec: string) => spec.replace(":", " · "); -const FROM: Record<string, string> = { cast: "the cast", project: "this project", narrator: "the narrator's", default: "the default", override: "a read's own" }; +const FROM: Record<string, string> = { cast: "the cast", project: "this project", narrator: "the narrator's", default: "the default", override: "a read's own", item: "the item's own character" }; const fileUrl = (project: string, rel: string, v?: string | number | null) => `/api/report/file?project=${encodeURIComponent(project)}&path=${encodeURIComponent(rel)}${v ? `&v=${v}` : ""}`; export default function VoicesPanel({ project, posts, initialWho = null }: { project: string; posts: Post[]; initialWho?: string | null }) { @@ -78,6 +85,8 @@ export default function VoicesPanel({ project, posts, initialWho = null }: { pro const [queued, setQueued] = useState<string[] | null>(null); const [rec, setRec] = useState<{ item: string; as: string; clean: boolean; convert: boolean; file: File | null }>({ item: posts[0]?.id ?? "", as: "", clean: true, convert: true, file: null }); const [drag, setDrag] = useState(false); + // The character whose presets are open: the cast's, or one of this video's own. + const [preset, setPreset] = useState<{ scope: "cast" | "project"; id: string } | null>(null); const timer = useRef<ReturnType<typeof setTimeout> | null>(null); const audios = useRef<Map<string, HTMLAudioElement>>(new Map()); @@ -230,6 +239,23 @@ export default function VoicesPanel({ project, posts, initialWho = null }: { pro }); }; + const changed = (what: string) => { + setStatus(what); + void load(); + void loadAudition(); + }; + // An author with no character: into the pool (the cast: the voice they read in now, everywhere) or this video only. + const poolAuthor = async (c: Character) => { + const j = await post({ op: "use", who: whoOf(c), voice: c.voice.spec, scope: "cast" }); + if (j) changed(`${c.name} is in the pool now (${pretty(c.voice.spec)}), for every project`); + }; + const keepHere = async (who: string, name: string) => { + const j = (await post({ op: "character-keep", who })) as { character?: { id: string } } | null; + if (!j) return; + changed(`${name} is a character of this video only`); + if (j.character?.id) setPreset({ scope: "project", id: j.character.id }); + }; + if (!view) return error ? <p role="alert" className="text-[12px] text-reject-text">{error}</p> : <p className="text-[12px] text-muted">reading the voices…</p>; const input = "rounded-[3px] border border-seam-2 bg-ground px-1.5 py-[3px] text-[11.5px] text-text outline-none focus:border-signal"; @@ -241,6 +267,8 @@ export default function VoicesPanel({ project, posts, initialWho = null }: { pro const best = scored.length > 1 && scored[0] > scored[1] ? scored[0] : null; const missing = (audition?.candidates ?? []).filter((c) => !c.cached).length; const heavy = (audition?.candidates ?? []).some((c) => !c.cached && c.weight === "heavy"); + const own = view.own ?? []; + const presetOf = preset ? (preset.scope === "project" ? own.find((c) => c.id === preset.id) : view.cast.find((c) => c.id === preset.id)) ?? null : null; return ( <div className="space-y-5 text-[12.5px]" data-voices-panel={project}> @@ -249,7 +277,7 @@ export default function VoicesPanel({ project, posts, initialWho = null }: { pro <h2 className="micro mb-1.5"> the characters · {view.characters.length} <span className="ml-2 normal-case tracking-normal text-muted"> - a voice comes from a read&apos;s own choice, this project&apos;s map, the cast (every project), the narrator&apos;s, or the default — in that order + a voice comes from a read&apos;s own choice, the item&apos;s own character, this video&apos;s characters and map, the cast (every project), the narrator&apos;s, or the default — in that order </span> </h2> {view.castError && <p className="m-0 mb-1 text-doubt-text" data-cast-error="">the cast is not read: {view.castError}</p>} @@ -272,10 +300,13 @@ export default function VoicesPanel({ project, posts, initialWho = null }: { pro <td className={cell}> <span className="font-medium text-text">{c.name}</span> <span className="ml-1.5 font-mono text-[11px] text-muted">{c.handles.map((h) => `@${h}`).join(" ")}</span> - {c.character && <span className="ml-1.5 rounded-[3px] border border-seam-2 px-1 text-[10.5px] text-signal-text" title="in the cast: the same voice in every project">cast</span>} + {c.character && c.character.layer !== "project" && <span className="ml-1.5 rounded-[3px] border border-seam-2 px-1 text-[10.5px] text-signal-text" title="in the cast: the same voice in every project">cast</span>} + {c.character?.layer === "project" && <span className="ml-1.5 rounded-[3px] border border-seam-2 px-1 text-[10.5px] text-text-2" data-voices-layer="project" title="a character of this video only">this video</span>} + {c.character?.anonymous && <span className="ml-1.5 rounded-[3px] border border-seam-2 px-1 text-[10.5px] text-doubt-text" title={`anonymous: shown and said as “${c.character.shown}”, never its own name`}>anonymous</span>} </td> <td className={cell}> <span className="font-mono text-[12px]" data-voice-now={c.voice.spec}>{pretty(c.voice.spec)}</span> + {typeof c.voice.speed === "number" && <span className="ml-1 font-mono text-[11px] text-text-2" data-voice-speed={c.voice.speed} title="its preset's speed">×{c.voice.speed}</span>} {c.weight === "heavy" && <span className="ml-1 text-[10.5px] text-doubt-text" title="Orpheus pins ~8.5 GB while it reads">heavy</span>} <div className="text-[11px] text-muted">from {FROM[c.voice.from] ?? c.voice.from}{c.contextVoice ? ` · as a context post: ${pretty(c.contextVoice.spec)} (${FROM[c.contextVoice.from] ?? c.contextVoice.from})` : ""}</div> </td> @@ -297,7 +328,27 @@ export default function VoicesPanel({ project, posts, initialWho = null }: { pro <td className={cn(cell, "text-text-2")} data-voice-speaker={c.speaker ?? ""}> {c.speaker ?? <span className="text-muted" title="name it in speakers.json (the walk's Add to a voice) to score candidates against it">—</span>} </td> - <td className={cn(cell, "text-right")}> + <td className={cn(cell, "whitespace-nowrap text-right")}> + {c.character ? ( + <button + type="button" + data-voices-preset-open={k} + onClick={() => setPreset({ scope: c.character!.layer, id: c.character!.id })} + className={buttonVariants({ variant: preset?.id === c.character.id && preset.scope === c.character.layer ? "pressed" : "outline", size: "sm" })} + title="its two presets: the synthetic voice and speed, and what a recording of them is made into" + > + Presets + </button> + ) : ( + <> + <button type="button" data-character-pool-author={k} disabled={busy} onClick={() => void poolAuthor(c)} className={buttonVariants({ variant: "outline", size: "sm" })} title={`a cast character, reading in ${pretty(c.voice.spec)} in every project`}> + Add to the pool + </button>{" "} + <button type="button" data-character-keep={k} disabled={busy} onClick={() => void keepHere(k, c.name)} className={buttonVariants({ variant: "outline", size: "sm" })} title="a character of this video only — for someone who must not enter the pool"> + Keep in this video only + </button> + </> + )}{" "} <button type="button" data-voices-audition-open={k} @@ -342,6 +393,35 @@ export default function VoicesPanel({ project, posts, initialWho = null }: { pro )} </section> + {/* --- one character's presets --------------------------------------------------- */} + {preset && presetOf && ( + <> + <PresetEditor key={`${preset.scope}:${preset.id}:${JSON.stringify([presetOf.name, presetOf.shown, presetOf.synthetic, presetOf.recorded])}`} c={presetOf} scope={preset.scope} engines={view.engines} convertEngines={view.convertEngines} busy={busy} post={post} onSaved={changed} onClose={() => setPreset(null)} /> + {preset.scope === "cast" && !own.some((c) => c.id === preset.id) && ( + <p className="m-0 -mt-3 text-[11.5px] text-text-2"> + <button type="button" data-character-keep={preset.id} disabled={busy} onClick={() => void keepHere(preset.id, presetOf.name)} className="ink-link"> + Keep in this video only + </button>{" "} + — a copy of {presetOf.name} for this video: change its presets here and the pool&apos;s stay as they are + </p> + )} + </> + )} + + {/* --- this video's own characters ------------------------------------------------ */} + <ProjectCharacters + own={own} + cast={view.cast} + itemCharacters={view.itemCharacters ?? []} + posts={posts} + charactersError={view.charactersError} + busy={busy} + post={post} + onChanged={changed} + onOpen={(id) => setPreset({ scope: "project", id })} + open={preset?.scope === "project" ? preset.id : null} + /> + {/* --- the audition ------------------------------------------------------------- */} {chosen && ( <section className="rounded-[4px] border border-seam-2 p-3" data-audition-panel={whoOf(chosen)}> @@ -535,8 +615,13 @@ export default function VoicesPanel({ project, posts, initialWho = null }: { pro ))} </select> <select data-recording-as="" value={rec.as} onChange={(e) => setRec({ ...rec, as: e.target.value })} className={input}> - <option value="">as: the post&apos;s author (else the narrator)</option> - {view.cast.map((c) => ( + <option value="">as: the item&apos;s character, else the post&apos;s author (else the narrator)</option> + {own.filter((c) => c.voice || c.recorded).map((c) => ( + <option key={`own:${c.id}`} value={c.id}> + as {c.anonymous ? c.shown : c.name} (this video{c.recorded?.convert?.voice ?? c.voice ? `: ${pretty(c.recorded?.convert?.voice ?? c.voice ?? "")}` : ""}) + </option> + ))} + {view.cast.filter((c) => !own.some((o) => o.id === c.id)).map((c) => ( <option key={c.id} value={c.id}> as {c.name} ({pretty(c.convert?.voice ?? c.voice)}{pitchWords(c.convert) ? `, ${pitchWords(c.convert)}` : ""}) </option> @@ -588,7 +673,10 @@ export default function VoicesPanel({ project, posts, initialWho = null }: { pro <span className="ml-1.5 font-mono text-[11px] text-muted">{(c.handles ?? []).map((h) => `@${h}`).join(" ")}</span> {c.narrator && <span className="ml-1.5 text-[11px] text-muted">the narrator</span>} </td> - <td className={cn(cell, "font-mono")}>{pretty(c.voice)}</td> + <td className={cn(cell, "font-mono")}> + {pretty(c.voice)} + {typeof c.synthetic?.speed === "number" ? ` ×${c.synthetic.speed}` : ""} + </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) && ( @@ -596,10 +684,14 @@ export default function VoicesPanel({ project, posts, initialWho = null }: { pro {` · pitch: ${pitchWords(c.convert)}`} </span> )} + {recordedWords({ ...c, recorded: { ...c.recorded, convert: undefined } }) ? ` · ${recordedWords({ ...c, recorded: { ...c.recorded, convert: undefined } })}` : ""} {c.speakers?.length ? ` · real voice: ${c.speakers.join(", ")}` : ""} {c.note ? ` · ${c.note}` : ""} </td> - <td className={cn(cell, "text-right")}> + <td className={cn(cell, "whitespace-nowrap text-right")}> + <button type="button" data-cast-preset={c.id} onClick={() => setPreset({ scope: "cast", id: c.id })} className={buttonVariants({ variant: preset?.scope === "cast" && preset.id === c.id ? "pressed" : "outline", size: "sm" })}> + Presets + </button>{" "} <button type="button" data-cast-remove={c.id} disabled={busy} onClick={() => void post({ op: "cast-rm", id: c.id }).then((j) => j && load())} className={buttonVariants({ variant: "quiet", size: "sm" })} aria-label={`remove ${c.name} from the cast`}> ✕ </button>