commit c72d2086c89134565de2e2631b9b35ecaf3081a5
parent fb84d197731d04c97e0e7c57fbe9f2d0d8f5dcad
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Tue, 17 Nov 2026 10:02:40 -0500
umtool bench: Read again, Read edited text, Tune and Pick where a line is read
- components/projects/read/ReadAgain.tsx: the three buttons, Tune (the six numbers, this line only, from how
it was last made), play when ready (per browser), a waiting-for-the-render sentence; keepForCharacter is S2's
seam (absent: no button), with the character passed where it is known.
- Post script: the next reading unpicked, the take list says each take's words, reading and tuning, a new one
marked and played; an item edited before the rule says so in one line and Save script stays pressable.
- Screen lines: a said-as field; Read again / Read edited text per line (posts screen read --for), the line's
readings with Play and Pick.
- The thread read: Read again (op thread-read). Card narration (the narration page): Read again, Read edited
text, Tune, its readings with Play and Pick.
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat:
10 files changed, 454 insertions(+), 26 deletions(-)
diff --git a/umtool/app/api/report/narration/play/route.ts b/umtool/app/api/report/narration/play/route.ts
@@ -2,6 +2,7 @@ import { jobView, runningJob, startJob } from "@/lib/jobs";
import path from "node:path";
import { UMTOOL_DIR, narrateCardSteps } from "@/lib/report/driver.mjs";
import { parseTtsTuning, ttsReadingError } from "yt-dlp-transcript-common/lib/ttsTuning.mjs";
+import { renderWaitSentence } from "@/lib/report/renderMode.mjs";
import { resolveReport } from "@/lib/report/serve.mjs";
import { narrationsOf } from "umtool-report-to-video/narration";
@@ -45,7 +46,9 @@ export async function POST(request: Request) {
argv: [process.execPath, path.join(/* turbopackIgnore: true */ UMTOOL_DIR, "bin", "umtool.mjs"), "narration", r.project.id, card, "--read", ...flags],
};
const job = startJob(`narrate ${r.project.id} ${card}`, [step], { project: r.project.id });
- return Response.json({ ok: true, job: jobView(job) }, { headers: { "cache-control": "no-store" } });
+ // While render mode gives the machine to a render, the reading waits for it -- said in place.
+ const waiting = renderWaitSentence();
+ return Response.json({ ok: true, job: jobView(job), ...(waiting ? { waiting } : {}) }, { headers: { "cache-control": "no-store" } });
}
const job = startJob(`narrate ${r.project.id} ${card}`, narrateCardSteps(r.project, card), { project: r.project.id });
return Response.json({ ok: true, job: jobView(job) }, { headers: { "cache-control": "no-store" } });
diff --git a/umtool/components/projects/NarrationReview.tsx b/umtool/components/projects/NarrationReview.tsx
@@ -1,6 +1,7 @@
"use client";
import { useEffect, useRef, useState } from "react";
+import ReadAgain, { madeWithText, playNow, useAutoPlay, type Tuning } from "./read/ReadAgain";
import { badgeVariants, type BadgeVariants } from "@/components/ui/badge";
import { buttonVariants } from "@/components/ui/button";
import { MANIFEST_CHANGED } from "./timelineApi";
@@ -38,6 +39,12 @@ export type NarrationRow = {
judgedText: string;
judgedAt: string;
kept: { seconds: number; disclosure: string; mtimeMs: number } | null;
+ /** Its key now, reading and tuning, and every reading kept for it (lane line-rerun). */
+ key?: string;
+ reading?: number;
+ tuning?: Tuning | null;
+ madeWith?: Tuning | null;
+ readings?: Array<{ key: string; text: string; reading: number; tuning: Tuning | null; seconds: number; createdAt: string | null }>;
};
export type NarrationView = {
file: string;
@@ -284,6 +291,35 @@ function NarrationCard({
const dirty = text.trim() !== r.text;
const screen = [r.screen.kicker, r.screen.heading, r.screen.sub].filter(Boolean);
+ // ---- READ AGAIN (lane line-rerun): a reading kept for the card, the card not changed; Pick makes it play ----
+ const [auto, setAuto] = useAutoPlay();
+ const [reading, setReading] = useState<{ waiting: string | null } | null>(null);
+ const readingUrl = (key: string) => `/api/report/narration/audio?${new URLSearchParams({ project, card: r.id, key })}`;
+ const readAgain = (tuning: Tuning | null, words: string | null) =>
+ run(async () => {
+ if (words !== null) await act(r.id, "edit", { text: words });
+ const before = new Set((r.readings ?? []).map((x) => x.key));
+ const res = await fetch("/api/report/narration/play", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ project, card: r.id, again: true, reading: "next", ...(tuning ? { tuning } : {}) }) });
+ const j = (await res.json()) as { error?: string; job?: { id: string }; waiting?: string };
+ if (!res.ok || !j.job) throw new Error(j.error ?? `HTTP ${res.status}`);
+ setReading({ waiting: j.waiting ?? null });
+ try {
+ for (;;) {
+ await new Promise((ok) => setTimeout(ok, 600));
+ const p = await fetch(`/api/report/build?job=${encodeURIComponent(j.job.id)}`, { cache: "no-store" });
+ if (!p.ok) continue;
+ const st = (await p.json()) as { state: string; error: string | null };
+ if (st.state === "running") continue;
+ if (st.state !== "done") throw new Error(st.error ?? "the reading was not made");
+ break;
+ }
+ } finally {
+ setReading(null);
+ }
+ const v = await refresh();
+ const fresh = v?.rows.find((x) => x.id === r.id)?.readings?.find((x) => !before.has(x.key));
+ if (fresh && auto) playNow(readingUrl(fresh.key));
+ });
return (
<article
@@ -403,6 +439,34 @@ function NarrationCard({
{r.kept && (
<audio ref={audio} controls preload="none" src={audioSrc(project, r)} data-narration-audio="" className="h-8 w-full" />
)}
+ <ReadAgain
+ what="the card"
+ busy={busy}
+ waiting={reading?.waiting ?? null}
+ canReadAgain={ready && !dirty}
+ edited={ready && dirty && !!text.trim()}
+ onReadAgain={(t) => void readAgain(t, null)}
+ onReadEdited={(t) => void readAgain(t, text)}
+ madeWith={r.madeWith ?? r.tuning ?? null}
+ autoplay={auto}
+ onAutoplay={setAuto}
+ />
+ {(r.readings?.length ?? 0) > 0 && (
+ <ul className="m-0 list-none space-y-0.5 p-0 text-[11px]" data-narration-readings={r.id}>
+ {r.readings!.map((x) => (
+ <li key={x.key} className="flex flex-wrap items-center gap-1.5" data-narration-reading={x.key.slice(0, 12)} data-playing={x.key === r.key ? "1" : undefined}>
+ <span className="font-mono">{madeWithText(x) || "reading 0"}</span>
+ <span className="tabular-nums">{Number(x.seconds).toFixed(1)} s</span>
+ {x.text !== r.text && <span className="truncate text-[var(--color-dim)]" title={x.text}>“{x.text}”</span>}
+ {/* eslint-disable-next-line jsx-a11y/media-has-caption */}
+ <audio controls preload="none" src={readingUrl(x.key)} className="h-6 w-36" />
+ <button type="button" className={buttonVariants({ variant: "outline", size: "sm" })} disabled={!ready || busy || x.key === r.key} onClick={() => void run(() => act(r.id, "pick", { key: x.key }))} aria-label={`Pick reading ${x.reading} of ${r.id}`} data-narration-reading-pick={x.key.slice(0, 12)}>
+ {x.key === r.key ? "playing" : "Pick"}
+ </button>
+ </li>
+ ))}
+ </ul>
+ )}
{r.kept && <p className="text-[11px] text-[var(--color-dim)]">{r.kept.disclosure}</p>}
<DraftAlternatives address={`narrate/${r.id}/narration`} view={drafts} act={draftAct} />
{error && (
diff --git a/umtool/components/projects/PostBench.tsx b/umtool/components/projects/PostBench.tsx
@@ -432,7 +432,21 @@ export default function PostBench({
}}
/>
<PostFollowPanel entry={entry} plan={plan} render={render} s={s} setS={setS} setEntry={(f) => setEntry((e) => f(e) as Entry)} />
- <PostThreadPanel project={project} entry={entry} plan={plan} render={render} before={before} scene={conversation} setS={setS} setEntry={(f) => setEntry((e) => f(e) as Entry)} />
+ <PostThreadPanel
+ project={project}
+ entry={entry}
+ plan={plan}
+ render={render}
+ before={before}
+ scene={conversation}
+ setS={setS}
+ setEntry={(f) => setEntry((e) => f(e) as Entry)}
+ onEntry={(e, t) => {
+ setEntry(e as Entry);
+ setSaved(e as Entry);
+ setToken(t);
+ }}
+ />
<PostScreensPanel
project={project}
entry={entry}
diff --git a/umtool/components/projects/PostNarrationPanel.tsx b/umtool/components/projects/PostNarrationPanel.tsx
@@ -16,6 +16,8 @@ import { MIC_KEY, ls, useMic } from "./useMic";
import type { PostPlan } from "./review/PostItemPlayer";
import { wordZoomTimes, zoomSpan } from "umtool-report-to-video/word-zoom";
import PostAttachmentLane from "./PostAttachmentLane";
+import ReadAgain, { madeWithText, playNow, useAutoPlay, type KeepForCharacter, type Tuning } from "./read/ReadAgain";
+import { LEGACY_EDIT_TEXT, scriptEditOf } from "umtool-report-to-video/post-item";
// ---------------------------------------------------------------------------
// A POST's NARRATION ON THE BENCH (report-to-video/post-narration.mjs;
@@ -47,7 +49,7 @@ const PITCH_WORDS: Record<string, string> = {
source: "follow my pitch",
contour: "my intonation, at the voice's register",
};
-type Take = { file: string; engine?: string; voice?: string; seconds: number; note?: string; script?: string; label?: string; source?: { kind: string; from?: string; voice?: string; engine?: string }; steps?: Step[]; parts?: Array<{ n: number; para?: number; text?: string; start: number; seconds: number; file?: string }>; words?: Array<{ w: string; start: number; end: number }> };
+type Take = { file: string; engine?: string; voice?: string; seconds: number; note?: string; script?: string; label?: string; tuning?: Tuning; reading?: number; read?: { kind?: string }; source?: { kind: string; from?: string; voice?: string; engine?: string }; steps?: Step[]; parts?: Array<{ n: number; para?: number; text?: string; start: number; seconds: number; file?: string }>; words?: Array<{ w: string; start: number; end: number }> };
type Narration = { script?: string; takes?: Take[]; pick?: number; approved?: boolean; off?: boolean; window?: { media: number; start: number; end: number; score?: number; reason?: string } } & Record<string, unknown>;
type Entry = Record<string, unknown> & { id: string; narration?: Narration; media?: Array<Record<string, unknown> & { src: string; kind: string; seconds?: number; start?: number; end?: number }> };
type Progress = { items: Array<{ id: string; n: number; plays: string; approved: boolean }>; counts: { posts: number; recorded: number; synthesized: number; none: number; approved: number } };
@@ -56,7 +58,7 @@ const fileUrl = (project: string, rel: string) => `/api/report/file?project=${en
const LABEL_KEY = "umtool.post-narration.label";
export default function PostNarrationPanel({
- project, entry, token, plan, render, onEntry, onTrim, s, setS, setPlaying, prev, next, fromPlay,
+ project, entry, token, plan, render, onEntry, onTrim, s, setS, setPlaying, prev, next, fromPlay, keepForCharacter,
}: {
project: string;
entry: Entry;
@@ -73,6 +75,8 @@ export default function PostNarrationPanel({
prev: string | null;
next: string | null;
fromPlay: boolean;
+ /** S2's seam (lane character-tuning): keep a Tune's numbers for the item's character. Absent: no button. */
+ keepForCharacter?: KeepForCharacter;
}) {
const n = entry.narration ?? {};
const takes = n.takes ?? [];
@@ -89,7 +93,7 @@ export default function PostNarrationPanel({
async (body: Record<string, unknown>) => {
setError(null);
const res = await fetch("/api/report/post-narration", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ project, id: entry.id, token, ...body }) });
- const j = (await res.json().catch(() => ({}))) as { entry?: Entry; token?: string; error?: string; errors?: string[]; jobId?: string; file?: string; untouched?: boolean; why?: string; window?: Narration["window"] };
+ const j = (await res.json().catch(() => ({}))) as { entry?: Entry; token?: string; error?: string; errors?: string[]; jobId?: string; file?: string; untouched?: boolean; why?: string; window?: Narration["window"]; busy?: boolean };
if (!res.ok) {
setError(j.errors?.join("; ") ?? j.error ?? `HTTP ${res.status}`);
return null;
@@ -221,7 +225,7 @@ export default function PostNarrationPanel({
// ---- a re-take with direction (the editor's tts op) --------------------------
const [dir, setDir] = useState({ note: "", voice: "", speed: "" });
- const [job, setJob] = useState<{ id: string; file: string; note: string; script: string; state: string; error?: string; polls?: number; derive?: { from: number; op: string; engine?: string | null; voice?: string | null; pitch?: string | null; semitones?: number | null } } | null>(null);
+ const [job, setJob] = useState<{ id: string; file: string; note: string; script: string; state: string; error?: string; polls?: number; again?: boolean; waiting?: string | null; derive?: { from: number; op: string; engine?: string | null; voice?: string | null; pitch?: string | null; semitones?: number | null } } | null>(null);
// Derived takes still to make after a re-record ("re-run the chain"), from the new take.
const [chain, setChain] = useState<Array<{ from: number; step: Step }>>([]);
const [rerunChain, setRerunChain] = useState(true);
@@ -242,6 +246,25 @@ export default function PostNarrationPanel({
const j = await post({ op: "take", note: dir.note || undefined, voice: dir.voice || undefined, speed: dir.speed ? Number(dir.speed) : undefined, script });
if (j?.jobId && j.file) setJob({ id: j.jobId, file: j.file, note: dir.note, script, state: "running" });
};
+ // ---- READ AGAIN (lane line-rerun): the next reading, unpicked, played as it lands ------------------------------
+ const [autoplay, setAutoplay] = useAutoPlay();
+ const [landed, setLanded] = useState<string | null>(null);
+ const readAgain = async (words: string, tuning: Tuning | null) => {
+ const j = await post({ op: "take", script: words, reading: "next", keepPick: true, ...(tuning ? { tuning } : {}), voice: dir.voice || undefined });
+ if (!j) return;
+ if (j.jobId && j.file) setJob({ id: j.jobId, file: j.file, note: "", script: words, state: "running", again: true });
+ };
+ const readEdited = async (tuning: Tuning | null) => {
+ const saved = await post({ op: "set", patch: { script } });
+ 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 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;
+ }, [takes, n.script, picked]);
+ const legacy = scriptEditOf(entry) === "legacy";
useEffect(() => {
if (!job || job.state !== "running") return;
const t = setTimeout(async () => {
@@ -250,17 +273,22 @@ export default function PostNarrationPanel({
...(job.derive ? { derive: String(job.derive.from), op: job.derive.op, ...(job.derive.engine ? { engine: job.derive.engine } : {}), ...(job.derive.voice ? { voice: job.derive.voice } : {}), ...(job.derive.pitch ? { pitch: job.derive.pitch } : {}), ...(typeof job.derive.semitones === "number" ? { semitones: String(job.derive.semitones) } : {}) } : {}),
});
const r = await fetch(`/api/report/post-narration?${q}`, { cache: "no-store" });
- const j = (await r.json().catch(() => ({}))) as { state?: string; error?: string; entry?: Entry; token?: string };
+ const j = (await r.json().catch(() => ({}))) as { state?: string; error?: string; entry?: Entry; token?: string; waiting?: string };
if (j.state === "done") {
- setJob({ ...job, state: "done" });
- setStatus(`new take ${job.file} (picked)`);
+ setJob({ ...job, state: "done", waiting: null });
+ setStatus(job.again ? `new reading ${job.file} -- Pick makes it the one` : `new take ${job.file} (picked)`);
+ if (job.again) {
+ setLanded(job.file);
+ if (autoplay) playNow(fileUrl(project, job.file));
+ }
if (j.entry) onEntry(j.entry, j.token ?? null);
else window.location.reload();
} else if (j.state === "failed" || !r.ok) setJob({ ...job, state: "failed", error: j.error ?? `HTTP ${r.status}` });
- // Still queued or running on the editor: ask again.
- else setJob({ ...job, polls: (job.polls ?? 0) + 1 });
+ // Still queued or running on the editor (waiting for a render, it says so): ask again.
+ else setJob({ ...job, polls: (job.polls ?? 0) + 1, waiting: j.waiting ?? null });
}, 1500);
return () => clearTimeout(t);
+ // eslint-disable-next-line react-hooks/exhaustive-deps
}, [job, project, entry.id]);
useEffect(() => {
@@ -294,13 +322,16 @@ 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): S2 keeps a Tune for it.
+ const [character, setCharacter] = useState<{ id: string; name: string; layer?: string } | null>(null);
useEffect(() => {
let live = true;
setCastConvert(null);
fetch(`/api/report/post-narration?project=${encodeURIComponent(project)}&id=${encodeURIComponent(entry.id)}&convert=1`, { cache: "no-store" })
.then((r) => (r.ok ? r.json() : null))
- .then((j: { character?: { name: string } | null; convert?: { engine?: string | null; voice?: string | null; pitch?: string; semitones?: number } | null } | 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 () => {
@@ -643,9 +674,11 @@ export default function PostNarrationPanel({
{src.kind === "recorded" ? `recorded · ${src.voice ?? t.voice ?? "?"}` : src.kind === "take" ? `${step?.op ?? "derived"}${step?.engine ? ` · ${step.engine}` : ""}${step?.voice ? ` → ${step.voice}` : ""}${convertPitchLabel(step) ? ` · pitch: ${convertPitchLabel(step)}` : ""}` : `${t.engine ?? "?"} · ${t.voice ?? "?"}`}
</span>
<span className="tabular-nums">{Number(t.seconds).toFixed(1)} s</span>
+ {madeWithText(t) && <span className="font-mono text-text-2" data-post-take-made={i + 1}>{madeWithText(t)}</span>}
+ {landed === t.file && <span className="micro text-[var(--color-sel)]" data-post-take-new={i + 1}>new</span>}
{/* eslint-disable-next-line jsx-a11y/media-has-caption */}
<audio src={fileUrl(project, t.file)} controls preload="none" className="h-7" data-post-take-audio={i + 1} />
- <button type="button" className={btn} disabled={picked?.index === i} onClick={() => void set({ pick: i })} data-post-take-pick={i + 1}>
+ <button type="button" className={btn} disabled={picked?.index === i} onClick={() => void set({ pick: i })} aria-label={`Pick take ${i + 1}`} data-post-take-pick={i + 1}>
Pick
</button>
{src.kind === "take" && step && (
@@ -670,6 +703,7 @@ export default function PostNarrationPanel({
</button>
{t.note && <span className="text-text-2">“{t.note}”</span>}
</div>
+ {t.script && src.kind === "tts" && t.read?.kind !== "thread" && <div className="truncate pl-6 text-text-2" title={t.script} data-post-take-text={i + 1}>{t.script}</div>}
{(t.parts?.length ?? 0) > 1 && (
<ol className="m-0 mt-1 list-none space-y-0.5 pl-6 text-text-2" data-post-take-parts={i + 1}>
{t.parts!.map((p) => (
@@ -741,8 +775,22 @@ export default function PostNarrationPanel({
<span className="micro">script — the post, verbatim; add emotion with <sigh> <laugh> <chuckle> <groan> <gasp></span>
<textarea value={script} onChange={(e) => setScript(e.target.value)} rows={4} className="mt-1 w-full rounded border border-seam bg-ground px-2 py-1" data-post-script="" />
</label>
+ {legacy && <p className="m-0 text-text-2" data-post-script-legacy="">{LEGACY_EDIT_TEXT}</p>}
+ <ReadAgain
+ busy={job?.state === "running"}
+ waiting={job?.state === "running" ? job.waiting ?? null : null}
+ canReadAgain={!!(n.script ?? "").trim() && script === (n.script ?? "")}
+ edited={!!script.trim() && script !== (n.script ?? "")}
+ onReadAgain={(t) => void readAgain(n.script ?? "", t)}
+ onReadEdited={(t) => void readEdited(t)}
+ madeWith={madeWith}
+ character={character}
+ keepForCharacter={keepForCharacter}
+ autoplay={autoplay}
+ onAutoplay={setAutoplay}
+ />
<div className="flex flex-wrap items-center gap-1.5">
- <button type="button" className={btn} disabled={script === (n.script ?? "")} onClick={() => void set({ script })} data-post-script-save="">
+ <button type="button" className={btn} disabled={script === (n.script ?? "") && !legacy} onClick={() => void set({ script })} data-post-script-save="">
Save script
</button>
<input value={dir.note} onChange={(e) => setDir({ ...dir, note: e.target.value })} placeholder="direction (kept with the take)" className="min-w-0 flex-1 rounded border border-seam bg-ground px-1.5 py-0.5" data-post-retake-note="" />
@@ -750,7 +798,7 @@ export default function PostNarrationPanel({
<button type="button" className={btn} disabled={!script.trim() || job?.state === "running"} onClick={() => void retake()} data-post-retake="">
{job?.state === "running" ? "Synthesizing on the editor…" : "Re-take with direction"}
</button>
- {job?.state === "failed" && <span className="text-[var(--color-blocking,#c33)]">{job.error}</span>}
+ {job?.state === "failed" && <span className="text-[var(--color-blocking,#c33)]" data-post-take-failed="">{job.error}</span>}
</div>
</section>
diff --git a/umtool/components/projects/PostScreensPanel.tsx b/umtool/components/projects/PostScreensPanel.tsx
@@ -6,7 +6,7 @@ import { isNarrated, pickedTake } from "umtool-report-to-video/post-narration";
import { ownPictureOnly } from "umtool-report-to-video/post-item";
import { lineTakeWarnings, lineTakesOf, partRoles, threadReadErrors } from "umtool-report-to-video/post-thread";
import { postFileUrl } from "./review/PostItemPlayer";
-import { ScreenLineVoice, useScreenVoice, type LineTakeOption, type ScreenVoice, type VoiceEntry } from "./ScreenLineVoice";
+import { ScreenLineVoice, lineReadings, useScreenVoice, type LineTakeOption, type ScreenVoice, type VoiceEntry } from "./ScreenLineVoice";
// ---------------------------------------------------------------------------
// A POST's SCREENS ON THE BENCH (report-to-video/post-screens.mjs; docs/report-video.md, "Screens"; operator, 12 Nov:
@@ -21,7 +21,7 @@ import { ScreenLineVoice, useScreenVoice, type LineTakeOption, type ScreenVoice,
type Line = { who?: string; side?: "left" | "right"; text: string; time?: string; redact?: true };
type Read = "all" | "none" | Array<{ line: number; text?: string }>;
-type Screen = { id: string; media: number; at?: [number, number]; kind: string; title?: string; source?: string; checked?: { by: string; at: string }; ref?: string; unread?: "omit" | "dim"; lines: Line[]; read: Read; lineTakes?: Record<string, string> };
+type Screen = { id: string; media: number; at?: [number, number]; kind: string; title?: string; source?: string; checked?: { by: string; at: string }; ref?: string; unread?: "omit" | "dim"; lines: Line[]; read: Read; saidAs?: Record<string, string>; lineTakes?: Record<string, string> };
type LineRecs = Array<{ role: string; screen: string; n: number; takes: Array<{ n: number; id: string; take: { steps?: Array<{ op: string; voice?: string }>; engine?: string; screenLine?: { heard?: unknown } }; current: boolean; chosen: boolean }> }>;
/** A recording's step as the select says it: recorded, cleaned, converted to its voice. */
const stepOf = (t: { steps?: Array<{ op: string; voice?: string }>; engine?: string }) => {
@@ -202,6 +202,17 @@ function ScreenEditor({
setRead(on ? [...list, { line: n }] : list);
};
const setExcerpt = (n: number, text: string) => setRead([...readList(sc).filter((x) => x.line !== n), text.trim() ? { line: n, text } : { line: n }]);
+ // What line n is SAID AS (saidAs; lane line-rerun): never drawn -- the card shows the line as written.
+ const setSaidAs = (n: number, text: string) =>
+ setScreen((s) => {
+ const sa = { ...(s.saidAs ?? {}) };
+ if (text.trim()) sa[String(n)] = text;
+ else delete sa[String(n)];
+ const { saidAs: _a, ...rest } = s;
+ void _a;
+ return Object.keys(sa).length ? { ...rest, saidAs: sa } : rest;
+ });
+ const spaced = (t: string) => t.toLowerCase().replace(/[^\p{L}\p{N}]+/gu, " ").trim();
const setLine = (n: number, patch: Partial<Line>) =>
setLines((lines) =>
lines.map((l, i) => {
@@ -334,6 +345,9 @@ function ScreenEditor({
{r && !l.redact && (
<input className="mt-0.5 w-full text-text-2" value={r.text ?? ""} placeholder="excerpt: the words read (all of them when empty)" onChange={(e) => setExcerpt(n, e.target.value)} data-post-screen-excerpt={n} />
)}
+ {d && !l.redact && (
+ <input className="mt-0.5 w-full text-text-2" value={sc.saidAs?.[String(n)] ?? ""} placeholder={`said as (the line as written when empty)`} onChange={(e) => setSaidAs(n, e.target.value)} aria-label={`said as, line ${n}`} data-post-screen-said-as={n} />
+ )}
{d && (d.cutBefore || d.cutAfter) && <span className="text-text-2">reads an excerpt</span>}
{shapes.length > 0 && !l.redact && <span className="text-text-2" data-post-screen-masked={n}> · masked: {shapes.join(", ")}</span>}
</td>
@@ -355,6 +369,12 @@ function ScreenEditor({
dirty={dirty}
options={(recs.find((x) => x.screen === sc.id && x.n === n)?.takes ?? []).map((x): LineTakeOption => ({ id: x.id, label: `take ${x.n} · ${stepOf(x.take)}${x.take.screenLine?.heard ? " · heard" : " · not heard"}`, current: x.current }))}
chosen={sc.lineTakes?.[String(n)]}
+ readings={lineReadings(entry, `screen:${sc.id}:${n}`)}
+ edited={(() => {
+ const said = sc.saidAs?.[String(n)];
+ const playing = lineReadings(entry, `screen:${sc.id}:${n}`).find((x) => x.picked);
+ return !!said && !!playing && spaced(playing.text) !== spaced(said);
+ })()}
onChoose={(id) =>
setScreen((s) => {
const lt = { ...(s.lineTakes ?? {}) };
diff --git a/umtool/components/projects/PostThreadPanel.tsx b/umtool/components/projects/PostThreadPanel.tsx
@@ -1,6 +1,7 @@
"use client";
-import { useMemo, useState } from "react";
+import { useMemo, useRef, useState } from "react";
+import ReadAgain, { playNow, useAutoPlay, type Tuning } from "./read/ReadAgain";
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";
@@ -26,7 +27,7 @@ const ROLE_NAME = (r: string | null) =>
r === null ? "no text on the card" : r === "post" ? "his words" : r === "quoted" ? "the post it quotes" : r === "parent:0" ? "the post it answers" : r.startsWith("parent:") ? "the post that answers" : `attachment ${Number(r.slice(6)) + 1}'s words`;
export default function PostThreadPanel({
- project = null, entry, plan, render, before, scene = null, setS, setEntry,
+ project = null, entry, plan, render, before, scene = null, setS, setEntry, onEntry,
}: {
/** The project (its "Read without it" re-joins the take through the post-narration route). */
project?: string | null;
@@ -38,6 +39,8 @@ export default function PostThreadPanel({
scene?: Record<string, unknown> | null;
setS: (s: number) => void;
setEntry: (f: (e: Entry) => Entry) => void;
+ /** The writer's answer after a Read again (the entry as it is now, the manifest's token). */
+ onEntry?: (e: Entry, token: string | null) => void;
}) {
const own = (entry.thread ?? undefined) as Thread | undefined;
const k = threadKnobs(entry, render) as Required<Thread>;
@@ -66,6 +69,37 @@ export default function PostThreadPanel({
setRereading(null);
}
};
+ // 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 [autoplay, setAutoplay] = useAutoPlay();
+ const [again, setAgain] = useState<{ state: string; waiting?: string | null; error?: string | null } | null>(null);
+ const poll = useRef<ReturnType<typeof setTimeout> | null>(null);
+ const readThreadAgain = async (tuning: Tuning | null) => {
+ if (!project || again?.state === "running") return;
+ const res = await fetch("/api/report/post-narration", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ project, op: "thread-read", id: entry.id, reading: "next", ...(tuning ? { tuning } : {}) }) });
+ const j = (await res.json().catch(() => ({}))) as { job?: { id: string }; error?: string };
+ if (!res.ok || !j.job) return setAgain({ state: "failed", error: j.error ?? `HTTP ${res.status}` });
+ setAgain({ state: "running" });
+ const jobId = j.job.id;
+ const tick = async () => {
+ const r = await fetch(`/api/report/post-narration?project=${encodeURIComponent(project)}&id=${encodeURIComponent(entry.id)}&screenJob=${encodeURIComponent(jobId)}`, { cache: "no-store" }).catch(() => null);
+ const v = r ? ((await r.json().catch(() => ({}))) as { state?: string; error?: string | null; waiting?: string; entry?: Entry | null; token?: string | null }) : {};
+ if (!v.state || v.state === "running") {
+ setAgain({ state: "running", waiting: v.waiting ?? null });
+ poll.current = setTimeout(tick, 1500);
+ return;
+ }
+ setAgain({ state: v.state, error: v.error ?? null });
+ if (v.state === "done" && v.entry) {
+ const takes = ((v.entry.narration as { takes?: Array<{ file?: string }> } | undefined)?.takes ?? []);
+ const file = takes.at(-1)?.file;
+ if (file && autoplay) playNow(`/api/report/file?project=${encodeURIComponent(project)}&path=${encodeURIComponent(file)}`);
+ onEntry?.(v.entry, v.token ?? null);
+ }
+ };
+ poll.current = setTimeout(tick, 800);
+ };
const startOf = (part: number) => plan.follow?.blocks.find((b) => b.part === part)?.start ?? null;
const setOwn = (patch: Thread) =>
setEntry((e) => {
@@ -112,6 +146,20 @@ export default function PostThreadPanel({
{layout.on ? "the card draws the conversation: each post read is shown in full, then shrinks and dims as the next comes in" : roles.length ? "his words only: the posts it answers are context" : "not narrated: the card as it is"}
</span>
</div>
+ {project && playing?.read?.kind === "thread" && (
+ <div className="mb-2">
+ <ReadAgain
+ what="the thread"
+ 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}
+ error={again?.state === "failed" ? again.error ?? "failed" : null}
+ autoplay={autoplay}
+ onAutoplay={setAutoplay}
+ />
+ </div>
+ )}
{sceneTiles.length > 0 && (
<p className="m-0 mb-2 text-text-2" data-post-thread-scene={sceneTiles.length}>
one scene with the item before:{" "}
diff --git a/umtool/components/projects/ScreenLineVoice.tsx b/umtool/components/projects/ScreenLineVoice.tsx
@@ -2,6 +2,7 @@
import { useCallback, useEffect, useRef, useState } from "react";
import { useMic, ls } from "./useMic";
+import ReadAgain, { playNow, useAutoPlay, type Tuning } from "./read/ReadAgain";
// ---------------------------------------------------------------------------
// A SCREEN LINE IN THE OPERATOR's VOICE, on the post bench's screens section (lib/report/screenLineRecord.mjs; the
@@ -14,7 +15,10 @@ import { useMic, ls } from "./useMic";
const LABEL_KEY = "umtool.post-narration.label";
-type Job = { id: string; what: string; role?: string; state: string; message?: string | null; error?: string | null };
+type Job = { id: string; what: string; role?: string; state: string; message?: string | null; error?: string | null; waiting?: string | null };
+type Part = { role?: string; file?: string; text?: string; reading?: number; tuning?: Tuning };
+type TakeLike = { file?: string; parts?: Part[]; read?: { kind?: string } };
+const fileUrl = (project: string, rel: string) => `/api/report/file?project=${encodeURIComponent(project)}&path=${encodeURIComponent(rel)}`;
export type VoiceEntry = Record<string, unknown> & { id: string };
/** The section's voice: one microphone, one take at a time, one job at a time. */
@@ -44,9 +48,9 @@ export function useScreenVoice({ project, id, onEntry, unsaved }: { project: str
setJob(j);
const tick = async () => {
const r = await fetch(`/api/report/post-narration?project=${encodeURIComponent(project)}&id=${encodeURIComponent(id)}&screenJob=${encodeURIComponent(j.id)}`, { cache: "no-store" }).catch(() => null);
- const v = r ? ((await r.json().catch(() => ({}))) as { state?: string; message?: string; error?: string; entry?: VoiceEntry | null; token?: string | null; result?: { takes?: Array<{ n: number; step: string }>; notes?: string[] } | null }) : {};
+ const v = r ? ((await r.json().catch(() => ({}))) as { state?: string; message?: string; error?: string; waiting?: string; entry?: VoiceEntry | null; token?: string | null; result?: { takes?: Array<{ n: number; step: string }>; notes?: string[] } | null }) : {};
const state = v.state ?? (r ? "failed" : "running");
- setJob({ ...j, state, message: v.message ?? null, error: v.error ?? null });
+ setJob({ ...j, state, message: v.message ?? null, error: v.error ?? null, waiting: v.waiting ?? null });
if (state === "running") {
poll.current = setTimeout(tick, 1500);
return;
@@ -63,6 +67,13 @@ export function useScreenVoice({ project, id, onEntry, unsaved }: { project: str
});
const made = v.result?.takes ?? [];
setStatus(`${j.role}: ${made.map((x) => `take ${x.n} ${x.step}`).join(", ")} -- none picked; choose one for the line, Save, then make the read${(v.result?.notes ?? []).length ? ` (${(v.result?.notes ?? []).join("; ")})` : ""}`);
+ } else if (j.what === "again" && j.role) {
+ // A LINE READ AGAIN (lane line-rerun): a new read, unpicked; its line's part plays as it lands.
+ const takes = ((v.entry?.narration as { takes?: TakeLike[] } | undefined)?.takes ?? []) as TakeLike[];
+ const part = takes.at(-1)?.parts?.find((p) => p.role === j.role && p.file);
+ setLanded({ role: j.role, take: takes.length - 1 });
+ if (part?.file && autoplayNow.current) playNow(fileUrl(project, part.file));
+ setStatus(`${j.role}: read again -- take ${takes.length}, not picked; Pick makes it the one`);
} else setStatus("the read is made (picked)");
if (kept) setStatus((x) => `${x ?? ""} -- your unsaved edits are kept: Save, then reload the bench to see it`);
void loadPrompts();
@@ -113,6 +124,28 @@ export function useScreenVoice({ project, id, onEntry, unsaved }: { project: str
}
follow({ id: j.job.id, what: "line", role, state: j.job.state });
};
+ // ---- READ A LINE AGAIN (lane line-rerun): `posts screen <p> <item> read --for <role> --reading next --no-pick` ----
+ const [autoplay, setAutoplay] = useAutoPlay();
+ const autoplayNow = useRef(autoplay);
+ autoplayNow.current = autoplay;
+ const [landed, setLanded] = useState<{ role: string; take: number } | null>(null);
+ const readLine = async (role: string, tuning: Tuning | null) => {
+ if (job?.state === "running") return;
+ setStatus(null);
+ const r = await fetch("/api/report/post-narration", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ project, op: "screen-read", id, for: role, reading: "next", keepPick: true, ...(tuning ? { tuning } : {}) }) });
+ const j = (await r.json().catch(() => ({}))) as { job?: { id: string; state: string }; error?: string };
+ if (!r.ok || !j.job) {
+ setJob({ id: "", what: "again", role, state: "failed", error: j.error ?? `HTTP ${r.status}` });
+ return;
+ }
+ follow({ id: j.job.id, what: "again", role, state: j.job.state });
+ };
+ const pickTake = async (index: number) => {
+ const r = await fetch("/api/report/post-narration", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ project, op: "set", id, patch: { pick: index } }) });
+ const j = (await r.json().catch(() => ({}))) as { entry?: VoiceEntry; token?: string; error?: string };
+ if (!r.ok || !j.entry) setStatus(j.error ?? `HTTP ${r.status}`);
+ else onEntry(j.entry, j.token ?? null);
+ };
const makeRead = async () => {
setStatus(null);
const r = await fetch("/api/report/post-narration", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ project, op: "screen-read", id }) });
@@ -123,7 +156,7 @@ export function useScreenVoice({ project, id, onEntry, unsaved }: { project: str
}
follow({ id: j.job.id, what: "read", state: j.job.state });
};
- return { mic, at, phase, takes, job, status, prompts, record, stop, redo, keep, makeRead };
+ return { mic, at, phase, takes, job, status, prompts, record, stop, redo, keep, makeRead, readLine, pickTake, landed, autoplay, setAutoplay, project };
}
export type ScreenVoice = ReturnType<typeof useScreenVoice>;
@@ -131,8 +164,21 @@ export type ScreenVoice = ReturnType<typeof useScreenVoice>;
/** The recordings of one line, as the select offers them: `{ id, label, current }`. */
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 };
+
+/** 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[] {
+ const n = (entry.narration ?? {}) as { takes?: TakeLike[]; pick?: number };
+ 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 }] : [];
+ });
+}
+
/** ONE READ LINE's voice cell: Record / Stop / play back / Redo / Keep, and the take chosen for it. */
-export function ScreenLineVoice({ role, n, voice, dirty, options, chosen, onChoose }: { role: string; n: number; voice: ScreenVoice; dirty: boolean; options: LineTakeOption[]; chosen: string | undefined; onChoose: (id: string | undefined) => void }) {
+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";
const t = voice.takes[role];
const busy = voice.job?.state === "running";
@@ -169,6 +215,36 @@ export function ScreenLineVoice({ role, n, voice, dirty, options, chosen, onChoo
)}
{dirty && <span className="text-text-2" data-post-screen-record-save-first={n}>save first</span>}
</div>
+ {!chosen && (
+ <ReadAgain
+ what={`line ${n}`}
+ busy={busy}
+ waiting={busy && voice.job?.role === role ? voice.job?.waiting ?? null : null}
+ canReadAgain={!dirty}
+ 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}
+ autoplay={voice.autoplay}
+ onAutoplay={voice.setAutoplay}
+ />
+ )}
+ {readings.length > 0 && (
+ <ul className="m-0 list-none space-y-0.5 p-0" data-post-screen-readings={n}>
+ {readings.map((x) => (
+ <li key={x.take} className="flex flex-wrap items-center gap-1.5" data-post-screen-reading={`${n}:${x.take + 1}`} data-picked={x.picked ? "1" : undefined}>
+ <span className="font-mono">take {x.take + 1}</span>
+ <span className="text-text-2">reading {x.reading}{x.tuning ? ` · ${Object.entries(x.tuning).map(([k, v]) => `${k} ${v}`).join(", ")}` : ""}</span>
+ {voice.landed?.role === role && voice.landed.take === x.take && <span className="micro" data-post-screen-reading-new="">new</span>}
+ {/* eslint-disable-next-line jsx-a11y/media-has-caption */}
+ {x.file && <audio src={fileUrl(voice.project, x.file)} controls preload="none" className="h-6 w-32" />}
+ <button type="button" className={btn} disabled={x.picked || busy || dirty} onClick={() => void voice.pickTake(x.take)} aria-label={`Pick take ${x.take + 1} for line ${n}`} data-post-screen-reading-pick={`${n}:${x.take + 1}`}>
+ {x.picked ? "playing" : "Pick"}
+ </button>
+ </li>
+ ))}
+ </ul>
+ )}
{options.length > 0 && (
<label className="flex items-center gap-1">
reads
diff --git a/umtool/components/projects/read/ReadAgain.tsx b/umtool/components/projects/read/ReadAgain.tsx
@@ -0,0 +1,152 @@
+"use client";
+
+import { useEffect, 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";
+
+// ---------------------------------------------------------------------------
+// READ AGAIN (lane line-rerun, S3 of the Orpheus re-tune plan): one line's
+// re-read controls, the same wherever a synthetic voice reads a line -- a
+// post's script, a screen line, a thread read, a card's narration.
+//
+// Read again the same words, the next reading
+// Read edited text the words as edited (saved first), read
+// Tune ▾ the six numbers for this line only, prefilled from
+// how it was last made
+// play when ready the new read plays as it lands (remembered per browser)
+//
+// Every press is a form and a job: the caller's route runs the umtool command.
+// The read made joins the list unpicked; the caller's Pick makes it the one.
+// `keepForCharacter` is S2's seam (lane character-tuning): absent, no button.
+// ---------------------------------------------------------------------------
+
+export type Tuning = Partial<Record<"temperature" | "top_p" | "top_k" | "min_p" | "repeat_penalty" | "takes", number>>;
+/** S2's seam: keep these numbers for the character (its command: `umtool cast set <id> --temperature …`). */
+export type KeepForCharacter = (tuning: Tuning) => Promise<string | null>;
+
+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" };
+const DEFAULTS: Record<string, number> = { ...ORPHEUS_TUNING_DEFAULTS, takes: ORPHEUS_DEFAULT_TAKES };
+
+/** Whether a new read plays as it lands: on unless this browser said otherwise. */
+export function useAutoPlay(): [boolean, (on: boolean) => void] {
+ const [on, setOn] = useState(true);
+ useEffect(() => setOn(ls.get(AUTOPLAY_KEY) !== "off"), []);
+ return [on, (v: boolean) => {
+ setOn(v);
+ ls.set(AUTOPLAY_KEY, v ? "on" : "off");
+ }];
+}
+
+/** Play `url` now (a read that landed); a browser that refuses without a gesture is left silent. */
+export function playNow(url: string) {
+ try {
+ void new Audio(url).play().catch(() => {});
+ } catch {
+ // no audio here
+ }
+}
+
+/** The numbers that differ from Orpheus's defaults, or null: what a read asks. */
+export function tuningAsked(draft: Record<string, string>): Tuning | null {
+ const out: Tuning = {};
+ for (const k of TTS_TUNING_FIELDS as readonly (keyof Tuning)[]) {
+ const v = Number(draft[k]);
+ if (draft[k] !== "" && Number.isFinite(v) && v !== DEFAULTS[k]) out[k] = v;
+ }
+ return Object.keys(out).length ? out : null;
+}
+
+/** A tuning and a reading as a short phrase: "reading 2 · temperature 0.7". Defaults are not said. */
+export function madeWithText(t: { reading?: number | null; tuning?: Tuning | null }): string {
+ const bits = [...(t.reading ? [`reading ${t.reading}`] : []), ...Object.entries(t.tuning ?? {}).filter(([k, v]) => v !== DEFAULTS[k]).map(([k, v]) => `${LABEL[k] ?? k} ${v}`)];
+ return bits.join(" · ");
+}
+
+export default function ReadAgain({
+ what = "", busy = false, waiting = null, canReadAgain = true, edited = false, onReadAgain, onReadEdited, madeWith = null, character = null, keepForCharacter, error = null, autoplay, onAutoplay,
+}: {
+ /** What is read, in the controls' names: "" (the post), "line 2", "the thread", "the card". */
+ what?: string;
+ busy?: boolean;
+ /** Said in place while the read waits (render mode holds the machine). */
+ waiting?: string | null;
+ canReadAgain?: boolean;
+ /** The words differ from what was last saved: Read edited text is offered. */
+ edited?: boolean;
+ 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. */
+ madeWith?: Tuning | 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;
+ error?: string | null;
+ /** Whether a new read plays as it lands (the caller's useAutoPlay: it plays it). */
+ autoplay: boolean;
+ onAutoplay: (on: boolean) => void;
+}) {
+ const start = (): Record<string, string> => Object.fromEntries(TTS_TUNING_FIELDS.map((k: string) => [k, String(madeWith?.[k as keyof Tuning] ?? DEFAULTS[k])]));
+ 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 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];
+ const v = Number(draft[k]);
+ return draft[k] === "" || !Number.isFinite(v) || v < r.min || v > r.max || (r.integer && !Number.isInteger(v));
+ });
+ return (
+ <div className="flex flex-wrap items-center gap-1.5" data-read-again={what || "post"}>
+ <button type="button" className={btn} disabled={busy || !canReadAgain} onClick={() => onReadAgain(tuningAsked(draft))} aria-label={what ? `Read ${what} again` : "Read again"} data-read-again-button="">
+ Read again
+ </button>
+ {onReadEdited && (
+ <button type="button" className={btn} disabled={busy || !edited} onClick={() => onReadEdited(tuningAsked(draft))} aria-label={what ? `Read ${what} as edited` : "Read the edited text"} data-read-edited-button="">
+ Read edited text
+ </button>
+ )}
+ <details className="relative" data-read-tune="">
+ <summary className={cn(btn, "cursor-pointer list-none")} aria-label={what ? `Tune ${what} only` : "Tune this line only"}>
+ Tune ▾
+ </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>
+ {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]} 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} />
+ </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="">
+ Read with these
+ </button>
+ <button type="button" className={btn} onClick={() => setDraft(Object.fromEntries(TTS_TUNING_FIELDS.map((k: string) => [k, 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="">
+ Keep for {character.name}
+ </button>
+ )}
+ </div>
+ {kept && <span className="text-text-2" data-read-tune-kept="">{kept}</span>}
+ </div>
+ </details>
+ <label className="flex items-center gap-1 text-text-2">
+ <input type="checkbox" checked={autoplay} onChange={(e) => onAutoplay(e.target.checked)} aria-label="Play new reads when they land" data-read-autoplay="" />
+ play when ready
+ </label>
+ {busy && <span className="text-text-2" data-read-busy="">{waiting ?? "reading…"}</span>}
+ {error && <span className="text-[var(--color-blocking,#c33)]" data-read-error="">{error}</span>}
+ </div>
+ );
+}
diff --git a/umtool/lib/report/postNarrationCli.mjs b/umtool/lib/report/postNarrationCli.mjs
@@ -29,7 +29,7 @@ import {
} from "umtool-report-to-video/post-narration";
import { CAST_CONVERT_PITCH, CAST_SEMITONES_MAX, convertPitchLabel } from "umtool-report-to-video/cast";
import { convertAskOf, stepPitchOf } from "./derivePitch.mjs";
-import { excerptSpansOf, postItemPlan, postReadText, scriptEditOf } from "umtool-report-to-video/post-item";
+import { LEGACY_EDIT_TEXT, excerptSpansOf, postItemPlan, postReadText, scriptEditOf } from "umtool-report-to-video/post-item";
import { partRoles } from "umtool-report-to-video/post-thread";
import { spokenRead } from "umtool-report-to-video/post-redact";
import { projectRedaction } from "./postRedaction.mjs";
@@ -295,7 +295,7 @@ export function narrationLines(e, render) {
}
/** What a legacy edited script is told (`--list`, the bench): the fact, and what moves it to the new rule. */
-export const LEGACY_EDIT = "edited before reads were kept apart from the card: its card follows the script -- save the script again to keep the card to the post's words";
+export const LEGACY_EDIT = LEGACY_EDIT_TEXT;
/** `k=v` words as a narration patch (the post's mix, or with `cut` the cut's). */
export function mixPatchOf(pairs, { cut = false } = {}) {
diff --git a/umtool/report-to-video/post-item.mjs b/umtool/report-to-video/post-item.mjs
@@ -179,6 +179,9 @@ const spacing = (t) => str(t).split(/\n\s*\n/).map((x) => x.replace(/\s+/g, " ")
/** Whether `script` says his words as drafted (shownDraftOf), paragraph for paragraph: not an edit for reading. */
export const saysShownDraft = (entry, script) => spacing(script) === spacing(shownDraftOf(entry));
+/** What an item edited before the rule is told (`posts narrate --list`, the bench): the fact, and what moves it. */
+export const LEGACY_EDIT_TEXT = "edited before reads were kept apart from the card: its card follows the script -- save the script again to keep the card to the post's words";
+
/**
* Whether a script is the post's words EDITED FOR READING (lane line-rerun; operator ruling 3, 15 Nov 2026: an edit
* changes only what is spoken) -- `script` the one to judge (default: the item's own):