commit 497e2f48acb669db3c42a5abd894d5fc85a2a8a7
parent 3dcbfe46cdf95d135b764bbadc420ce777a9aef8
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Tue, 17 Nov 2026 09:39:40 -0500
Voices page: a character's Orpheus tuning in its preset -- try it, keep it
The preset's synthetic section gains CharacterTuning: Steady / Default /
Lively fill the numbers (always shown, editable; "custom" when edited),
a line it reads in this project prefilled, Read it and Another reading
(each a job: umtool cast try, the editor's tts), the tries listed at one
loudness with their numbers and reading, Keep these settings (umtool cast
set / cast project <p> set), and the reads made with other settings.
Another job running is said in place and the buttons open when it ends;
while render mode holds the machine, the read says it waits for the
render. The characters table counts a character's stale reads.
/api/report/voices: op "try" (a job), GET ?tries=<who>, and a tuning on
character-set (exactly the numbers given; --no-tuning for none).
e2e: character-tuning.spec.ts on its own fixture (tuning-fixture).
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat:
7 files changed, 578 insertions(+), 7 deletions(-)
diff --git a/umtool/app/api/report/voices/route.ts b/umtool/app/api/report/voices/route.ts
@@ -14,6 +14,7 @@ import { addStep } from "@/lib/queue/store.mjs";
import { kickQueue, queueDir } from "@/lib/queue/runner";
import { REPORTS_ROOT } from "@/lib/projects/core.mjs";
import { CAST_CONVERT_ENGINES, ENGINE_WEIGHT, charactersOf } from "umtool-report-to-video/cast";
+import { ORPHEUS_TUNING_DEFAULTS, ttsReadingError } from "yt-dlp-transcript-common/lib/ttsTuning.mjs";
import { readPolicy } from "@/lib/articles/generation";
import { castAssignRouteOf } from "@/lib/report/castAssignModel.mjs";
@@ -28,6 +29,11 @@ export const dynamic = "force-dynamic";
// engines and their stock voices, the job running
// GET ?project&who&voices=a,b[&text|&item] an audition as it is kept (auditionView: nothing asked)
// GET ?job=<id>[&since&sinceEvent] that job
+// GET ?project&tries=<who> a character's TRIES (umtool cast try <p> <who> --list): its tuning,
+// the line the page prefills, the tries kept (newest first)
+// POST { project, op: "try", who, text, tuning: { temperature, top_p, repeat_penalty, takes? }, reading } a JOB: one
+// line read in the character's voice with that tuning and reading
+// (umtool cast try: the editor's tts; scratch, no take, no draft)
// POST { project, op: "audition", who, voices: [..], text?, item? } a JOB: the editor's tts for the candidates not
// kept, then (with a reference) their closeness to the real voice
// through the heavy slot
@@ -36,7 +42,8 @@ export const dynamic = "force-dynamic";
// 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?, …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 /
+// convertSemitones?, enhance?, trim?, trimPad?, direction?, handles?, anonymous?, shown?,
+// tuning?: { temperature?, top_p?, repeat_penalty?, takes? } | null } 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
@@ -108,9 +115,36 @@ function presetArgs(b: Record<string, unknown>): string[] {
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");
+ if (has("tuning")) args.push(...tuningArgs(b.tuning));
return args;
}
+/** The tuning fields a character keeps, and the CLI flag of each (castCli.mjs CHARACTER_TUNING_FLAGS). */
+const TUNING_FIELD_FLAGS: Record<string, string> = { temperature: "--temperature", top_p: "--top-p", repeat_penalty: "--repeat-penalty", takes: "--chunk-takes" };
+
+/**
+ * A tuning as the CLI's flags, EXACTLY these numbers: each field given, the others `default` (off); null, "" or "none"
+ * is --no-tuning. A field a character does not keep (top_k, min_p) is refused unless it is Orpheus's default.
+ */
+function tuningArgs(t: unknown): string[] {
+ if (t === null || t === "" || t === "none") return ["--no-tuning"];
+ if (!t || typeof t !== "object" || Array.isArray(t)) throw new TuningAskError("a tuning is { temperature, top_p, repeat_penalty, takes }");
+ const o = t as Record<string, unknown>;
+ for (const k of Object.keys(o)) {
+ if (k in TUNING_FIELD_FLAGS) continue;
+ const dflt = (ORPHEUS_TUNING_DEFAULTS as Record<string, number>)[k];
+ if (dflt !== undefined && (o[k] === null || o[k] === undefined || Number(o[k]) === dflt)) continue;
+ throw new TuningAskError(`a character keeps temperature, top_p, repeat penalty and takes (not ${k})`);
+ }
+ const args: string[] = [];
+ for (const [k, flag] of Object.entries(TUNING_FIELD_FLAGS)) {
+ const v = o[k];
+ args.push(flag, v === undefined || v === null || v === "" ? "default" : String(v));
+ }
+ return args;
+}
+class TuningAskError extends Error {}
+
/** 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");
@@ -119,7 +153,7 @@ function queueLockScript() {
const mine = (project: string) => {
const r = runningJob();
- return r && r.project === project && (r.kind.startsWith("cast-audition ") || r.kind.startsWith("cast-recording ") || r.kind.startsWith("cast-assign ")) ? jobView(r) : null;
+ return r && r.project === project && (r.kind.startsWith("cast-audition ") || r.kind.startsWith("cast-recording ") || r.kind.startsWith("cast-assign ") || r.kind.startsWith("cast-try ")) ? jobView(r) : null;
};
export async function GET(request: Request) {
@@ -133,7 +167,12 @@ export async function GET(request: Request) {
const project = await projectRef(String(url.searchParams.get("project") ?? ""));
if (!project) return Response.json({ error: "no such project" }, { status: 404 });
const who = url.searchParams.get("who");
+ const tries = url.searchParams.get("tries");
try {
+ if (tries) {
+ const r = await cli(["try", project.id, tries, "--list"]);
+ return Response.json(r.code === 0 ? r.json : { error: r.error }, { status: r.code === 0 ? 200 : 400, headers });
+ }
if (who) {
const castRead = await castForProject(project.dir);
const voices = String(url.searchParams.get("voices") ?? "").split(",").map((s) => s.trim()).filter(Boolean).slice(0, AUDITION_MAX);
@@ -198,6 +237,30 @@ export async function POST(request: Request) {
const job = startJob(plan.kind, plan.steps, { project: project.id });
return Response.json({ ok: true, job: jobView(job), audition: view }, { headers });
}
+ if (op === "try") {
+ // ONE LINE read in the character's voice with a tuning and a reading: the CLI's own command as a job (scratch).
+ const who = s("who");
+ const text = s("text");
+ if (!who) return Response.json({ error: "a try is of a character" }, { status: 400 });
+ if (!text) return Response.json({ error: "type the line to read" }, { status: 400 });
+ const reading = b.reading === undefined || b.reading === null || b.reading === "" ? 0 : Number(b.reading);
+ const readingError = ttsReadingError(reading);
+ if (readingError) return Response.json({ error: readingError }, { status: 400 });
+ let tuning: string[];
+ try {
+ tuning = b.tuning === undefined ? [] : tuningArgs(b.tuning).filter((a) => a !== "--no-tuning");
+ } catch (e) {
+ return Response.json({ error: e instanceof Error ? e.message : String(e) }, { status: 400 });
+ }
+ // With no tuning given, the try reads with the character's own; "none" reads with the defaults.
+ if (b.tuning === null || b.tuning === "none") tuning = ["--tuning", "default", "--chunk-takes", "default"];
+ const running = runningJob();
+ if (running) return Response.json({ error: `another job is running (${running.kind}): Read it is open again when it ends`, busy: true, running: jobView(running) }, { status: 409 });
+ const cliPath = path.join(/* turbopackIgnore: true */ UMTOOL_DIR, "bin", "umtool.mjs");
+ const argv = [process.execPath, cliPath, "cast", "try", project.id, who, "--text", text, ...tuning, "--reading", String(reading), "--progress", "ndjson"];
+ const job = startJob(`cast-try ${project.id}`, [{ label: `${who}: the line read (the editor's tts), reading ${reading}`, argv, cwd: path.join(/* turbopackIgnore: true */ UMTOOL_DIR, ".."), env: {}, ndjson: true, timeoutMs: 45 * 60 * 1000 }], { project: project.id });
+ return Response.json({ ok: true, job: jobView(job) }, { headers });
+ }
if (op === "use") {
const scope = s("scope") === "cast" ? "cast" : "project";
const r = await cli(["use", project.id, s("who"), s("voice"), ...(scope === "cast" ? ["--everywhere"] : [])]);
@@ -248,7 +311,14 @@ export async function POST(request: Request) {
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)]));
+ let args: string[];
+ try {
+ args = presetArgs(b);
+ } catch (e) {
+ if (e instanceof TuningAskError) return Response.json({ error: e.message }, { status: 400 });
+ throw e;
+ }
+ return answer(await cli([...head, ...args]));
}
if (op === "character-rm") {
if (!idOk(s("id"))) return Response.json({ error: "which character?" }, { status: 400 });
diff --git a/umtool/components/projects/CharacterPresets.tsx b/umtool/components/projects/CharacterPresets.tsx
@@ -3,13 +3,15 @@
import { useState } from "react";
import { buttonVariants } from "@/components/ui/button";
import { cn } from "@/lib/utils";
+import { CharacterTuning, type StaleRead, type TuningFields } from "./CharacterTuning";
// ---------------------------------------------------------------------------
// 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
+// PresetEditor one character's two presets: SYNTHETIC (the stock voice, its speed, its Orpheus tuning and a
+// line to try it on: CharacterTuning.tsx) 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
@@ -19,7 +21,7 @@ import { cn } from "@/lib/utils";
// ---------------------------------------------------------------------------
export type Convert = { engine?: string; voice?: string; pitch?: "target" | "source" | "contour"; semitones?: number };
-export type Synthetic = { voice?: string; speed?: number };
+export type Synthetic = { voice?: string; speed?: number; tuning?: TuningFields };
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;
@@ -116,9 +118,13 @@ const formOf = (c: PresetCharacter): Form => ({
* 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, scope, engines, convertEngines, busy, post, onSaved, onClose, project = null, stale = [],
}: {
c: PresetCharacter; scope: "cast" | "project"; engines: Engine[]; convertEngines: string[]; busy: boolean; post: PostFn; onSaved: (what: string) => void; onClose: () => void;
+ /** The project the page is of: its tuning tried on this project's lines (none: no tuning row). */
+ project?: string | null;
+ /** The reads by this character made with other settings than its tuning now (cast.mjs tuningStale). */
+ stale?: StaleRead[];
}) {
// (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));
@@ -169,6 +175,9 @@ export function PresetEditor({
{f.voice.startsWith("orpheus:") && f.speed && <span className="text-[11px] text-doubt-text">Orpheus has no speed</span>}
</label>
</div>
+ {project && (c.synthetic?.voice ?? c.voice) && (
+ <CharacterTuning project={project} id={c.id} name={c.anonymous ? c.shown ?? c.name : c.name} voice={String(c.synthetic?.voice ?? c.voice)} scope={scope} busy={busy} post={post} onKept={onSaved} stale={stale} />
+ )}
<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">
diff --git a/umtool/components/projects/CharacterTuning.tsx b/umtool/components/projects/CharacterTuning.tsx
@@ -0,0 +1,284 @@
+"use client";
+
+import { useCallback, useEffect, useMemo, useRef, useState } from "react";
+import { buttonVariants } from "@/components/ui/button";
+import { cn } from "@/lib/utils";
+import { postBenchHref } from "@/lib/hrefs";
+import { ORPHEUS_TUNING_NAMED, ORPHEUS_TUNING_NAMES, TTS_TUNING_RANGES, ttsTuningNameOf, type TtsTuningName } from "yt-dlp-transcript-common/lib/ttsTuning.mjs";
+
+// ---------------------------------------------------------------------------
+// A CHARACTER's ORPHEUS TUNING, in its preset (lane character-tuning; components/projects/CharacterPresets.tsx; the
+// CLI is `umtool cast set <id> --tuning … --temperature …`, `umtool cast try <p> <id> …`, `umtool cast stale <p>`).
+// Works with the operator alone: every button a form and a job, every write the CLI's own command.
+//
+// the tuning Steady / Default / Lively fill the numbers, which are always shown and editable ("custom")
+// try it a line (its own in this project, or typed), Read it -> a job (the editor's tts) -> plays when
+// done; Another reading -> the same line and numbers, the next reading; the list of tries, each at
+// one loudness (-20 LUFS), with its numbers and reading; scratch (no take, nothing in the draft)
+// keep Keep these settings -> umtool cast set (the cast) / cast project <p> set (this video)
+// stale the reads by this character made with other settings than its tuning now (listed, never re-made)
+// ---------------------------------------------------------------------------
+
+export type TuningFields = { temperature?: number; top_p?: number; repeat_penalty?: number; takes?: number };
+export type StaleRead = { id: string; role: string; character: string; reading: number; made: Record<string, number>; want: Record<string, number> };
+type TuningView = { tuning: TuningFields | null; name: string; effective: Record<string, number>; takesFrom: "character" | "setting" };
+type TryRow = { key: string; character: string; voice: string; text: string; tuning: TuningFields; reading: number; rel: string; seconds: number | null; lufs: number | null; at: string };
+type Tries = { character: { id: string; name: string; layer: string | null; voice: string | null; tuning: TuningView }; line: { text: string; from: string }; settingTakes: number; tries: TryRow[] };
+type JobPoll = { id: string; state: "running" | "done" | "failed"; error: string | null; kind?: string };
+type PostFn = (body: Record<string, unknown>) => Promise<Record<string, unknown> | null>;
+
+const FIELDS = [
+ { k: "temperature", label: "temperature", step: 0.05 },
+ { k: "top_p", label: "top_p", step: 0.01 },
+ { k: "repeat_penalty", label: "repeat penalty", step: 0.05 },
+ { k: "takes", label: "takes", step: 1 },
+] as const;
+type Form = Record<(typeof FIELDS)[number]["k"], string>;
+const NAME_LABEL: Record<string, string> = { steady: "Steady", default: "Default", lively: "Lively", custom: "custom" };
+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 fileUrl = (project: string, rel: string, v?: string) => `/api/report/file?project=${encodeURIComponent(project)}&path=${encodeURIComponent(rel)}${v ? `&v=${v}` : ""}`;
+
+const formOf = (t: TuningFields | null | undefined, eff?: Record<string, number>): Form => ({
+ temperature: String(t?.temperature ?? eff?.temperature ?? ORPHEUS_TUNING_NAMED.default.temperature),
+ top_p: String(t?.top_p ?? eff?.top_p ?? ORPHEUS_TUNING_NAMED.default.top_p),
+ repeat_penalty: String(t?.repeat_penalty ?? eff?.repeat_penalty ?? ORPHEUS_TUNING_NAMED.default.repeat_penalty),
+ takes: typeof t?.takes === "number" ? String(t.takes) : "",
+});
+/** The form's numbers, or the field that is out of its range. */
+function numbersOf(f: Form): { ok: true; t: TuningFields } | { ok: false; field: string } {
+ const t: TuningFields = {};
+ for (const { k } of FIELDS) {
+ const raw = f[k].trim();
+ if (!raw && k === "takes") continue;
+ const n = Number(raw);
+ const r = TTS_TUNING_RANGES[k];
+ if (!raw || !Number.isFinite(n) || n < r.min || n > r.max || (r.integer && !Number.isInteger(n))) return { ok: false, field: k };
+ t[k] = Math.round(n * 1000) / 1000;
+ }
+ return { ok: true, t };
+}
+const sameTuning = (a: TuningFields, b: TuningFields, dflt: number) =>
+ (["temperature", "top_p", "repeat_penalty"] as const).every((k) => (a[k] ?? ORPHEUS_TUNING_NAMED.default[k]) === (b[k] ?? ORPHEUS_TUNING_NAMED.default[k])) && (a.takes ?? dflt) === (b.takes ?? dflt);
+const numbersWords = (t: TuningFields, settingTakes: number) =>
+ `temperature ${t.temperature ?? ORPHEUS_TUNING_NAMED.default.temperature} · top_p ${t.top_p ?? ORPHEUS_TUNING_NAMED.default.top_p} · repeat penalty ${t.repeat_penalty ?? ORPHEUS_TUNING_NAMED.default.repeat_penalty} · takes ${t.takes ?? settingTakes}`;
+
+export function CharacterTuning({
+ project, id, name, voice, scope, busy, post, onKept, stale,
+}: {
+ project: string; id: string; name: string; voice: string; scope: "cast" | "project"; busy: boolean; post: PostFn; onKept: (what: string) => void; stale: StaleRead[];
+}) {
+ const orpheus = voice.startsWith("orpheus:");
+ const [data, setData] = useState<Tries | null>(null);
+ const [form, setForm] = useState<Form | null>(null);
+ const [text, setText] = useState<string | null>(null);
+ const [job, setJob] = useState<JobPoll | null>(null);
+ const [blocked, setBlocked] = useState<string | null>(null);
+ const [renderWait, setRenderWait] = useState<string | null>(null);
+ const [error, setError] = useState<string | null>(null);
+ const [status, setStatus] = useState<string | null>(null);
+ const timer = useRef<ReturnType<typeof setTimeout> | null>(null);
+ const newest = useRef<HTMLAudioElement | null>(null);
+ const playNext = useRef(false);
+
+ const load = useCallback(async () => {
+ const r = await fetch(`/api/report/voices?project=${encodeURIComponent(project)}&tries=${encodeURIComponent(id)}`, { cache: "no-store" });
+ const j = (await r.json().catch(() => null)) as (Tries & { error?: string }) | null;
+ if (!r.ok || !j) {
+ setError(j?.error ?? `HTTP ${r.status}`);
+ return;
+ }
+ setData(j);
+ setForm((f) => f ?? formOf(j.character.tuning.tuning, j.character.tuning.effective));
+ setText((t) => t ?? j.line.text);
+ }, [project, id]);
+ useEffect(() => {
+ void load();
+ return () => {
+ if (timer.current) clearTimeout(timer.current);
+ };
+ }, [load]);
+ // A new try plays when its job ends (the list re-read, its row first).
+ useEffect(() => {
+ if (!playNext.current || !newest.current) return;
+ playNext.current = false;
+ void newest.current.play().catch(() => undefined);
+ }, [data]);
+
+ const settingTakes = data?.settingTakes ?? 3;
+ const nums = form ? numbersOf(form) : null;
+ const tuning = nums?.ok ? nums.t : null;
+ const named = tuning ? ttsTuningNameOf(tuning) : "custom";
+ const kept = data?.character.tuning.tuning ?? {};
+ const isKept = !!tuning && sameTuning(tuning, kept, settingTakes);
+ const running = job?.state === "running";
+ const off = busy || running || !!blocked || !orpheus;
+
+ /** Follow a job to its end; while it runs, say when render mode holds the machine. */
+ const follow = useCallback((jobId: string, then: (j: JobPoll) => void) => {
+ const tick = async () => {
+ const r = await fetch(`/api/report/voices?job=${encodeURIComponent(jobId)}`, { cache: "no-store" });
+ const j = (await r.json().catch(() => null)) as JobPoll | null;
+ const rm = (await fetch("/api/render-mode", { cache: "no-store" }).then((x) => x.json()).catch(() => null)) as { held?: boolean; what?: string | null } | null;
+ setRenderWait(rm?.held ? `Waiting for the render (${rm.what ?? "render mode is on"}): the read is made when it lets go.` : null);
+ if (!j || j.state === "running") {
+ timer.current = setTimeout(() => void tick(), 1000);
+ return;
+ }
+ setRenderWait(null);
+ then(j);
+ };
+ void tick();
+ }, []);
+
+ const read = async (reading: number) => {
+ if (!tuning || !text?.trim()) return;
+ setError(null);
+ setStatus(null);
+ const r = await fetch("/api/report/voices", {
+ method: "POST", headers: { "content-type": "application/json" },
+ body: JSON.stringify({ project, op: "try", who: id, text: text.trim(), tuning: { ...tuning, takes: tuning.takes ?? null }, reading }),
+ });
+ const j = (await r.json().catch(() => ({}))) as { job?: JobPoll; error?: string; running?: JobPoll };
+ if (r.status === 409 && j.running) {
+ // Another job holds umtool's runner: said here, the buttons open again when it ends.
+ setBlocked(`Another job is running (${j.running.kind ?? "a job"}): Read it is open again when it ends.`);
+ follow(j.running.id, () => setBlocked(null));
+ return;
+ }
+ if (!r.ok || !j.job) {
+ setError(j.error ?? `HTTP ${r.status}`);
+ return;
+ }
+ setJob(j.job);
+ follow(j.job.id, (done) => {
+ setJob(done);
+ if (done.state === "failed") setError(`the read failed: ${done.error ?? "see the job's log on /jobs"}`);
+ else {
+ playNext.current = true;
+ setStatus(`reading ${reading} made`);
+ }
+ void load();
+ });
+ };
+ const another = () => {
+ if (!tuning || !text) return;
+ const mine = (data?.tries ?? []).filter((t) => t.voice === voice && t.text === text.trim() && sameTuning(t.tuning ?? {}, tuning, settingTakes));
+ void read(mine.length ? Math.max(...mine.map((t) => t.reading)) + 1 : 1);
+ };
+ const keep = async () => {
+ if (!tuning) return;
+ const j = await post({ op: "character-set", scope, id, tuning: { ...tuning, takes: tuning.takes ?? null } });
+ if (j) {
+ onKept(`${name}: Orpheus tuning kept (${NAME_LABEL[named]}) ${scope === "cast" ? "in the cast (every project)" : "for this video only"}`);
+ void load();
+ }
+ };
+ const pick = (n: TtsTuningName) => setForm((f) => ({ ...(f ?? formOf(null)), temperature: String(ORPHEUS_TUNING_NAMED[n].temperature), top_p: String(ORPHEUS_TUNING_NAMED[n].top_p), repeat_penalty: String(ORPHEUS_TUNING_NAMED[n].repeat_penalty) }));
+ const staleIds = useMemo(() => [...new Set(stale.map((s) => s.id))], [stale]);
+
+ return (
+ <div className="mt-2" data-tuning={id} data-tuning-name={named} data-tuning-kept={isKept ? "yes" : "no"}>
+ <div className="flex flex-wrap items-center gap-x-3 gap-y-1.5">
+ <span className="text-muted">Orpheus tuning</span>
+ <span role="radiogroup" aria-label={`${name}'s Orpheus tuning: a starting point`} className="inline-flex gap-1">
+ {ORPHEUS_TUNING_NAMES.map((n) => {
+ const t = ORPHEUS_TUNING_NAMED[n];
+ return (
+ <button
+ key={n} type="button" role="radio" aria-checked={named === n} data-tuning-pick={n} disabled={!orpheus}
+ aria-label={`Orpheus tuning: ${NAME_LABEL[n]} (temperature ${t.temperature}, top_p ${t.top_p}, repeat penalty ${t.repeat_penalty})`}
+ onClick={() => pick(n)} className={buttonVariants({ variant: named === n ? "pressed" : "outline", size: "sm" })}
+ >
+ {NAME_LABEL[n]}
+ </button>
+ );
+ })}
+ </span>
+ {named === "custom" && <span className="rounded-[3px] border border-seam-2 px-1 text-[10.5px] text-text-2" data-tuning-custom="">custom</span>}
+ {!orpheus && <span className="text-[11px] text-doubt-text" data-tuning-ignored="">{voice.split(":")[0] || "this voice"} ignores a tuning</span>}
+ </div>
+ <div className="mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1.5">
+ {FIELDS.map(({ k, label, step }) => {
+ const r = TTS_TUNING_RANGES[k];
+ return (
+ <label key={k} className="inline-flex items-center gap-1.5" title={`${r.min}–${r.max}${k === "takes" ? `; empty: the editor's setting (${settingTakes})` : ""}`}>
+ <span className="text-muted">{label}</span>
+ <input
+ data-tuning-field={k} type="number" min={r.min} max={r.max} step={step} disabled={!orpheus || !form}
+ aria-label={`Orpheus tuning: ${label}`} placeholder={k === "takes" ? String(settingTakes) : undefined}
+ value={form?.[k] ?? ""} onChange={(e) => setForm((f) => ({ ...(f ?? formOf(null)), [k]: e.target.value }))}
+ aria-invalid={nums && !nums.ok && nums.field === k ? true : undefined}
+ className={cn(input, "w-16", nums && !nums.ok && nums.field === k && "border-reject-text")}
+ />
+ </label>
+ );
+ })}
+ <span className="text-[11px] text-muted" data-tuning-effective="">
+ {data ? (data.character.tuning.tuning ? `kept: ${NAME_LABEL[data.character.tuning.name] ?? data.character.tuning.name} · ${numbersWords(data.character.tuning.effective, settingTakes)}` : `kept: none (Default · takes ${settingTakes})`) : ""}
+ </span>
+ </div>
+
+ <div className="mt-2 flex flex-wrap items-start gap-1.5">
+ <textarea
+ data-tuning-text="" aria-label="the line to try" value={text ?? ""} onChange={(e) => setText(e.target.value)} rows={2} maxLength={400}
+ className={cn(input, "min-w-[18rem] flex-1")} disabled={!orpheus}
+ />
+ <button type="button" data-tuning-read="" aria-label="Read the line with these settings" disabled={off || !tuning || !text?.trim()} onClick={() => void read(0)} className={buttonVariants({ variant: "outline", size: "sm" })}>
+ Read it
+ </button>
+ <button type="button" data-tuning-another="" aria-label="Read the same line again, the next reading" disabled={off || !tuning || !text?.trim()} onClick={another} className={buttonVariants({ variant: "outline", size: "sm" })}>
+ Another reading
+ </button>
+ <button type="button" data-tuning-keep="" aria-label={`Keep these settings for ${name} (${scope === "cast" ? "the cast" : "this video"})`} disabled={busy || running || !tuning || isKept || !orpheus} onClick={() => void keep()} className={buttonVariants({ variant: "go", size: "sm" })}>
+ Keep these settings
+ </button>
+ </div>
+ {running && <p className="m-0 mt-1 text-[11.5px] text-text-2" data-tuning-running="">reading… (the editor's tts)</p>}
+ {renderWait && <p className="m-0 mt-1 text-[11.5px] text-doubt-text" data-tuning-render-wait="">{renderWait}</p>}
+ {blocked && <p className="m-0 mt-1 text-[11.5px] text-doubt-text" data-tuning-blocked="">{blocked}</p>}
+ {status && <p className="m-0 mt-1 text-[11.5px] text-text-2" data-tuning-status="">{status}</p>}
+ {error && <p role="alert" className="m-0 mt-1 text-[11.5px] text-reject-text" data-tuning-error="">{error}</p>}
+
+ {data && data.tries.length > 0 && (
+ <table className="mt-2 w-full border-collapse text-[11.5px]" data-tuning-tries={data.tries.length}>
+ <tbody>
+ {data.tries.map((t, i) => (
+ <tr key={t.key} data-tuning-try={t.reading} data-tuning-try-key={t.key} className="align-top">
+ <td className="border-t border-seam px-1.5 py-1 text-text-2">{t.text.length > 70 ? `${t.text.slice(0, 70)}…` : t.text}</td>
+ <td className="border-t border-seam px-1.5 py-1 font-mono text-[11px]" data-tuning-try-numbers="">
+ {NAME_LABEL[ttsTuningNameOf(t.tuning)] ?? "custom"} · {numbersWords(t.tuning ?? {}, settingTakes)}
+ </td>
+ <td className="border-t border-seam px-1.5 py-1 whitespace-nowrap">reading {t.reading}</td>
+ <td className="border-t border-seam px-1.5 py-1 w-[16rem]">
+ <audio ref={i === 0 ? (a) => { newest.current = a; } : undefined} controls preload="none" src={fileUrl(project, t.rel, t.key)} className="w-full" aria-label={`play reading ${t.reading}`} data-tuning-try-audio="" />
+ {t.lufs !== null && <span className="text-[10.5px] text-muted" title="every try is brought to one loudness, so they compare by ear, not by level">{t.lufs.toFixed(1)} LUFS</span>}
+ </td>
+ <td className="border-t border-seam px-1.5 py-1 whitespace-nowrap">
+ <button type="button" className="ink-link" data-tuning-try-use={t.key} aria-label={`Use reading ${t.reading}'s numbers`} onClick={() => { setForm(formOf(t.tuning)); setText(t.text); }}>
+ use these numbers
+ </button>
+ </td>
+ </tr>
+ ))}
+ </tbody>
+ </table>
+ )}
+
+ <p className="m-0 mt-2 text-[11.5px]" data-tuning-stale={staleIds.length}>
+ {staleIds.length ? (
+ <span className="text-doubt-text">
+ {staleIds.length} read{staleIds.length === 1 ? "" : "s"} by this character {staleIds.length === 1 ? "was" : "were"} made with other settings:{" "}
+ {staleIds.map((x, i) => (
+ <span key={x}>
+ {i ? ", " : ""}
+ <a href={postBenchHref(project, x)} className="ink-link font-mono" data-tuning-stale-item={x}>{x}</a>
+ </span>
+ ))}
+ </span>
+ ) : (
+ <span className="text-muted">no read by this character was made with other settings</span>
+ )}
+ </p>
+ </div>
+ );
+}
diff --git a/umtool/components/projects/VoicesPanel.tsx b/umtool/components/projects/VoicesPanel.tsx
@@ -5,6 +5,7 @@ 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";
+import type { StaleRead } from "./CharacterTuning";
import { ProposedCharacters, type Proposal } from "./ProposedCharacters";
// ---------------------------------------------------------------------------
@@ -39,6 +40,8 @@ type Character = {
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 }[];
+ // Its reads made with other settings than its Orpheus tuning now (stale: listed, never re-made).
+ stale?: StaleRead[];
};
// 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`).
@@ -57,6 +60,7 @@ type View = {
project: string; castFile: string | null; castError?: string; map: Record<string, string>;
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 }[];
+ tuningStale?: StaleRead[];
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;
@@ -340,6 +344,11 @@ export default function VoicesPanel({ project, posts, initialWho = null }: { pro
) : (
<span className="text-muted" data-voice-drift="0">none yet</span>
)}
+ {c.stale && c.stale.length > 0 && (
+ <div className="text-[11px] text-doubt-text" data-voice-stale={new Set(c.stale.map((d) => d.id)).size} title={c.stale.map((d) => `${d.id} ${d.role}: made with temperature ${d.made.temperature}, top_p ${d.made.top_p}, repeat penalty ${d.made.repeat_penalty}, takes ${d.made.takes}`).join("\n")}>
+ {new Set(c.stale.map((d) => d.id)).size} made with other settings
+ </div>
+ )}
</td>
<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>}
@@ -415,7 +424,7 @@ export default function VoicesPanel({ project, posts, initialWho = null }: { pro
{/* --- 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)} />
+ <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)} project={project} stale={(view.tuningStale ?? []).filter((d) => d.character === preset.id)} />
{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">
diff --git a/umtool/e2e/character-tuning.spec.ts b/umtool/e2e/character-tuning.spec.ts
@@ -0,0 +1,148 @@
+import { test, expect } from "@playwright/test";
+import { copyFileSync, existsSync, readFileSync, readdirSync, rmSync } from "node:fs";
+import { createHash } from "node:crypto";
+import path from "node:path";
+import { fileURLToPath } from "node:url";
+import * as urls from "./urls";
+import { TUNING_LINE } from "./fixtures/tuning-fixture.mjs";
+
+// ---------------------------------------------------------------------------
+// A CHARACTER's ORPHEUS TUNING, in its preset on the Voices page (lane character-tuning, S2 of
+// plans/orpheus-retune.md; components/projects/CharacterTuning.tsx, /api/report/voices, lib/report/castCli.mjs
+// `cast set|try|stale`). Fixture: e2e/fixtures/tuning-fixture.mjs -- this video's own "teller" (orpheus · tara) and
+// three reads of it (made with the defaults; with its line's own tuning; recorded). Every step a press:
+//
+// Lively fills the numbers; a number edited is "custom"
+// the line it reads in this project, prefilled; Read it -> a job (the stub editor's tts) -> a try, reading 0;
+// Another reading -> reading 1, the same numbers
+// another job running: said in place, the buttons open again when it ends
+// Keep these settings -> umtool cast project <p> set: the preset says the tuning kept
+// the read made with the defaults is now one made with other settings (listed, never re-made)
+// and nothing the cut shows changed: the manifest, every drawn card, no take
+// ---------------------------------------------------------------------------
+
+const HERE = path.dirname(fileURLToPath(import.meta.url));
+const FIXTURE = path.join(HERE, "..", ".e2e-song");
+const P = "reports/tuning-fixture";
+const DIR = path.join(FIXTURE, "reports", "tuning-fixture");
+const MANIFEST = path.join(DIR, "video.manifest.json");
+const CHARACTERS = path.join(DIR, "narration", "characters.json");
+const STUB_LOG = path.join(FIXTURE, "editor-stub.requests.json");
+
+type Tts = { route: string; text?: string; engine?: string; voice?: string; tuning?: Record<string, number>; reading?: number };
+const ttsAsks = () => (existsSync(STUB_LOG) ? (JSON.parse(readFileSync(STUB_LOG, "utf8")) as Tts[]) : []).filter((r) => r.route === "tts" && r.voice === "tara");
+const sha = (s: string) => createHash("sha1").update(s).digest("hex");
+const takeFiles = () => readdirSync(path.join(DIR, "narration", "posts"), { recursive: true }).map(String).sort();
+/** Every post item's card as drawn (the card page, plain and following) and its plan: what the cut shows. */
+const drawn = async () => {
+ const { postCardHtml, postItemPlan } = (await import("../report-to-video/post-item.mjs")) as unknown as {
+ postCardHtml: (e: unknown, o: Record<string, unknown>) => string; postItemPlan: (e: unknown, r?: unknown) => unknown;
+ };
+ const m = JSON.parse(readFileSync(MANIFEST, "utf8")) as { render?: unknown; timeline: unknown[] };
+ return m.timeline.map((e) => sha(JSON.stringify([postCardHtml(e, { width: 1080, height: 1350 }), postCardHtml(e, { width: 1080, height: 1350, follow: true }), postItemPlan(e, m.render)])));
+};
+
+test.beforeAll(() => {
+ for (const f of [MANIFEST, CHARACTERS]) if (!existsSync(`${f}.pristine`)) copyFileSync(f, `${f}.pristine`);
+});
+const reset = () => {
+ for (const f of [MANIFEST, CHARACTERS]) copyFileSync(`${f}.pristine`, f);
+ rmSync(CHARACTERS.replace(/\.json$/, ".undo.json"), { force: true });
+ rmSync(path.join(DIR, "narration", "auditions"), { recursive: true, force: true });
+};
+test.beforeEach(() => {
+ test.setTimeout(240_000);
+ reset();
+});
+test.afterAll(reset);
+
+test("a character's tuning: Lively, Read it, Another reading, Keep -- its stale read listed, nothing shown changed", async ({ page }) => {
+ const manifestBefore = readFileSync(MANIFEST, "utf8");
+ const cardsBefore = await drawn();
+ const takesBefore = takeFiles();
+ const asksBefore = ttsAsks().length;
+
+ await page.goto(urls.voicesHref(P));
+ const row = page.locator('[data-voices-character="teller"]');
+ await expect(row).toBeVisible({ timeout: 30_000 });
+ await row.locator('[data-voices-preset-open="teller"]').click();
+ const ed = page.locator('[data-preset-editor="teller"]');
+ const tune = ed.locator('[data-tuning="teller"]');
+ await expect(tune).toHaveAttribute("data-tuning-name", "default");
+ await expect(tune.locator("[data-tuning-stale]")).toHaveAttribute("data-tuning-stale", "0");
+ // The line it reads in this project, prefilled.
+ await expect(tune.locator("[data-tuning-text]")).toHaveValue(TUNING_LINE);
+
+ // Lively: the numbers shown under the name; one edited is custom; Lively again.
+ await tune.getByRole("radio", { name: /Orpheus tuning: Lively/ }).click();
+ await expect(tune).toHaveAttribute("data-tuning-name", "lively");
+ await expect(tune.locator('[data-tuning-field="temperature"]')).toHaveValue("0.75");
+ await expect(tune.locator('[data-tuning-field="top_p"]')).toHaveValue("0.92");
+ await expect(tune.locator('[data-tuning-field="repeat_penalty"]')).toHaveValue("1.25");
+ await tune.locator('[data-tuning-field="temperature"]').fill("0.8");
+ await expect(tune.locator("[data-tuning-custom]")).toBeVisible();
+ await tune.locator('[data-tuning-pick="lively"]').click();
+ await expect(tune.locator("[data-tuning-custom]")).toHaveCount(0);
+
+ // Read it: a job (the stub editor's tts, asked with the numbers), a try at reading 0 in the list.
+ await tune.getByRole("button", { name: "Read the line with these settings" }).click();
+ await expect(tune.locator('[data-tuning-try="0"]')).toBeVisible({ timeout: 60_000 });
+ let asks = ttsAsks().slice(asksBefore);
+ expect(asks).toHaveLength(1);
+ expect(asks[0].tuning).toEqual({ temperature: 0.75, top_p: 0.92, repeat_penalty: 1.25 });
+ expect(asks[0].reading).toBeUndefined();
+ expect(asks[0].text).toBe(TUNING_LINE);
+ await expect(tune.locator('[data-tuning-try="0"] [data-tuning-try-numbers]')).toContainText("Lively · temperature 0.75 · top_p 0.92 · repeat penalty 1.25");
+ await expect(tune.locator('[data-tuning-try="0"] [data-tuning-try-audio]')).toHaveAttribute("src", /narration%2Fauditions%2F[0-9a-f]{20}\.wav/);
+
+ // Another reading: the same line and numbers, reading 1.
+ await tune.getByRole("button", { name: "Read the same line again, the next reading" }).click();
+ await expect(tune.locator('[data-tuning-try="1"]')).toBeVisible({ timeout: 60_000 });
+ asks = ttsAsks().slice(asksBefore);
+ expect(asks).toHaveLength(2);
+ expect(asks[1].reading).toBe(1);
+ expect(asks[1].tuning).toEqual(asks[0].tuning);
+ await expect(tune.locator("[data-tuning-tries]")).toHaveAttribute("data-tuning-tries", "2");
+
+ // Another job running: said in place, Read it closed until it ends (umtool runs one job at a time).
+ let busy = true;
+ const tryPost = (u: URL) => u.pathname === "/api/report/voices" && !u.search;
+ const busyJob = (u: URL) => u.pathname === "/api/report/voices" && u.searchParams.get("job") === "busy-1";
+ await page.route(tryPost, async (route) => {
+ const body = route.request().postDataJSON() as { op?: string } | null;
+ if (route.request().method() === "POST" && body?.op === "try") {
+ return route.fulfill({ status: 409, contentType: "application/json", body: JSON.stringify({ error: "another job is running", busy: true, running: { id: "busy-1", kind: "cast-audition reports/tuning-fixture", state: "running", error: null } }) });
+ }
+ return route.continue();
+ });
+ await page.route(busyJob, (route) => route.fulfill({ contentType: "application/json", body: JSON.stringify({ id: "busy-1", state: busy ? "running" : "done", error: null }) }));
+ await tune.locator("[data-tuning-read]").click();
+ await expect(tune.locator("[data-tuning-blocked]")).toContainText("Another job is running (cast-audition reports/tuning-fixture): Read it is open again when it ends.");
+ await expect(tune.locator("[data-tuning-read]")).toBeDisabled();
+ busy = false;
+ await expect(tune.locator("[data-tuning-blocked]")).toHaveCount(0, { timeout: 10_000 });
+ await expect(tune.locator("[data-tuning-read]")).toBeEnabled();
+ await page.unroute(tryPost);
+ await page.unroute(busyJob);
+ expect(ttsAsks().slice(asksBefore), "the refused press asked nothing").toHaveLength(2);
+
+ // Keep these settings: the CLI's own command; the preset says it is kept; the read made with the defaults is stale.
+ await tune.getByRole("button", { name: /Keep these settings for The Teller \(this video\)/ }).click();
+ await expect(page.locator("[data-voices-status]")).toContainText("The Teller: Orpheus tuning kept (Lively) for this video only");
+ const kept = (JSON.parse(readFileSync(CHARACTERS, "utf8")) as { characters: { id: string; synthetic?: { tuning?: Record<string, number> } }[] }).characters.find((c) => c.id === "teller");
+ expect(kept?.synthetic?.tuning).toEqual({ temperature: 0.75, top_p: 0.92, repeat_penalty: 1.25 });
+ const tune2 = page.locator('[data-preset-editor="teller"] [data-tuning="teller"]');
+ await expect(tune2).toHaveAttribute("data-tuning-kept", "yes");
+ await expect(tune2.locator("[data-tuning-effective]")).toContainText("kept: Lively · temperature 0.75 · top_p 0.92 · repeat penalty 1.25");
+ await expect(tune2.locator("[data-tuning-stale]")).toHaveAttribute("data-tuning-stale", "1");
+ await expect(tune2.locator("[data-tuning-stale]")).toContainText("1 read by this character was made with other settings: p-1");
+ await expect(tune2.locator("[data-tuning-stale-item]")).toHaveCount(1);
+ await expect(row.locator("[data-voice-stale]")).toHaveAttribute("data-voice-stale", "1");
+ // The tries are still there after the keep (scratch, the project's).
+ await expect(tune2.locator("[data-tuning-tries]")).toHaveAttribute("data-tuning-tries", "2");
+
+ // Nothing the cut shows changed: the manifest byte for byte, every card as drawn, no take made, no script written.
+ expect(readFileSync(MANIFEST, "utf8")).toBe(manifestBefore);
+ expect(await drawn()).toEqual(cardsBefore);
+ expect(takeFiles()).toEqual(takesBefore);
+});
diff --git a/umtool/e2e/fixtures/make-fixture.mjs b/umtool/e2e/fixtures/make-fixture.mjs
@@ -39,6 +39,7 @@ import { makeTakeWalkFixture } from "./take-walk-fixture.mjs";
import { makeCutIntegrityFixture } from "./cut-integrity-fixture.mjs";
import { makeUiOpsFixture } from "./ui-ops-fixture.mjs";
import { makeVoicesFixture } from "./voices-fixture.mjs";
+import { makeTuningFixture } from "./tuning-fixture.mjs";
import { makeRecordFilterFixture } from "./record-filter-fixture.mjs";
import { makeYoutubeFixture } from "./youtube-fixture.mjs";
import { makeBoardFixture, makeResearchFixture } from "./research-fixture.mjs";
@@ -1931,6 +1932,8 @@ makeCutIntegrityFixture({ reports, manifest, cachedWindow: path.join(REPORT, "ou
makeUiOpsFixture({ reports, channels: CHANNELS, manifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4"), ff });
// The Voices page (voices.spec.ts): Host's clips (the real voice) and post items by @hostman and @guest.
makeVoicesFixture({ reports, channels: CHANNELS, manifest, ff });
+// A character's Orpheus tuning on the Voices page (character-tuning.spec.ts): its own character, three reads.
+makeTuningFixture({ reports, manifest, ff });
// Record -> filter -> preview on the record page (record-filter.spec.ts): three one-part post items, no cast.
makeRecordFilterFixture({ reports, manifest });
// Release 28 M6: the YouTube text, previewed and built (media-draft-e.spec.ts).
diff --git a/umtool/e2e/fixtures/tuning-fixture.mjs b/umtool/e2e/fixtures/tuning-fixture.mjs
@@ -0,0 +1,48 @@
+// A CHARACTER's ORPHEUS TUNING (character-tuning.spec.ts; components/projects/CharacterTuning.tsx, lib/report/castCli.mjs
+// `cast set|try|stale`): one character of this video's own, "teller" (orpheus · tara), and the reads it makes --
+//
+// reports/tuning-fixture/
+// p-1 @teller its picked take orpheus · tara, made with the DEFAULTS (a 262 Hz tone): stale once a tuning is kept
+// p-2 @teller its picked take made with its line's OWN tuning (temperature 0.9): never stale
+// p-3 @teller its picked take RECORDED: never stale
+// narration/characters.json teller, no tuning yet
+//
+// The cast (<fixture>/.umtool/cast.json) is not used: the character is this video's own. The editor is the suite's
+// stub (its tts writes a tone and reports the tuning it was asked). Invented people, like every fixture.
+import { mkdirSync, writeFileSync } from "node:fs";
+import path from "node:path";
+
+export const TUNING = "tuning-fixture";
+export const TUNING_LINE = "The teller says the bridge over the river was closed for the whole long winter.";
+
+const write = (dir, name, doc) => {
+ mkdirSync(dir, { recursive: true });
+ writeFileSync(path.join(dir, name), typeof doc === "string" ? doc : JSON.stringify(doc, null, 2) + "\n");
+};
+
+/** @param {{ reports: string, manifest: Function, ff: (args: string[]) => void }} o */
+export function makeTuningFixture({ reports, manifest, ff }) {
+ const dir = path.join(reports, TUNING);
+ const made = (o = {}) => ({ temperature: 0.55, top_p: 0.85, top_k: 50, min_p: 0, repeat_penalty: 1.2, takes: 3, ...o });
+ const post = (id, text, take) => ({
+ type: "post", id: `p-${id}`, post: `tuningx/${id}`, platform: "x", author: "The Teller", handle: "teller", date: `2026-10-30T1${id}:00:00.000Z`, text,
+ url: `https://x.com/teller/status/${id}`, engagement: { likes: 1 }, section: 0,
+ narration: { script: text, takes: [{ seconds: 2, script: text, at: "2026-11-02T00:00:00.000Z", ...take }], pick: 0 },
+ });
+ const tone = (rel) => {
+ mkdirSync(path.dirname(path.join(dir, rel)), { recursive: true });
+ ff(["-f", "lavfi", "-i", "sine=frequency=262:sample_rate=48000:duration=2", "-ac", "1", "-c:a", "pcm_s16le", path.join(dir, rel)]);
+ };
+ const timeline = [
+ post("1", TUNING_LINE, { file: "narration/posts/1/take-1.orpheus-tara.wav", engine: "orpheus", voice: "tara", tuning: made(), reading: 0 }),
+ post("2", "The teller answers a second question about the ferry and its fares.", { file: "narration/posts/2/take-1.orpheus-tara.wav", engine: "orpheus", voice: "tara", tuning: made({ temperature: 0.9 }), reading: 0 }),
+ post("3", "The teller reads this one aloud in a voice of his own.", { file: "narration/posts/3/take-1.recorded.wav", engine: "recorded", voice: "operator" }),
+ ];
+ for (const e of timeline) tone(e.narration.takes[0].file);
+ write(dir, "video.manifest.json", manifest(TUNING, "The Tuning Fixture", {}, timeline));
+ write(path.join(dir, "narration"), "characters.json", {
+ format: "umtool-project-characters", version: 1,
+ characters: [{ id: "teller", name: "The Teller", handles: ["teller"], synthetic: { voice: "orpheus:tara" } }],
+ });
+ return dir;
+}