commit 9b61df4d11bb2356c7579f2e9589769ceff1d82b
parent afb414909a8b4c83d1fa1bf1aaaa0796129dfee1
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Tue, 17 Nov 2026 13:11:28 -0500
review 2: a plain Read again asks the character's tuning as it is now
- The Tune's baseline is what a plain press reads now: the piece's
character's tuning (none: the defaults), unless its last read was the
line's own (then those numbers, and they stay its own). A press asks as the
line's own only what differs from the character's (lib/report/tuneAsk.mjs);
the panel says where it starts. Defaults on a Lively line asks the three
defaults as its own.
- One rule for ownership (post-say.mjs tuningAskOf) in makeTake, the bench's
take op and every thread piece, decided from the values AS ASKED: an
explicit default is the read's own; read.tuned keeps the read's own values
(its takes too).
- The thread Tune starts from his piece and keeps for his character; a Keep
pins takes only when typed, and is one write per press.
- GET ?reads=all: one call per item, the playing read's voice overrides
kept, read again after a Keep. knobs.md: a screen line spoken by a display
name is not listed stale.
- Tests: the must's e2e (failed on the pre-fix code at the second take's
tuningAsked), tuneAsk.test.mjs, the explicit-default and own-takes thread
tests.
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat:
16 files changed, 506 insertions(+), 108 deletions(-)
diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md
@@ -52,9 +52,12 @@
by field. The take, and each thread part, records where its tuning came from: `tuningAsked` `"preset"` (the
character's: stale when that changes) or `true` (its own). A character with no tuning asks, keys and records
exactly as before (pinned against main).
- - On the bench, the Tune's **Keep this tuning for <character>** keeps the numbers as the character's (the cast's, or
- this video's own) and says what that leaves made with other settings. A re-read of a take whose tuning was the
- character's asks the character's tuning as it is then.
+ - On the bench, the Tune starts from what a plain press reads now: the character's tuning, or the line's own when
+ its last read was its own. A press asks as the line's own only what differs from the character's, so a plain Read
+ again of a character's line asks the character's tuning as it is then, and Defaults asks the defaults as the
+ line's own. **Keep this tuning for <character>** keeps the numbers as the character's (the cast's, or this video's
+ own) and says what that leaves made with other settings. `cast reread` of a take whose tuning was the character's
+ asks the character's tuning as it is then.
- **An Orpheus line can be read again differently: the tts op takes a `tuning` and a `reading`.** `pnpm ops tts`
(`POST /api/ops/tts`) takes `tuning` (any of temperature 0.1–1.5, top_p 0.05–1, top_k 0–200, min_p 0–0.5,
repeat_penalty 1–2, takes 1–6) and `reading` (0–99,999; reading r reads with seed base 1234 + 9973 × r). A value out
diff --git a/umtool/app/api/report/post-narration/route.ts b/umtool/app/api/report/post-narration/route.ts
@@ -22,6 +22,7 @@ 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 { tuningAskOf } from "umtool-report-to-video/post-say";
import { characterById, recordedPresetOf, shownNameOf } from "umtool-report-to-video/cast";
import { readLayers, recordedTrimFor } from "@/lib/report/characterLayers.mjs";
import { convertAskOf, derivePitchOf, deriveRefusalOf, stepPitchOf } from "@/lib/report/derivePitch.mjs";
@@ -93,10 +94,10 @@ const benchVoice = (red: { slurs?: { voice?: string } | null } | null) => (red?.
// screens, else `posts narrate <p> <item> --take --thread` asked as the
// playing read was -- every synthesized piece's next reading, unpicked
// GET ?project&id&screenJob=<job> either job: its state, its result, and -- ended -- the entry as it is
-// GET ?project&id&reads=<role> the CHARACTER whose synthetic preset reads that piece of the item
-// (post, parent:<i>, quoted, linked:<i>, screen:<id>:<n>) now:
-// {character: {id, name, layer: "cast" | "project"} | null} -- the one a
-// Tune's "Keep for <character>" keeps a tuning for (lane character-tuning)
+// GET ?project&id&reads=all the CHARACTER whose synthetic preset reads each piece of the item now
+// (the playing read's overrides kept), and its tuning: {pieces: {<role>:
+// {character: {id, name, layer: "cast" | "project"} | null, tuning}}} --
+// a Tune's baseline and its "Keep for <character>" (lane character-tuning)
// GET ?project&id&pending=1 the post's read being made or made and not kept: {jobId, file,
// script, note} -- the bench follows `?job` with them to land its take
@@ -143,22 +144,29 @@ export async function GET(request: Request) {
return Response.json({ ok: true, prompts }, { headers: noStore });
}
if (id && q.get("reads") !== null) {
- // The character whose synthetic preset answers for one piece of this item's read now (the chain every read asks:
- // readVoice.mjs for his own words, the thread read's pieces for the rest) -- and where it is kept.
+ // THE CHARACTER EACH PIECE OF THIS ITEM's READ IS MADE WITH NOW, and its tuning (lane character-tuning): the plan a
+ // read would make (postThreadRead.mjs, a dry run -- the playing thread read's own options and voice overrides
+ // kept, so a piece its read gives another voice on purpose has no character), each synthesized piece's
+ // `{ character: {id, name, layer} | null, tuning }` -- `tuning` the character's (null: the defaults). One call per
+ // item: the bench's panels share it.
const e = postsOf(m).find((x) => x.id === id);
if (!e) return Response.json({ error: `no post item ${id}` }, { status: 404 });
- const role = String(q.get("reads") || "post");
- if (!/^(post|quoted|parent:\d|linked:\d|screen:[a-z0-9][a-z0-9-]{0,23}:\d{1,2})$/.test(role)) return Response.json({ error: "reads names one piece of a read (post, quoted, parent:<i>, linked:<i>, screen:<id>:<n>)" }, { status: 400 });
const L = await readLayers(r.project.dir).catch(() => null);
- let charId: string | null = null;
- if (role === "post") charId = ((await itemReadVoice(r.project, e, { render: (m.render ?? {}) as Record<string, unknown> }).catch(() => null)) as { character?: string } | null)?.character ?? null;
- else {
- const { threadTake } = await import("@/lib/report/postThreadRead.mjs");
- const plan = await threadTake(r.project, e, { manifest: m, dryRun: true, parents: "all" }).then((x: { plan?: { pieces?: Array<{ role: string; character?: string }> } }) => x.plan ?? null, () => null);
- charId = plan?.pieces?.find((pc) => pc.role === role)?.character ?? null;
+ const takes = (e.narration?.takes ?? []) as Array<{ read?: Record<string, unknown> }>;
+ const pick = Number.isInteger(e.narration?.pick) ? Number(e.narration?.pick) : 0;
+ const rd = (takes[pick]?.read?.kind === "thread" ? takes[pick].read : null) as { parents?: string; skip?: string[]; quoted?: boolean; linked?: boolean; seen?: boolean; voiceFor?: Record<string, string>; voice?: string; screens?: boolean } | null;
+ const { threadTake } = await import("@/lib/report/postThreadRead.mjs");
+ const plan = await threadTake(r.project, e, {
+ manifest: m, dryRun: true, parents: rd?.parents ?? "0", skip: rd?.skip ?? [], quoted: rd?.quoted !== false, linked: rd?.linked !== false, readSeen: rd?.seen === true,
+ overrides: rd?.voiceFor ?? {}, voice: rd?.voice ?? null, screens: rd?.screens !== false,
+ }).then((x: { plan?: { pieces?: Array<{ role: string; character?: string; take?: unknown; tuning?: Record<string, number>; tuningAsked?: unknown }> } }) => x.plan ?? null, () => null);
+ const pieces: Record<string, { character: { id: string; name: string; layer: string } | null; tuning: Record<string, number> | null }> = {};
+ for (const pc of plan?.pieces ?? []) {
+ if (pc.take || pieces[pc.role]) continue;
+ const hit = pc.character && L ? characterById(pc.character, { project: L.project, cast: L.cast }) : null;
+ pieces[pc.role] = { character: hit ? { id: hit.character.id, name: shownNameOf(hit.character), layer: hit.layer } : null, tuning: hit && pc.tuningAsked === "preset" && pc.tuning ? pc.tuning : null };
}
- const hit = charId && L ? characterById(charId, { project: L.project, cast: L.cast }) : null;
- return Response.json({ character: hit ? { id: hit.character.id, name: shownNameOf(hit.character), layer: hit.layer } : null }, { headers: noStore });
+ return Response.json({ pieces }, { headers: noStore });
}
if (id && q.get("pending") !== null) {
// THE READ OF THIS POST BEING MADE, or made and not yet kept (review 2, finding 2): its marker's job, file and
@@ -443,13 +451,10 @@ async function postHere(request: Request) {
const keepPick = body.keepPick === true;
// Its tuning: the line's own (the Tune), else -- Orpheus only -- its character's (the synthetic preset's that
// answered for the voice: lane character-tuning); a character with no tuning asks as it always did.
- // Field by field, as makeTake: the line's own values over the character's.
- const own = tuned?.ok && Object.keys(tuned.value).length ? tuned.value : null;
- const presetT = (said as { tuning?: Record<string, number> }).tuning;
- const preset = engine === "orpheus" && presetT && Object.keys(presetT).length ? presetT : null;
- const tuning = preset ? { ...preset, ...(own ?? {}) } : own;
- const ownSampler = !!own && Object.keys(own).some((k) => k !== "takes");
- const tuningAsked = engine === "orpheus" && tuning ? (ownSampler || !preset ? true : "preset") : null;
+ // Field by field, as makeTake and every thread piece: the line's own values over the character's (tuningAskOf).
+ const ta = tuningAskOf({ own: tuned?.ok ? tuned.value : null, preset: (said as { tuning?: Record<string, number> }).tuning ?? null, engine });
+ const tuning = ta.tuning;
+ const tuningAsked = ta.asked;
askFile = `${out}.ask.json`;
if (speed || keepPick || tuningAsked) await writeFile(`${out}.ask.json`, JSON.stringify({ ...(speed ? { speed, speedAsked: body.speed !== undefined && body.speed !== null ? true : (e.narration as { speed?: number } | undefined)?.speed != null ? "item" : "preset" } : {}), ...(keepPick ? { keepPick: true } : {}), ...(tuningAsked ? { tuningAsked } : {}) }));
const jobId = await startJob("/api/ops/tts", { text: spoken, engine, voice, out, ...(speed ? { speed } : {}), ...(tuning ? { tuning } : {}), ...(reading !== null ? { reading } : {}) });
diff --git a/umtool/components/projects/PostNarrationPanel.tsx b/umtool/components/projects/PostNarrationPanel.tsx
@@ -287,11 +287,12 @@ export default function PostNarrationPanel({
if (saved) await readAgain(script, tuning);
};
// How this text was last made (its last synthesized take's tuning, else the playing take's): Tune starts there.
- const madeWith = useMemo(() => {
+ const madeTake = useMemo(() => {
const synth = takes.filter((t) => takeSourceOf(t).kind === "tts" && t.read?.kind !== "thread" && t.tuning);
const same = synth.filter((t) => (t.script ?? "").replace(/\s+/g, " ").trim() === (n.script ?? "").replace(/\s+/g, " ").trim());
- return (same.at(-1) ?? (picked?.tuning ? picked : null) ?? synth.at(-1))?.tuning ?? null;
+ return (same.at(-1) ?? (picked?.tuning ? picked : null) ?? synth.at(-1)) ?? null;
}, [takes, n.script, picked]);
+ const madeWith = madeTake?.tuning ?? null;
const legacy = legacyReadOf(entry);
useEffect(() => {
if (!job || job.state !== "running") return;
@@ -358,11 +359,9 @@ export default function PostNarrationPanel({
// What a convert of THIS post defaults to: its author's character in the cast (else the narrator) -- the engine, the
// stock voice and the pitch every recording made that character's lands on (`umtool cast set <id> --convert-pitch …`).
const [castConvert, setCastConvert] = useState<{ name: string; engine?: string | null; voice?: string | null; pitch?: string; semitones?: number } | null>(null);
- // The character this item's read is made with (the convert's answer).
- const [character, setCharacter] = useState<{ id: string; name: string; layer?: string } | null>(null);
- void character;
- // The character whose SYNTHETIC preset reads his words now (lane character-tuning): a Tune is kept for it.
- const readsAs = useKeepForCharacter(project, entry.id, "post");
+ // The character whose SYNTHETIC preset reads his words now (lane character-tuning): a Tune is kept for it, and its
+ // tuning is where the Tune starts -- unless his last read was his own.
+ const readsAs = useKeepForCharacter(project, entry.id, "post", madeTake ? { tuning: madeTake.tuning ?? null, tuningAsked: (madeTake as { tuningAsked?: unknown }).tuningAsked } : null);
useEffect(() => {
let live = true;
setCastConvert(null);
@@ -370,7 +369,6 @@ export default function PostNarrationPanel({
.then((r) => (r.ok ? r.json() : null))
.then((j: { character?: { id?: string; name: string; layer?: string } | null; convert?: { engine?: string | null; voice?: string | null; pitch?: string; semitones?: number } | null } | null) => {
if (live && j?.character && j.convert) setCastConvert({ name: j.character.name, ...j.convert });
- if (live && j?.character) setCharacter(j.character as { id: string; name: string; layer?: string });
})
.catch(() => {});
return () => {
@@ -823,6 +821,7 @@ export default function PostNarrationPanel({
onReadAgain={(t) => void press(() => readAgain(n.script ?? "", t))}
onReadEdited={(t) => void press(() => readEdited(t))}
madeWith={madeWith}
+ baseline={readsAs.baseline}
character={readsAs.character ?? null}
keepForCharacter={keepForCharacter ?? readsAs.keepForCharacter}
autoplay={autoplay}
diff --git a/umtool/components/projects/PostThreadPanel.tsx b/umtool/components/projects/PostThreadPanel.tsx
@@ -3,6 +3,7 @@
import { useEffect, useMemo, useRef, useState } from "react";
import ReadAgain, { playNow, useAutoPlay, type Tuning } from "./read/ReadAgain";
import { useKeepForCharacter } from "./read/keepForCharacter";
+import { threadTuneMadeOf } from "@/lib/report/tuneAsk.mjs";
import { THREAD_DEFAULTS, THREAD_LIMITS, THREAD_MODES, partRoles, readPieces, threadKnobs, threadLayout, threadReadErrors } from "umtool-report-to-video/post-thread";
import { followKnobs } from "umtool-report-to-video/read-follow";
import { pickedTake } from "umtool-report-to-video/post-narration";
@@ -44,8 +45,6 @@ export default function PostThreadPanel({
onEntry?: (e: Entry, token: string | null) => void;
}) {
const own = (entry.thread ?? undefined) as Thread | undefined;
- // The character whose synthetic preset reads his words (lane character-tuning): the thread's Tune is kept for it.
- const readsAs = useKeepForCharacter(project, entry.id, "post");
const k = threadKnobs(entry, render) as Required<Thread>;
const layout = useMemo(() => threadLayout(entry, render, { prev: before, scene }), [entry, render, before, scene]);
const roles = useMemo(() => partRoles(entry) as Array<{ role: string | null; source: string }>, [entry]);
@@ -74,7 +73,11 @@ export default function PostThreadPanel({
};
// READ THE THREAD AGAIN (lane line-rerun): every synthesized piece's next reading, a new take unpicked, played as
// it lands -- `posts screen … read` / `posts narrate … --take --thread` as a umtool job (op thread-read).
- const playing = pickedTake(entry) as { read?: { kind?: string }; parts?: Array<{ reading?: number; tuning?: Tuning }> } | null;
+ const playing = pickedTake(entry) as { read?: { kind?: string }; parts?: Array<{ role?: string; take?: string; reading?: number; tuning?: Tuning; tuningAsked?: true | "preset" }> } | null;
+ // HIS piece (review 2 #4): the thread's Tune starts from how his words were last read and keeps for his character --
+ // never another piece's (a parent's, a screen speaker's).
+ const postPart = threadTuneMadeOf(playing?.parts) as { tuning: Tuning | null; tuningAsked?: unknown } | null;
+ const readsAs = useKeepForCharacter(project, entry.id, "post", postPart);
const [autoplay, setAutoplay] = useAutoPlay();
const [again, setAgain] = useState<{ state: string; waiting?: string | null; error?: string | null; said?: string | null } | null>(null);
const poll = useRef<ReturnType<typeof setTimeout> | null>(null);
@@ -172,7 +175,8 @@ export default function PostThreadPanel({
busy={again?.state === "running"}
waiting={again?.state === "running" ? again.waiting ?? null : null}
onReadAgain={(t) => void readThreadAgain(t)}
- madeWith={playing.parts?.find((p) => p.tuning)?.tuning ?? null}
+ madeWith={postPart?.tuning ?? null}
+ baseline={readsAs.baseline}
character={readsAs.character}
keepForCharacter={readsAs.keepForCharacter}
error={again?.state === "failed" ? again.error ?? "failed" : null}
diff --git a/umtool/components/projects/ScreenLineVoice.tsx b/umtool/components/projects/ScreenLineVoice.tsx
@@ -185,7 +185,7 @@ export type ScreenVoice = ReturnType<typeof useScreenVoice>;
export type LineTakeOption = { id: string; label: string; current: boolean };
/** One synthesized reading of a line: the take it is in (index), its part's file, words, reading and tuning. */
-export type LineReading = { take: number; picked: boolean; file: string | null; text: string; reading: number; tuning: Tuning | null };
+export type LineReading = { take: number; picked: boolean; file: string | null; text: string; reading: number; tuning: Tuning | null; tuningAsked?: true | "preset" };
/** The readings of a line (`role`) in an item's takes: each take whose parts read it, synthesized. */
export function lineReadings(entry: Record<string, unknown>, role: string): LineReading[] {
@@ -193,7 +193,8 @@ export function lineReadings(entry: Record<string, unknown>, role: string): Line
const pick = Number.isInteger(n.pick) ? (n.pick as number) : 0;
return (n.takes ?? []).flatMap((t, i) => {
const p = (t.parts ?? []).find((x) => x.role === role && !(x as { take?: string }).take);
- return p ? [{ take: i, picked: i === pick, file: p.file ?? null, text: String(p.text ?? ""), reading: Number.isInteger(p.reading) ? (p.reading as number) : 0, tuning: p.tuning ?? null }] : [];
+ const asked = (p as { tuningAsked?: unknown }).tuningAsked;
+ return p ? [{ take: i, picked: i === pick, file: p.file ?? null, text: String(p.text ?? ""), reading: Number.isInteger(p.reading) ? (p.reading as number) : 0, tuning: p.tuning ?? null, ...(asked === true || asked === "preset" ? { tuningAsked: asked } : {}) }] : [];
});
}
@@ -201,7 +202,8 @@ export function lineReadings(entry: Record<string, unknown>, role: string): Line
export function ScreenLineVoice({ role, n, voice, dirty, options, chosen, onChoose, readings = [], edited = false }: { role: string; n: number; voice: ScreenVoice; dirty: boolean; options: LineTakeOption[]; chosen: string | undefined; onChoose: (id: string | undefined) => void; readings?: LineReading[]; edited?: boolean }) {
const mine = voice.at === role && voice.phase === "recording";
// The character whose synthetic preset reads this line (its speaker's; lane character-tuning): a Tune is kept for it.
- const readsAs = useKeepForCharacter(voice.project, voice.id, role);
+ const playedLine = readings.find((x) => x.picked) ?? null;
+ const readsAs = useKeepForCharacter(voice.project, voice.id, role, playedLine ? { tuning: playedLine.tuning, tuningAsked: playedLine.tuningAsked } : null);
const t = voice.takes[role];
const busy = voice.job?.state === "running";
const other = voice.phase === "recording" && voice.at !== role;
@@ -246,7 +248,8 @@ export function ScreenLineVoice({ role, n, voice, dirty, options, chosen, onChoo
edited={!dirty && edited}
onReadAgain={(t) => void voice.readLine(role, t)}
onReadEdited={(t) => void voice.readLine(role, t)}
- madeWith={readings.find((x) => x.picked)?.tuning ?? null}
+ madeWith={playedLine?.tuning ?? null}
+ baseline={readsAs.baseline}
character={readsAs.character}
keepForCharacter={readsAs.keepForCharacter}
autoplay={voice.autoplay}
diff --git a/umtool/components/projects/read/ReadAgain.tsx b/umtool/components/projects/read/ReadAgain.tsx
@@ -1,10 +1,11 @@
"use client";
-import { useEffect, useState } from "react";
+import { useEffect, useRef, useState } from "react";
import { buttonVariants } from "@/components/ui/button";
import { cn } from "@/lib/utils";
import { ls } from "../useMic";
-import { ORPHEUS_DEFAULT_TAKES, ORPHEUS_TUNING_DEFAULTS, TTS_TUNING_FIELDS, TTS_TUNING_RANGES } from "yt-dlp-transcript-common/lib/ttsTuning.mjs";
+import { ORPHEUS_DEFAULT_TAKES, ORPHEUS_TUNING_DEFAULTS, TTS_TUNING_FIELDS, TTS_TUNING_RANGES, ttsTuningNameOf } from "yt-dlp-transcript-common/lib/ttsTuning.mjs";
+import { keepAskOf, madeOwnOf as tuneMadeOwnOf, tuneAskOf, tuneStartOf } from "@/lib/report/tuneAsk.mjs";
// ---------------------------------------------------------------------------
// READ AGAIN (lane line-rerun, S3 of the Orpheus re-tune plan): one line's
@@ -26,6 +27,18 @@ export type Tuning = Partial<Record<"temperature" | "top_p" | "top_k" | "min_p"
/** S2's seam: keep these numbers for the character (its command: `umtool cast set <id> --temperature …`). */
export type KeepForCharacter = (tuning: Tuning) => Promise<string | null>;
+/**
+ * THE TUNE's BASELINE (lane character-tuning, review 2): what a plain press reads this piece with NOW -- its
+ * character's tuning (null: the defaults; no character: the defaults), unless its last read was the line's own
+ * (`madeOwn`): then those numbers, and they stay the line's own. A press sends as the line's own only what differs
+ * from the character's (all of it when the last read was the line's own); nothing changed on a character's line sends
+ * none of the sampler, so the character's is asked as it is then.
+ */
+export type TuneBaseline = { character: { name: string; tuning: Tuning | null } | null; madeOwn: boolean };
+/** Was a read the line's own? (lib/report/tuneAsk.mjs: the one rule.) */
+export const madeOwnOf = (tuning: Tuning | null | undefined, tuningAsked: unknown): boolean => tuneMadeOwnOf(tuning, tuningAsked);
+const NAMED: Record<string, string> = { steady: "Steady", default: "Default", lively: "Lively", custom: "custom" };
+
const AUTOPLAY_KEY = "umtool.reads.autoplay";
const LABEL: Record<string, string> = { temperature: "temperature", top_p: "top p", top_k: "top k", min_p: "min p", repeat_penalty: "repeat penalty", takes: "takes" };
// `takes` has no default here: empty is the editor's settings' own (tts.orpheus.takes), never a guessed 3.
@@ -81,7 +94,7 @@ export function madeWithText(t: { reading?: number | null; tuning?: Tuning | nul
}
export default function ReadAgain({
- what = "", busy = false, waiting = null, canReadAgain = true, edited = false, onReadAgain, onReadEdited, madeWith = null, character = null, keepForCharacter, error = null, note = null, autoplay, onAutoplay,
+ what = "", busy = false, waiting = null, canReadAgain = true, edited = false, onReadAgain, onReadEdited, madeWith = null, baseline = null, character = null, keepForCharacter, error = null, note = null, autoplay, onAutoplay,
}: {
/** What is read, in the controls' names: "" (the post), "line 2", "the thread", "the card". */
what?: string;
@@ -94,8 +107,10 @@ export default function ReadAgain({
onReadAgain: (tuning: Tuning | null) => void;
/** Absent: no edited text here (a thread read). */
onReadEdited?: (tuning: Tuning | null) => void;
- /** How the line was last made: the Tune numbers start from it. */
+ /** How the line was last made: the Tune numbers start from it (with no `baseline`, S3's rule). */
madeWith?: Tuning | null;
+ /** What a plain press reads it with now (lane character-tuning): the Tune starts there, and a press sends only what differs. */
+ baseline?: TuneBaseline | null;
/** The character this line is read by, when known: S2 keeps a tuning for it. */
character?: { id: string; name: string; layer?: string } | null;
keepForCharacter?: KeepForCharacter;
@@ -106,11 +121,29 @@ export default function ReadAgain({
autoplay: boolean;
onAutoplay: (on: boolean) => void;
}) {
- const start = (): Record<string, string> => Object.fromEntries(TTS_TUNING_FIELDS.map((k: string) => [k, madeWith?.[k as keyof Tuning] !== undefined ? String(madeWith[k as keyof Tuning]) : k in DEFAULTS ? String(DEFAULTS[k]) : ""]));
+ // The numbers a plain press would read with now: the line's own last numbers, else its character's, else the
+ // defaults; the takes the last read's (lib/report/tuneAsk.mjs).
+ const start = (): Record<string, string> => tuneStartOf({ madeWith, baseline }) as Record<string, string>;
const [draft, setDraft] = useState<Record<string, string>>(start);
const [kept, setKept] = useState<string | null>(null);
- // eslint-disable-next-line react-hooks/exhaustive-deps
- useEffect(() => setDraft(start()), [JSON.stringify(madeWith)]);
+ const [keeping, setKeeping] = useState(false);
+ const keepingRef = useRef(false);
+ // The takes field typed by the operator (a Keep pins takes only then: the draft's are the last read's recorded).
+ const [takesTyped, setTakesTyped] = useState(false);
+ useEffect(() => {
+ setDraft(start());
+ setTakesTyped(false);
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [JSON.stringify(madeWith), JSON.stringify(baseline)]);
+ /**
+ * What a press asks as the line's own: with no character, S3's rule (what differs from the defaults); with one,
+ * what differs from the character's tuning -- all of the sampler when the last read was the line's own -- and the
+ * takes when given (S3's rule).
+ */
+ const ask = (): Tuning | null => (baseline?.character ? (tuneAskOf(draft, baseline) as Tuning | null) : tuningAsked(draft));
+ /** What a Keep keeps: the sampler as it stands, top k and min p when not their defaults, the takes only when typed. */
+ const keepAsk = (): Tuning => keepAskOf(draft, { takesTyped }) as Tuning;
+ const baseWords = !baseline ? null : baseline.madeOwn ? "this line's own" : baseline.character ? `${baseline.character.name}: ${NAMED[ttsTuningNameOf(baseline.character.tuning ?? {})] ?? "custom"}` : "defaults";
const btn = cn(buttonVariants({ variant: "outline", size: "sm" }));
const bad = TTS_TUNING_FIELDS.some((k: string) => {
const r = (TTS_TUNING_RANGES as Record<string, { min: number; max: number; integer: boolean }>)[k];
@@ -121,11 +154,11 @@ export default function ReadAgain({
});
return (
<div className="flex flex-wrap items-center gap-1.5" data-read-again={what || "post"}>
- <button type="button" className={btn} disabled={busy || bad || !canReadAgain} onClick={() => onReadAgain(tuningAsked(draft))} aria-label={what ? `Read ${what} again` : "Read again"} data-read-again-button="">
+ <button type="button" className={btn} disabled={busy || bad || !canReadAgain} onClick={() => onReadAgain(ask())} aria-label={what ? `Read ${what} again` : "Read again"} data-read-again-button="">
Read again
</button>
{onReadEdited && (
- <button type="button" className={btn} disabled={busy || bad || !edited} onClick={() => onReadEdited(tuningAsked(draft))} aria-label={what ? `Read ${what} as edited` : "Read the edited text"} data-read-edited-button="">
+ <button type="button" className={btn} disabled={busy || bad || !edited} onClick={() => onReadEdited(ask())} aria-label={what ? `Read ${what} as edited` : "Read the edited text"} data-read-edited-button="">
Read edited text
</button>
)}
@@ -135,24 +168,50 @@ export default function ReadAgain({
</summary>
<div className="absolute z-10 mt-1 w-64 space-y-1 rounded border border-seam bg-[var(--color-panel)] p-2 shadow">
<span className="micro">this line only</span>
+ {baseWords && (
+ <span className="block text-text-2" data-read-tune-baseline="">
+ from {baseWords}
+ </span>
+ )}
{TTS_TUNING_FIELDS.map((k: string) => {
const r = (TTS_TUNING_RANGES as Record<string, { min: number; max: number; integer: boolean }>)[k];
return (
<label key={k} className="flex items-center justify-between gap-2">
<span>{LABEL[k]}</span>
- <input type="number" min={r.min} max={r.max} step={r.integer ? 1 : 0.01} value={draft[k]} placeholder={k === "takes" ? "settings" : undefined} onChange={(e) => setDraft({ ...draft, [k]: e.target.value })} className="w-20 rounded border border-seam bg-ground px-1 py-0.5" aria-label={`${LABEL[k]}, this line only`} data-read-tune-field={k} />
+ <input type="number" min={r.min} max={r.max} step={r.integer ? 1 : 0.01} value={draft[k]} placeholder={k === "takes" ? "settings" : undefined} onChange={(e) => {
+ setDraft({ ...draft, [k]: e.target.value });
+ if (k === "takes") setTakesTyped(true);
+ }} className="w-20 rounded border border-seam bg-ground px-1 py-0.5" aria-label={`${LABEL[k]}, this line only`} data-read-tune-field={k} />
</label>
);
})}
<div className="flex flex-wrap gap-1.5 pt-1">
- <button type="button" className={btn} disabled={busy || bad || !canReadAgain} onClick={() => onReadAgain(tuningAsked(draft))} aria-label={what ? `Read ${what} again with this tuning` : "Read again with this tuning"} data-read-tune-read="">
+ <button type="button" className={btn} disabled={busy || bad || !canReadAgain} onClick={() => onReadAgain(ask())} aria-label={what ? `Read ${what} again with this tuning` : "Read again with this tuning"} data-read-tune-read="">
Read with these
</button>
<button type="button" className={btn} onClick={() => setDraft(Object.fromEntries(TTS_TUNING_FIELDS.map((k: string) => [k, k in DEFAULTS ? String(DEFAULTS[k]) : ""])))} aria-label="Tuning back to the defaults" data-read-tune-defaults="">
Defaults
</button>
{keepForCharacter && character && (
- <button type="button" className={btn} disabled={bad} onClick={() => void keepForCharacter(tuningAsked(draft) ?? {}).then(setKept)} aria-label={`Keep this tuning for ${character.name}`} data-read-tune-keep="">
+ <button
+ type="button"
+ className={btn}
+ disabled={bad || keeping}
+ onClick={() => {
+ // One keep at a time: a second press while it is written is no second write.
+ if (keepingRef.current) return;
+ keepingRef.current = true;
+ setKeeping(true);
+ void keepForCharacter(keepAsk())
+ .then(setKept)
+ .finally(() => {
+ keepingRef.current = false;
+ setKeeping(false);
+ });
+ }}
+ aria-label={`Keep this tuning for ${character.name}`}
+ data-read-tune-keep=""
+ >
Keep for {character.name}
</button>
)}
diff --git a/umtool/components/projects/read/keepForCharacter.ts b/umtool/components/projects/read/keepForCharacter.ts
@@ -1,37 +1,66 @@
"use client";
import { useEffect, useMemo, useState } from "react";
-import type { KeepForCharacter, Tuning } from "./ReadAgain";
+import type { KeepForCharacter, TuneBaseline, Tuning } from "./ReadAgain";
+import { madeOwnOf } from "@/lib/report/tuneAsk.mjs";
// ---------------------------------------------------------------------------
-// "KEEP FOR <CHARACTER>" (lane character-tuning; ReadAgain.tsx's seam): a Tune's numbers kept as the CHARACTER's --
-// the one whose synthetic preset reads this piece of the item now (GET /api/report/post-narration?reads=<role>),
-// through its command (`umtool cast set <id> …` for a cast character, `cast project <p> set <id> …` for this video's
-// own: /api/report/voices op "character-set"), then what that leaves stale (`umtool cast stale <p> <id>`). Every read
-// of the character asks it from then on, unless its own line asks another; nothing is re-read by itself.
+// A PIECE's CHARACTER ON THE BENCH (lane character-tuning; ReadAgain.tsx's seam): who reads each piece of an item now
+// and with what tuning -- ONE call per item (GET /api/report/post-narration?reads=all, the playing read's voice
+// overrides kept), shared by every panel that mounts a Read again for it, read again after a Keep. It gives each
+// Tune its BASELINE (what a plain press reads the piece with now) and its "Keep for <character>": the numbers kept as
+// the character's through its command (`umtool cast set <id> …` for a cast character, `cast project <p> set <id> …`
+// for this video's own: /api/report/voices op "character-set"), then what that leaves stale (`umtool cast stale`).
// ---------------------------------------------------------------------------
export type ReadCharacter = { id: string; name: string; layer: "cast" | "project" };
+type Piece = { character: ReadCharacter | null; tuning: Tuning | null };
+type Pieces = Record<string, Piece>;
-/** The character whose preset reads `role` of item `id` now (null: none -- no button). */
-export function useReadCharacter(project: string | null | undefined, id: string, role = "post"): ReadCharacter | null {
- const [c, setC] = useState<ReadCharacter | null>(null);
+const store = new Map<string, { data: Pieces | null; loading: boolean; subs: Set<(p: Pieces | null) => void> }>();
+const keyOf = (project: string, id: string) => `${project}\u0000${id}`;
+
+function slot(project: string, id: string) {
+ const k = keyOf(project, id);
+ let s = store.get(k);
+ if (!s) {
+ s = { data: null, loading: false, subs: new Set() };
+ store.set(k, s);
+ }
+ return s;
+}
+
+/** Read an item's pieces again (after a Keep, or a cast change made on the page): every panel of it is told. */
+export async function refreshReads(project: string, id: string): Promise<void> {
+ const s = slot(project, id);
+ s.loading = true;
+ const j = (await fetch(`/api/report/post-narration?project=${encodeURIComponent(project)}&id=${encodeURIComponent(id)}&reads=all`, { cache: "no-store" })
+ .then((r) => (r.ok ? r.json() : null))
+ .catch(() => null)) as { pieces?: Pieces } | null;
+ s.loading = false;
+ const pieces: Pieces = {};
+ for (const [role, p] of Object.entries(j?.pieces ?? {})) {
+ const c = p?.character;
+ pieces[role] = { character: c && (c.layer === "cast" || c.layer === "project") ? c : null, tuning: p?.tuning ?? null };
+ }
+ s.data = pieces;
+ for (const f of s.subs) f(pieces);
+}
+
+/** An item's pieces as the bench reads them (null until known). */
+export function useReads(project: string | null | undefined, id: string): Pieces | null {
+ const [data, setData] = useState<Pieces | null>(() => (project ? store.get(keyOf(project, id))?.data ?? null : null));
useEffect(() => {
if (!project) return;
- let live = true;
- fetch(`/api/report/post-narration?project=${encodeURIComponent(project)}&id=${encodeURIComponent(id)}&reads=${encodeURIComponent(role)}`, { cache: "no-store" })
- .then((r) => (r.ok ? r.json() : null))
- .then((j: { character?: ReadCharacter | null } | null) => {
- if (live) setC(j?.character && (j.character.layer === "cast" || j.character.layer === "project") ? j.character : null);
- })
- .catch(() => {
- if (live) setC(null);
- });
+ const s = slot(project, id);
+ s.subs.add(setData);
+ if (s.data) setData(s.data);
+ else if (!s.loading) void refreshReads(project, id);
return () => {
- live = false;
+ s.subs.delete(setData);
};
- }, [project, id, role]);
- return c;
+ }, [project, id]);
+ return data;
}
const words = (t: Tuning) => Object.entries(t).map(([k, v]) => `${k.replace("_", " ")} ${v}`).join(", ") || "the defaults";
@@ -47,17 +76,31 @@ export function keepTuningFor(project: string, item: string, c: ReadCharacter):
const r = await fetch("/api/report/voices", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ project, op: "character-set", scope: c.layer, id: c.id, tuning }) }).catch(() => null);
const j = (await r?.json().catch(() => null)) as { error?: string; notes?: string[] } | null;
if (!r?.ok) return `not kept: ${j?.error ?? (r ? `HTTP ${r.status}` : "umtool could not be reached")}`;
+ // Every panel of this item reads its baseline again: the character's tuning is the new one now.
+ void refreshReads(project, item);
const where = c.layer === "cast" ? "the cast: every project" : "this video only";
- const s = await fetch(`/api/report/voices?project=${encodeURIComponent(project)}&stale=${encodeURIComponent(c.id)}`, { cache: "no-store" }).then((x) => (x.ok ? x.json() : null)).catch(() => null) as { count?: number; items?: string[] } | null;
+ const s = (await fetch(`/api/report/voices?project=${encodeURIComponent(project)}&stale=${encodeURIComponent(c.id)}`, { cache: "no-store" }).then((x) => (x.ok ? x.json() : null)).catch(() => null)) as { count?: number; items?: string[] } | null;
const items = s?.items ?? [];
const stale = !s ? "" : items.length ? ` · ${items.includes(item) ? "this read was" : `${items.length} read${items.length === 1 ? " was" : "s were"}`} made with other settings${items.includes(item) && items.length > 1 ? ` (and ${items.length - 1} more: ${items.filter((x) => x !== item).join(", ")})` : items.includes(item) ? "" : `: ${items.join(", ")}`}` : " · every read of theirs is made with these";
return `kept for ${c.name} (${where}): ${words(t)}${(j?.notes ?? []).map((n) => ` · ${n}`).join("")}${stale}`;
};
}
-/** The seam for one piece of one item: its character's keeper, or undefined (no character: no button). */
-export function useKeepForCharacter(project: string | null | undefined, id: string, role = "post"): { character: ReadCharacter | null; keepForCharacter: KeepForCharacter | undefined } {
- const character = useReadCharacter(project, id, role);
+/**
+ * One piece of one item (`role`): its character and keeper (none: no button), and its Tune's baseline from how it was
+ * last made (`made`: its recorded tuning and `tuningAsked`) -- null until the item's pieces are known.
+ */
+export function useKeepForCharacter(project: string | null | undefined, id: string, role = "post", made: { tuning?: Tuning | null; tuningAsked?: unknown } | null = null): { character: ReadCharacter | null; keepForCharacter: KeepForCharacter | undefined; baseline: TuneBaseline | null } {
+ const pieces = useReads(project, id);
+ const piece = pieces?.[role] ?? null;
+ const character = piece?.character ?? null;
const keepForCharacter = useMemo(() => (project && character ? keepTuningFor(project, id, character) : undefined), [project, id, character]);
- return { character, keepForCharacter };
+ const madeOwn = madeOwnOf(made?.tuning ?? null, made?.tuningAsked);
+ const tuningKey = JSON.stringify(piece?.tuning ?? null);
+ const baseline = useMemo<TuneBaseline | null>(
+ () => (pieces ? { character: character ? { name: character.name, tuning: piece?.tuning ?? null } : null, madeOwn } : null),
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ [pieces, character?.id, character?.name, tuningKey, madeOwn],
+ );
+ return { character, keepForCharacter, baseline };
}
diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md
@@ -1874,10 +1874,19 @@ editor's `tts.orpheus.takes`, and the preset and `--json` say that number, never
thread read's parts each record theirs, and its `read.tuned` keeps only the read's own, so a later read asks the
character's as it is then. `cast reread` of a take whose tuning was the character's passes its reading, not its old
tuning. A character with no tuning: every ask, key and record as before.
+- **The Tune on the bench starts from what a plain press reads now:** the piece's character's tuning (none: the
+ defaults), unless its last read was the line's own (`tuningAsked` true) -- then those numbers, and they stay its
+ own. A press asks as the line's own only what differs from the character's (`umtool/lib/report/tuneAsk.mjs`), so a
+ plain Read again of a character's line asks the character's tuning as it is then; Defaults on a Lively line asks the
+ three defaults as its own. The panel says where it starts ("The Teller: Lively", "defaults", "this line's own"). A
+ thread read's Tune starts from his own piece.
- **Keep for the character, on the bench:** the Tune's **Keep this tuning for <character>** (a post's script, a thread
- read, a screen line: the character whose preset reads that piece, `GET /api/report/post-narration?reads=<role>`)
- runs the same `cast set` / `cast project <p> set`, and says what was kept and what that leaves made with other
- settings (`umtool cast stale`).
+ read, a screen line: the character whose preset reads that piece, one `GET /api/report/post-narration?reads=all`
+ per item, the playing read's voice overrides kept -- a piece given another voice on purpose has no button) runs the
+ same `cast set` / `cast project <p> set` (its takes only when typed), and says what was kept and what that leaves
+ made with other settings (`umtool cast stale`). Its panels read the item's pieces again after it.
+- A screen line whose speaker is written as a display name, not a handle, is read with its character's tuning but is
+ not listed stale (the stale list knows a screen line's character by its handle).
- **Stale, never re-made:** a picked Orpheus read of the character is made with OTHER SETTINGS when its character's
preset answers for it now in the voice it was made in, its tuning was not asked by its own line (the take's
`tuningAsked` is not `true`; a take that says nothing but records a tuning off the defaults was asked so), and the
diff --git a/umtool/e2e/character-tuning.spec.ts b/umtool/e2e/character-tuning.spec.ts
@@ -273,3 +273,62 @@ test("the post bench: Read again asks the character's Lively (\"preset\"); the T
await page.reload();
expect(await drawnCard(page)).toEqual(before);
});
+
+// REVIEW 2, THE MUST: a plain Read again under a tuned character asks the CHARACTER's tuning as it is now -- never the
+// last read's numbers as the line's own. Twice under Lively ("preset" both), the character made Steady: the playing
+// read is stale, and a third plain Read again asks Steady, "preset".
+const setTeller = (page: import("@playwright/test").Page, tuning: Record<string, number>) =>
+ page.evaluate(async ([project, t]) => {
+ const r = await fetch("/api/report/voices", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ project, op: "character-set", scope: "project", id: "teller", tuning: t }) });
+ return r.status;
+ }, [P, tuning] as const);
+const staleOfTeller = (page: import("@playwright/test").Page) =>
+ page.evaluate(async (project) => ((await (await fetch(`/api/report/voices?project=${encodeURIComponent(project)}&stale=teller`)).json()) as { items?: string[] }).items ?? [], P);
+
+test("review 2: a plain Read again asks the character's tuning as it is now (\"preset\"), never the last read's as its own", async ({ page }) => {
+ await page.setViewportSize({ width: 1440, height: 1400 });
+ await page.goto(urls.voicesHref(P));
+ expect(await setTeller(page, { temperature: 0.75, top_p: 0.92, repeat_penalty: 1.25 })).toBe(200);
+ await page.goto(urls.postBenchHref(P, "p-1"));
+ const panel = page.locator('[data-post-narration="p-1"]');
+ await expect(panel.locator("[data-post-take]")).toHaveCount(1, { timeout: 30_000 });
+ const before = await drawnCard(page);
+ const again = panel.locator('[aria-label="Read again"]');
+ // Twice under Lively: the second press starts from the first's (Lively, the character's) -- still the character's.
+ await again.click();
+ await expect(panel.locator("[data-post-take]")).toHaveCount(2, { timeout: 30_000 });
+ await expect(again).toBeEnabled({ timeout: 30_000 });
+ await again.click();
+ await expect(panel.locator("[data-post-take]")).toHaveCount(3, { timeout: 30_000 });
+ expect(takesOf("p-1")[1].tuningAsked).toBe("preset");
+ expect(takesOf("p-1")[2].tuningAsked).toBe("preset");
+ // The Tune says where its numbers start: the character's.
+ await panel.locator("[data-read-tune] summary").click();
+ await expect(panel.locator("[data-read-tune-baseline]")).toContainText("The Teller: Lively");
+ // Play the latest, then the character becomes Steady: that read is stale.
+ await panel.locator('[aria-label="Pick take 3"]').click();
+ await expect(panel.locator('[data-post-take="3"]')).toHaveAttribute("data-post-take-picked", "1");
+ expect(await setTeller(page, { temperature: 0.4, top_p: 0.8 })).toBe(200);
+ expect(await staleOfTeller(page)).toContain("p-1");
+ // A third plain press asks Steady, the character's now, and says so.
+ await page.reload();
+ await expect(panel.locator("[data-post-take]")).toHaveCount(3, { timeout: 30_000 });
+ const asked0 = benchAsks().length;
+ await panel.locator('[aria-label="Read again"]').click();
+ await expect(panel.locator("[data-post-take]")).toHaveCount(4, { timeout: 30_000 });
+ expect(benchAsks().length).toBe(asked0 + 1);
+ const sent = benchAsks().at(-1)!.tuning ?? {};
+ expect([sent.temperature, sent.top_p, sent.repeat_penalty ?? 1.2]).toEqual([0.4, 0.8, 1.2]);
+ expect(takesOf("p-1")[3].tuningAsked).toBe("preset");
+ // Defaults, this line only (review 2 #3): the three defaults asked as the line's own.
+ await panel.locator("[data-read-tune] summary").click();
+ await panel.locator('[aria-label="Tuning back to the defaults"]').click();
+ await panel.locator('[aria-label="Read again with this tuning"]').click();
+ await expect(panel.locator("[data-post-take]")).toHaveCount(5, { timeout: 30_000 });
+ const dflt = benchAsks().at(-1)!.tuning ?? {};
+ expect([dflt.temperature, dflt.top_p]).toEqual([0.55, 0.85]);
+ expect(takesOf("p-1")[4].tuningAsked).toBe(true);
+ // The card draws what it drew (take 3 plays: words as drafted).
+ await page.reload();
+ expect(await drawnCard(page)).toEqual(before);
+});
diff --git a/umtool/lib/report/characterTuningWiring.test.mjs b/umtool/lib/report/characterTuningWiring.test.mjs
@@ -147,7 +147,8 @@ test("a thread read and its screen lines: each piece asked its own character's t
const own = await threadTake(p, (await read(p)).timeline[0], { red: NO_RED, ask: stubAsk(asked), lanes: null, ...layersOf(castDoc(LIVELY, STEADY)), tuned: { "screen:s1:0": { tuning: { temperature: 0.9 } } } });
const line = own.take.parts.find((x) => x.role === "screen:s1:0");
assert.deepEqual([line.tuning, line.tuningAsked], [{ ...STEADY, temperature: 0.9 }, true]);
- assert.deepEqual(own.take.read.tuned["screen:s1:0"].tuning, { ...STEADY, temperature: 0.9 });
+ // read.tuned keeps the read's OWN values as asked (review 2 #9): a later read lays them over the character's then.
+ assert.deepEqual(own.take.read.tuned["screen:s1:0"].tuning, { temperature: 0.9 });
assert.equal(own.take.parts.find((x) => x.role === "post").tuningAsked, "preset");
});
@@ -185,3 +186,30 @@ test("rereadPlan: a take whose tuning was its character's is re-read with the ch
["--take", "--temperature", "0.9", "--top-p", "0.92", "--repeat-penalty", "1.25", "--chunk-takes", "3"],
]);
});
+
+test("review 2 #2: a thread piece's ownership is decided from the values AS ASKED -- an explicit default over a character's is the read's own", async () => {
+ const p = await project("thread-explicit", castDoc(LIVELY, STEADY));
+ const asked = [];
+ const r = await threadTake(p, (await read(p)).timeline[0], { red: NO_RED, ask: stubAsk(asked), lanes: null, ...layersOf(castDoc(LIVELY, STEADY)), tuned: { post: { tuning: { temperature: 0.55 } }, "screen:s1:0": { tuning: { temperature: 0.55, top_p: 0.85, repeat_penalty: 1.2 } } } });
+ const post = r.take.parts.find((x) => x.role === "post");
+ // temperature 0.55 over Lively: read with Lively's top_p and repeat penalty and the default temperature -- the read's own.
+ assert.deepEqual([post.tuning, post.tuningAsked], [{ top_p: 0.92, repeat_penalty: 1.25 }, true]);
+ assert.deepEqual(r.take.read.tuned.post.tuning, { temperature: 0.55 });
+ // All three defaults over Steady: read with the defaults (nothing left to key), still the read's own.
+ const line = r.take.parts.find((x) => x.role === "screen:s1:0");
+ assert.deepEqual([line.tuning, line.tuningAsked], [undefined, true]);
+ assert.deepEqual(r.take.read.tuned["screen:s1:0"].tuning, { temperature: 0.55, top_p: 0.85, repeat_penalty: 1.2 });
+ // Neither is stale when the characters change: they are the read's own.
+ const { tuningStale } = await import("umtool-report-to-video/cast");
+ const { resolverFor } = await import("./castProject.mjs");
+ const roles = tuningStale(await read(p), resolverFor({ cast: castDoc(STEADY, LIVELY) }), { settingTakes: 3 }).map((x) => x.role);
+ assert.ok(!roles.includes("post") && !roles.includes("screen:s1:0"), JSON.stringify(roles));
+});
+
+test("review 2 #9: a thread read's own takes over a character's tuning are kept in read.tuned (the sampler still the character's)", async () => {
+ const p = await project("thread-takes", castDoc(LIVELY));
+ const r = await threadTake(p, (await read(p)).timeline[0], { red: NO_RED, ask: stubAsk([]), lanes: null, ...layersOf(castDoc(LIVELY)), tuned: { post: { tuning: { takes: 5 } } } });
+ const post = r.take.parts.find((x) => x.role === "post");
+ assert.deepEqual([post.tuning, post.tuningAsked], [{ ...LIVELY, takes: 5 }, "preset"]);
+ assert.deepEqual(r.take.read.tuned.post.tuning, { takes: 5 });
+});
diff --git a/umtool/lib/report/postNarrationCli.mjs b/umtool/lib/report/postNarrationCli.mjs
@@ -406,13 +406,11 @@ export async function makeTake(project, e, { script = null, note = null, engine
// ITS CHARACTER's TUNING (lane character-tuning): the synthetic preset's that answered for the voice, asked when the
// line asks none of its own (the line's beats it; an engine with no sampler is asked none of the character's). A
// character with no tuning: the ask, and the take, as they always were.
- // Field by field: the line's own values over the character's (a line that asks only its takes keeps the
- // character's sampler); `tuningAsked` true when the line names a sampler value of its own.
- const own = tuning && Object.keys(tuning).length ? tuning : null;
- const preset = eng === "orpheus" && said0.tuning && Object.keys(said0.tuning).length ? said0.tuning : null;
- const asked = preset ? { ...preset, ...(own ?? {}) } : own;
- const ownSampler = !!own && Object.keys(own).some((k) => k !== "takes");
- const tuningAsked = eng === "orpheus" && asked ? (ownSampler || !preset ? true : "preset") : null;
+ // Field by field: the line's own values over the character's (post-say.mjs tuningAskOf, the thread read's rule too).
+ const { tuningAskOf } = await import("umtool-report-to-video/post-say");
+ const ta = tuningAskOf({ own: tuning, preset: said0.tuning ?? null, engine: eng });
+ const asked = ta.tuning;
+ const tuningAsked = ta.asked;
const ttsBody = (text) => ({
text, engine: eng, voice: vox, out, ...(spd !== null && eng !== "orpheus" ? { speed: spd } : {}),
...(asked ? { tuning: asked } : {}), ...(reading !== null ? { reading } : {}),
diff --git a/umtool/lib/report/postThreadRead.mjs b/umtool/lib/report/postThreadRead.mjs
@@ -62,7 +62,7 @@ import { chosenLineTakes, chronoPieces, lineTakesOf } from "umtool-report-to-vid
import { cardText, parentsOf, saysShownDraft, shownDraftOf } from "umtool-report-to-video/post-item";
import { planContext } from "umtool-report-to-video/post-conversation";
import { spokenRead, termsFor } from "umtool-report-to-video/post-redact";
-import { readSpeedOf, resolvePieceVoice } from "umtool-report-to-video/post-say";
+import { readSpeedOf, resolvePieceVoice, tuningAskOf } from "umtool-report-to-video/post-say";
import { SCREEN_LINE_GAP, parseScreenRole, screenWho, screensOf, shapeSpans } from "umtool-report-to-video/post-screens";
import { readManifest } from "../projects/report.mjs";
import { ORPHEUS_DEFAULT_TAKES, TTS_TUNING_FIELDS, normalizeTtsTuning } from "yt-dlp-transcript-common/lib/ttsTuning.mjs";
@@ -75,8 +75,6 @@ const r3 = (v) => Math.round(v * 1000) / 1000;
const str = (v) => (typeof v === "string" ? v : "");
const norm = (t) => str(t).replace(/\s+/g, " ").trim();
const isTuneObj = (v) => !!v && typeof v === "object" && !Array.isArray(v);
-/** Does a tuning name a sampler value (anything but `takes`)? */
-const samplerNamed = (t) => Object.keys(t ?? {}).some((k) => k !== "takes");
/** A piece's character's Orpheus tuning (resolvePieceVoice's `tuning`), held for the tuning pass below: `{}` for none. */
const presetTuningOf = (v) => (v?.engine === "orpheus" && isTuneObj(v.tuning) && Object.keys(v.tuning).length ? { presetTuning: v.tuning } : {});
@@ -347,14 +345,16 @@ export function threadReadPlan(manifest, e, { red = null, map = {}, cast = {}, i
if (pc.take) continue;
const kept = isTuneObj(inherit?.[pc.role]) && norm(inherit[pc.role].said) === norm(pc.text) ? inherit[pc.role] : null;
const ask = tuned?.[pc.role] ?? tuned?.["*"] ?? kept;
- const own = isTuneObj(ask) ? tuningOf(ask.tuning) : null;
- // Field by field: the read's own values over the character's (a read that asks only its takes keeps the
- // character's sampler); asked by the read when it names a sampler value of its own.
- const t = preset && pc.engine === "orpheus" ? tuningOf({ ...preset, ...(isTuneObj(ask?.tuning) ? ask.tuning : {}) }) : own;
- if (t) {
- pc.tuning = t;
- pc.tuningAsked = own && samplerNamed(own) ? true : preset && pc.engine === "orpheus" ? "preset" : true;
- }
+ // Field by field: the read's own values AS ASKED over the character's (post-say.mjs tuningAskOf: makeTake's rule
+ // -- an explicit default is the read's own); the tuning asked and keyed is then normalised (S3's key rule).
+ const ta = tuningAskOf({ own: isTuneObj(ask) && isTuneObj(ask.tuning) ? ask.tuning : null, preset, engine: pc.engine ?? "orpheus" });
+ const t = ta.tuning ? tuningOf(ta.tuning) : null;
+ if (t) pc.tuning = t;
+ // (An explicit default over a character's tuning is the read's own even when nothing is left to key: said so.)
+ if (ta.asked && (t || (ta.asked === true && preset))) pc.tuningAsked = ta.asked;
+ // The read's own values as asked (its takes too) over a character's: what `read.tuned` keeps, so a later read asks
+ // them again. With no character tuning, S3's record as it was (the tuning asked).
+ if (ta.own && preset) pc.ownTuning = ta.own;
if (!isTuneObj(ask)) continue;
const reading = ask.reading === "next" ? nextPartReading(e, pc.role, pc.text) : Number.isInteger(ask.reading) ? ask.reading : 0;
if (reading > 0) pc.reading = reading;
@@ -469,7 +469,7 @@ export function readParts(plan) {
const eng = pc.engine ?? plan.engine;
const tune = { ...(pc.reading ? { reading: pc.reading } : {}), ...(pc.tuning ? { tuning: pc.tuning } : {}) };
// Where its tuning came from (not in its key: the same tuning is the same audio, whoever asked it).
- const from = pc.tuning && pc.tuningAsked ? { tuningAsked: pc.tuningAsked } : {};
+ const from = pc.tuningAsked ? { tuningAsked: pc.tuningAsked } : {};
return scriptParts(pc.text).map((q) => ({ piece, para: q.para, role: pc.role, voice: pc.voice, engine: eng, ...(pc.speed !== undefined ? { speed: pc.speed } : {}), ...tune, ...from, text: q.text, key: partKey(eng, pc.voice, q.text, pc.speed ?? null, tune), ...line }));
});
}
@@ -492,7 +492,7 @@ export function joinTimes(parts, seconds, { fileOf = (p) => (p.take ? p.file : `
t += gap;
const s = Number(seconds[i]);
// A part from a take (--post-take) says which (`take`: its id); a synthesized one its parts-cache file and voice.
- const row = { n: i + 1, para: p.piece * 100 + p.para, text: p.text, ...(typeof p.line === "string" ? { line: p.line, speaker: str(p.speaker) } : {}), voice: p.voice, ...(p.engine ? { engine: p.engine } : {}), ...(typeof p.speed === "number" ? { speed: p.speed } : {}), ...(p.reading ? { reading: p.reading } : {}), ...(p.tuning ? { tuning: p.tuning } : {}), ...(p.tuning && p.tuningAsked ? { tuningAsked: p.tuningAsked } : {}), role: p.role, piece: p.piece, file: fileOf(p), ...(p.take ? { take: p.take } : {}), start: r3(t), seconds: r3(s), gapBefore: gap };
+ const row = { n: i + 1, para: p.piece * 100 + p.para, text: p.text, ...(typeof p.line === "string" ? { line: p.line, speaker: str(p.speaker) } : {}), voice: p.voice, ...(p.engine ? { engine: p.engine } : {}), ...(typeof p.speed === "number" ? { speed: p.speed } : {}), ...(p.reading ? { reading: p.reading } : {}), ...(p.tuning ? { tuning: p.tuning } : {}), ...(p.tuningAsked ? { tuningAsked: p.tuningAsked } : {}), role: p.role, piece: p.piece, file: fileOf(p), ...(p.take ? { take: p.take } : {}), start: r3(t), seconds: r3(s), gapBefore: gap };
t += s;
return row;
});
@@ -503,9 +503,10 @@ export function joinTimes(parts, seconds, { fileOf = (p) => (p.take ? p.file : `
export function readRecordOf({ parents = "0", skip = [], quoted = true, linked = true, readSeen = false, overrides = {}, voice = null, speed = null, postTake = null, screens = true, lineTakes = {}, pieces = [] }) {
// Each piece's reading and tuning, as made (lane line-rerun), with the words it said: a later read of the same words
// keeps it (posts screen read), and `--tuned` asks it again exactly (castProject.mjs threadArgvOf).
- // A tuning that came from the piece's character (`tuningAsked` "preset") is NOT the read's: it is left out, so a later
- // read asks the character's as it is then (lane character-tuning).
- const ownTuning = (pc) => (pc.tuning && pc.tuningAsked !== "preset" ? pc.tuning : null);
+ // Only the READ's OWN values (as asked, its takes too) are kept: a tuning that came from the piece's character is not
+ // the read's, so a later read asks the character's as it is then (lane character-tuning; review 2 #9). A piece with
+ // no character tuning: its own as S3 kept it (the tuning asked).
+ const ownTuning = (pc) => (pc.ownTuning ? pc.ownTuning : pc.tuning && pc.tuningAsked !== "preset" ? pc.tuning : null);
const tuned = Object.fromEntries((pieces ?? []).filter((pc) => !pc.take && (pc.reading || ownTuning(pc))).map((pc) => [pc.role, { ...(pc.reading ? { reading: pc.reading } : {}), ...(ownTuning(pc) ? { tuning: ownTuning(pc) } : {}), said: pc.text }]));
return {
kind: "thread", parents: parentsSelector(parents),
diff --git a/umtool/lib/report/tuneAsk.mjs b/umtool/lib/report/tuneAsk.mjs
@@ -0,0 +1,92 @@
+// THE TUNE's NUMBERS ON THE BENCH (lane character-tuning, review 2; components/projects/read/ReadAgain.tsx): where a
+// line's Tune starts, what a press asks as the line's OWN, and what a "Keep for <character>" keeps -- pure, so the
+// rule is one and tested.
+//
+// the BASELINE what a plain press reads the piece with now: its character's tuning (none: the defaults), unless
+// its last read was the line's own (`tuningAsked` true; made before that was recorded: a sampler value
+// off the defaults) -- then those numbers, and they stay the line's own
+// a PRESS with no character, S3's rule (what differs from the defaults); with one, what differs from the
+// character's tuning (all of the sampler when the last read was the line's own) -- nothing changed on
+// a character's line asks none of the sampler, so the character's is asked as it is then; the takes
+// when given (S3: a recorded takes is passed back)
+// a KEEP the sampler as it stands (top k, min p only when not their defaults) and the takes only when typed
+//
+// Plain ESM, pure.
+import { ORPHEUS_TUNING_DEFAULTS, TTS_TUNING_FIELDS } from "yt-dlp-transcript-common/lib/ttsTuning.mjs";
+
+export const TUNE_SAMPLER = Object.freeze(["temperature", "top_p", "top_k", "min_p", "repeat_penalty"]);
+const DEFAULTS = ORPHEUS_TUNING_DEFAULTS;
+const num = (v) => (v !== "" && v !== null && v !== undefined && Number.isFinite(Number(v)) ? Number(v) : null);
+
+/** Was a read the line's own? `tuningAsked` true -- or, made before it was recorded, a sampler value off the defaults. */
+export function madeOwnOf(tuning, tuningAsked) {
+ if (tuningAsked === true) return true;
+ if (tuningAsked !== undefined && tuningAsked !== null) return false;
+ return TUNE_SAMPLER.some((k) => typeof tuning?.[k] === "number" && tuning[k] !== DEFAULTS[k]);
+}
+
+/** S3's ask (ReadAgain.tsx tuningAsked): the sampler values off the defaults, and the takes whenever given. */
+export function defaultsAskOf(draft) {
+ const out = {};
+ for (const k of TTS_TUNING_FIELDS) {
+ const v = num(draft?.[k]);
+ if (v !== null && (k === "takes" || v !== DEFAULTS[k])) out[k] = v;
+ }
+ return Object.keys(out).length ? out : null;
+}
+
+/**
+ * The Tune's starting numbers, as its fields hold them (strings): the baseline's sampler (`baseline` null: S3's -- the
+ * last read's), and the last read's takes.
+ * @param {{ madeWith?: Record<string, number> | null, baseline?: { character: { tuning: Record<string, number> | null } | null, madeOwn: boolean } | null }} o
+ */
+export function tuneStartOf({ madeWith = null, baseline = null } = {}) {
+ const b = !baseline ? madeWith : baseline.madeOwn ? madeWith : baseline.character?.tuning ?? null;
+ return Object.fromEntries(TTS_TUNING_FIELDS.map((k) => {
+ const v = k === "takes" ? madeWith?.takes : b?.[k];
+ return [k, v !== undefined && v !== null ? String(v) : k in DEFAULTS ? String(DEFAULTS[k]) : ""];
+ }));
+}
+
+/**
+ * What a press asks as the line's own (null: nothing of its own -- the character's, or the defaults, as they are now).
+ * @param {Record<string, string>} draft
+ * @param {{ character: { tuning: Record<string, number> | null } | null, madeOwn: boolean } | null} [baseline]
+ */
+export function tuneAskOf(draft, baseline = null) {
+ if (!baseline?.character) return defaultsAskOf(draft);
+ const out = {};
+ for (const k of TUNE_SAMPLER) {
+ const v = num(draft?.[k]);
+ const was = baseline.character.tuning?.[k] ?? DEFAULTS[k];
+ if (v !== null && (baseline.madeOwn || v !== was)) out[k] = v;
+ }
+ const takes = num(draft?.takes);
+ if (takes !== null) out.takes = takes;
+ return Object.keys(out).length ? out : null;
+}
+
+/**
+ * What a Keep keeps: the sampler as it stands (top k and min p only when not their defaults), the takes only when typed.
+ * @param {Record<string, string>} draft
+ * @param {{ takesTyped?: boolean }} [o]
+ */
+export function keepAskOf(draft, { takesTyped = false } = {}) {
+ const out = {};
+ for (const k of TUNE_SAMPLER) {
+ const v = num(draft?.[k]);
+ if (v !== null && ((k !== "top_k" && k !== "min_p") || v !== DEFAULTS[k])) out[k] = v;
+ }
+ const takes = num(draft?.takes);
+ if (takesTyped && takes !== null) out.takes = takes;
+ return out;
+}
+
+/**
+ * A thread read's Tune starts from HIS piece (the `post` part) -- never the first tuned part of another piece.
+ * @param {any} parts
+ */
+export function threadTuneMadeOf(parts) {
+ const p = (Array.isArray(parts) ? parts : []).find((x) => x?.role === "post" && typeof x?.take !== "string") ?? null;
+ return p ? { tuning: p.tuning ?? null, tuningAsked: p.tuningAsked } : null;
+}
diff --git a/umtool/lib/report/tuneAsk.test.mjs b/umtool/lib/report/tuneAsk.test.mjs
@@ -0,0 +1,70 @@
+// THE TUNE's NUMBERS ON THE BENCH (lane character-tuning, review 2; tuneAsk.mjs): the baseline a press starts from,
+// what it asks as the line's own, what a Keep keeps, and the thread Tune's piece. Each test names the review finding
+// it holds, and what the rule before the fix did (S3's: the last read's numbers, every one off the defaults, sent as the
+// line's own).
+import assert from "node:assert/strict";
+import { test } from "node:test";
+import { defaultsAskOf, keepAskOf, madeOwnOf, threadTuneMadeOf, tuneAskOf, tuneStartOf } from "./tuneAsk.mjs";
+
+const LIVELY = { temperature: 0.75, top_p: 0.92, repeat_penalty: 1.25 };
+const STEADY = { temperature: 0.4, top_p: 0.8 };
+const MADE_LIVELY = { temperature: 0.75, top_p: 0.92, top_k: 50, min_p: 0, repeat_penalty: 1.25, takes: 3 };
+const asCharacter = (tuning, madeOwn = false) => ({ character: { name: "The Teller", tuning }, madeOwn });
+
+test("review 2 #1: a plain press after a read under the character's Lively asks NONE of the sampler as the line's own", () => {
+ // The last read was the character's ("preset"): the Tune starts from the character's tuning NOW.
+ const made = { tuning: MADE_LIVELY, tuningAsked: "preset" };
+ const b = asCharacter(LIVELY, madeOwnOf(made.tuning, made.tuningAsked));
+ const draft = tuneStartOf({ madeWith: made.tuning, baseline: b });
+ assert.deepEqual(tuneAskOf(draft, b), { takes: 3 }, "only the recorded takes (S3's rule): the sampler is the character's");
+ // The rule before the fix: the last read's numbers, as the line's own.
+ assert.deepEqual(defaultsAskOf(tuneStartOf({ madeWith: made.tuning })), { temperature: 0.75, top_p: 0.92, repeat_penalty: 1.25, takes: 3 });
+ // The character is Steady now: the Tune starts there, and a plain press still asks none of the sampler.
+ const now = asCharacter(STEADY, false);
+ const d2 = tuneStartOf({ madeWith: made.tuning, baseline: now });
+ assert.deepEqual([d2.temperature, d2.top_p, d2.repeat_penalty], ["0.4", "0.8", "1.2"]);
+ assert.deepEqual(tuneAskOf(d2, now), { takes: 3 });
+ // The line's own last read stays its own: its numbers are the baseline, all of the sampler asked.
+ const own = asCharacter(STEADY, madeOwnOf({ ...MADE_LIVELY, temperature: 0.9 }, true));
+ const d3 = tuneStartOf({ madeWith: { ...MADE_LIVELY, temperature: 0.9 }, baseline: own });
+ assert.deepEqual(tuneAskOf(d3, own), { temperature: 0.9, top_p: 0.92, top_k: 50, min_p: 0, repeat_penalty: 1.25, takes: 3 });
+ // Made before `tuningAsked` was recorded: a sampler value off the defaults was the line's own; the defaults were not.
+ assert.equal(madeOwnOf({ temperature: 0.7 }, undefined), true);
+ assert.equal(madeOwnOf({ temperature: 0.55, takes: 4 }, undefined), false);
+ assert.equal(madeOwnOf({ temperature: 0.7 }, "preset"), false);
+});
+
+test("review 2 #3: Defaults on a Lively character's line asks the three defaults as the line's own", () => {
+ const b = asCharacter(LIVELY, false);
+ const defaults = { temperature: "0.55", top_p: "0.85", top_k: "50", min_p: "0", repeat_penalty: "1.2", takes: "" };
+ assert.deepEqual(tuneAskOf(defaults, b), { temperature: 0.55, top_p: 0.85, repeat_penalty: 1.2 });
+ // The rule before the fix asked nothing (and the character's Lively was read).
+ assert.equal(defaultsAskOf(defaults), null);
+ // One number changed: only it is the line's own (the rest laid under it are the character's).
+ assert.deepEqual(tuneAskOf({ ...tuneStartOf({ baseline: b }), temperature: "0.9" }, b), { temperature: 0.9 });
+ // No character: S3's rule, exactly.
+ const none = { character: null, madeOwn: false };
+ assert.deepEqual(tuneAskOf({ ...defaults, temperature: "0.7" }, none), defaultsAskOf({ ...defaults, temperature: "0.7" }));
+ assert.equal(tuneAskOf(defaults, none), null);
+});
+
+test("review 2 #4: a thread read's Tune starts from his piece, never another piece's first tuned part", () => {
+ const parts = [
+ { role: "parent:0", voice: "leo", tuning: STEADY, tuningAsked: "preset" },
+ { role: "post", voice: "tara", tuning: LIVELY, tuningAsked: "preset" },
+ { role: "post", voice: "tara", tuning: LIVELY, tuningAsked: "preset" },
+ ];
+ assert.deepEqual(threadTuneMadeOf(parts), { tuning: LIVELY, tuningAsked: "preset" });
+ // The rule before the fix: the first part with a tuning (the parent's Steady).
+ assert.deepEqual(parts.find((p) => p.tuning)?.tuning, STEADY);
+ // His line from a take (--post-take) is no synthesized piece: nothing to start from.
+ assert.equal(threadTuneMadeOf([{ role: "post", take: "take-1.recorded", voice: "operator" }]), null);
+});
+
+test("review 2 #5: a Keep pins the character's takes only when the takes field was typed", () => {
+ const draft = { temperature: "0.9", top_p: "0.92", top_k: "50", min_p: "0", repeat_penalty: "1.25", takes: "4" };
+ assert.deepEqual(keepAskOf(draft), { temperature: 0.9, top_p: 0.92, repeat_penalty: 1.25 }, "the recorded takes (the editor's setting) are not pinned");
+ assert.deepEqual(keepAskOf(draft, { takesTyped: true }), { temperature: 0.9, top_p: 0.92, repeat_penalty: 1.25, takes: 4 });
+ // Top k and min p go only when not their defaults (a character does not keep them: the route says so).
+ assert.deepEqual(keepAskOf({ ...draft, top_k: "40" }).top_k, 40);
+});
diff --git a/umtool/report-to-video/cast.mjs b/umtool/report-to-video/cast.mjs
@@ -836,10 +836,12 @@ export function madeOf(e, take, role = "post", seen = new Set()) {
if (src && !isThreadTake(src)) return madeOf(e, src, "post", new Set([...seen, take]));
}
const part = parts.find((p) => p?.role === role && typeof p?.take !== "string" && isObj(p?.tuning));
+ // Where it came from: the piece's own part says so (one asked its explicit defaults has a provenance and no tuning).
+ const said = parts.find((p) => p?.role === role && typeof p?.take !== "string" && p?.tuningAsked !== undefined);
return {
tuning: part ? part.tuning : isObj(take?.tuning) ? take.tuning : null,
// A thread read's part says where its own tuning came from; else the take does.
- asked: part?.tuningAsked ?? take?.tuningAsked,
+ asked: said?.tuningAsked ?? part?.tuningAsked ?? take?.tuningAsked,
reading: Number.isInteger(take?.reading) ? take.reading : 0,
};
}
diff --git a/umtool/report-to-video/post-say.mjs b/umtool/report-to-video/post-say.mjs
@@ -330,6 +330,29 @@ export function resolvePieceVoice(piece, o) {
* the voice) -- `{ tuning, asked: true | "preset" }`, the take's `tuningAsked` -- or null: none to ask (no tuning
* either way, or an engine that has no sampler: Kokoro, eSpeak NG). An empty tuning is none.
*/
+/**
+ * THE TUNING ONE READ IS ASKED WITH, AND WHOSE IT IS -- the one rule a post's take (makeTake, the bench's take op) and
+ * every piece of a thread read follow (lane character-tuning, review 2): `own` the line's own values AS ASKED (the
+ * flags, the bench's Tune, a `--for`/`--tuned` piece; never normalised first: an explicit default is the line's own),
+ * `preset` its character's. Returns `{ tuning, asked, own }`: `tuning` the line's values over the character's, field
+ * by field (null: none); `asked` true when the line names a sampler value of its own (or asks any value with no
+ * character tuning to lay it over), "preset" when the sampler is the character's (a line asking only its takes keeps
+ * the character's sampler), null when nothing is asked; `own` the line's values as asked (null: none). An engine with no
+ * sampler is asked the line's own as it is (the editor says it ignores them) and none of the character's.
+ * @param {{ own?: Record<string, number> | null, preset?: Record<string, number> | null, engine?: string | null }} [o]
+ * @returns {{ tuning: Record<string, number> | null, asked: true | "preset" | null, own: Record<string, number> | null }}
+ */
+export function tuningAskOf({ own = null, preset = null, engine = null } = {}) {
+ const mine = isObj(own) ? Object.fromEntries(Object.entries(own).filter(([, v]) => typeof v === "number" && Number.isFinite(v))) : {};
+ const hasOwn = Object.keys(mine).length > 0;
+ if (engine !== "orpheus") return { tuning: hasOwn ? mine : null, asked: null, own: hasOwn ? mine : null };
+ const pre = isObj(preset) && Object.keys(preset).length ? preset : null;
+ const tuning = pre ? { ...pre, ...mine } : hasOwn ? mine : null;
+ const ownSampler = Object.keys(mine).some((k) => k !== "takes");
+ const asked = !tuning ? null : ownSampler || !pre ? true : "preset";
+ return { tuning, asked, own: hasOwn ? mine : null };
+}
+
export function readTuningOf({ flag = null, preset = null, engine = null } = {}) {
if (engine !== "orpheus") return null;
if (isObj(flag) && Object.keys(flag).length) return { tuning: flag, asked: true };