commit 575233259a7606a5439c44e9f8f8a6153222ac10
parent e7e7555a74d27d53bc1b84f23a6f78fac38cd25e
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Thu, 5 Nov 2026 03:00:16 -0500
umtool: Reads and voices carries the redacted words (posts redact: the list, Blank it, remove) and the slur filter (posts slurs: on/off, level, visual, voice; Mask it, Never mask it, Back to the list), each the CLI's own postsCommand with --json
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
2 files changed, 103 insertions(+), 4 deletions(-)
diff --git a/umtool/app/api/report/pronunciation/route.ts b/umtool/app/api/report/pronunciation/route.ts
@@ -1,6 +1,7 @@
import { projectRef } from "@/lib/projects";
import { refuseCaller } from "@/lib/report/caller";
import { sayCommand, voicesCommand } from "@/lib/report/postSay.mjs";
+import { postsCommand } from "@/lib/report/postsCli.mjs";
import { addStep } from "@/lib/queue/store.mjs";
import { kickQueue, queueDir } from "@/lib/queue/runner";
@@ -10,12 +11,16 @@ export const dynamic = "force-dynamic";
// before: `umtool posts say` / `umtool posts voices`). The CLI's own commands (lib/report/postSay.mjs), run
// here with --json -- the files' one writer each (narration/lexicon.json, narration/voices.json).
//
-// GET ?project -> { lexicon: say ls, voices: voices ls, stale: say stale }
+// GET ?project -> { lexicon: say ls, voices: voices ls, stale: say stale, redact: posts redact ls,
+// slurs: posts slurs ls } (the redaction and the slur filter: their own commands)
// POST { project, op: "say-add", word, say, case?, item?, note? } posts say <p> add <word> "<say>" [--case] [--item] [--note]
// { project, op: "say-remove", n } posts say <p> remove <n> (1-based, as ls lists it)
// { project, op: "say-try", text, item? } posts say <p> try "<text>"
// { project, op: "voices-set", handle, voice } posts voices <p> set <handle|*> <voice>
// { project, op: "voices-remove", handle } posts voices <p> remove <handle|*>
+// { project, op: "redact-add", term, substring?, note? } posts redact <p> add "<term>" [--substring] [--note]
+// { project, op: "redact-remove", n } posts redact <p> remove <n>
+// { project, op: "slurs", verb: on|off|level|visual|voice|add|except|remove, value? } posts slurs <p> <verb> [value]
// { project, op: "queue-narrate", what: "scripts" | "takes" } QUEUED (lib/queue/, /jobs): posts narrate <p> --all
// --draft-scripts | --all --take -- long, so a step of
// the queue, never a request held open; the argv is built
@@ -33,13 +38,26 @@ async function run(fn: (out: (s: string) => void) => Promise<number>) {
}
const say = (project: NonNullable<Awaited<ReturnType<typeof projectRef>>>, rest: string[], flags: Flags = new Map()) =>
run((out) => sayCommand(project, rest, { flags, str: (k: string) => String(flags.get(k) ?? ""), json: true, out }));
+// `umtool posts <verb> <p> …` in this process (postsCli.mjs postsCommand), --json.
+const posts = async (args: string[]) => {
+ const said: string[] = [];
+ const r: { exit: number; json: Record<string, unknown> | null; error?: string } = await run((out) => postsCommand([...args, "--json"], { out, err: (x: string) => said.push(x) }));
+ if (r.exit !== 0 && !r.error) r.error = said.join("\n") || `posts ${args[0]} refused`;
+ return r;
+};
const voices = (project: NonNullable<Awaited<ReturnType<typeof projectRef>>>, rest: string[]) => run((out) => voicesCommand(project, rest, { json: true, out }));
export async function GET(request: Request) {
const project = await projectRef(new URL(request.url).searchParams.get("project") ?? "");
if (!project) return Response.json({ error: "no such project" }, { status: 404 });
- const [lexicon, voiceMap, stale] = await Promise.all([say(project, ["ls"]), voices(project, ["ls"]), say(project, ["stale"])]);
- return Response.json({ lexicon, voices: voiceMap, stale }, { headers: { "cache-control": "no-store" } });
+ const [lexicon, voiceMap, stale, redact, slurs] = await Promise.all([
+ say(project, ["ls"]),
+ voices(project, ["ls"]),
+ say(project, ["stale"]),
+ posts(["redact", project.id, "ls"]),
+ posts(["slurs", project.id, "ls"]),
+ ]);
+ return Response.json({ lexicon, voices: voiceMap, stale, redact, slurs }, { headers: { "cache-control": "no-store" } });
}
export async function POST(request: Request) {
@@ -61,7 +79,13 @@ export async function POST(request: Request) {
else if (b.op === "say-try") r = await say(project, ["try", s("text")], flags);
else if (b.op === "voices-set") r = await voices(project, ["set", s("handle"), s("voice")]);
else if (b.op === "voices-remove") r = await voices(project, ["remove", s("handle")]);
- else if (b.op === "queue-narrate") {
+ else if (b.op === "redact-add") r = await posts(["redact", project.id, "add", s("term"), ...(b.substring === true ? ["--substring"] : []), ...(s("note") ? ["--note", s("note")] : [])]);
+ else if (b.op === "redact-remove") r = await posts(["redact", project.id, "remove", String(Number(b.n))]);
+ else if (b.op === "slurs") {
+ const verb = s("verb");
+ if (!["on", "off", "level", "visual", "voice", "add", "except", "remove"].includes(verb)) return Response.json({ error: "slurs: on, off, level, visual, voice, add, except or remove" }, { status: 400 });
+ r = await posts(["slurs", project.id, verb, ...(verb === "on" || verb === "off" ? [] : [s("value")])]);
+ } else if (b.op === "queue-narrate") {
const what = b.what === "takes" ? "takes" : "scripts";
try {
const step = (await addStep(queueDir(), {
diff --git a/umtool/components/projects/PronunciationPanel.tsx b/umtool/components/projects/PronunciationPanel.tsx
@@ -19,6 +19,8 @@ type View = {
lexicon: { json: { lexicon?: Lex[] } | null; error?: string };
voices: { json: { voices?: Record<string, string>; narrator?: string; engine?: string; authors?: Author[] } | null; error?: string };
stale: { json: { reads?: { id: string; take: string; entries: { word: string; say: string }[]; fix: string }[] } | null };
+ redact?: { json: { redact?: (string | { term: string; substring?: boolean; note?: string })[]; corpusTerms?: number; markedPosts?: number } | null; error?: string };
+ slurs?: { json: { on?: boolean; level?: string; visual?: string; voice?: string; listed?: number; add?: number; except?: number; total?: number } | null; error?: string };
};
export default function PronunciationPanel({ project }: { project: string }) {
@@ -32,6 +34,8 @@ export default function PronunciationPanel({ project }: { project: string }) {
const [handle, setHandle] = useState("");
const [voice, setVoice] = useState("");
const [queued, setQueued] = useState<string | null>(null);
+ const [term, setTerm] = useState("");
+ const [slurWord, setSlurWord] = useState("");
const load = useCallback(async () => {
const r = await fetch(`/api/report/pronunciation?project=${encodeURIComponent(project)}`, { cache: "no-store" });
const j = await r.json().catch(() => null);
@@ -162,6 +166,77 @@ export default function PronunciationPanel({ project }: { project: string }) {
</button>
</div>
</section>
+ {/* What the cut publishes blanked (posts redact) and the slur filter (posts slurs): their own commands. */}
+ <section data-redact={(view?.redact?.json?.redact ?? []).length}>
+ <h3 className="micro mb-1">Redacted words · {(view?.redact?.json?.redact ?? []).length}</h3>
+ <table className="w-full border-collapse">
+ <tbody>
+ {(view?.redact?.json?.redact ?? []).map((x, i) => {
+ const t = typeof x === "string" ? { term: x } : x;
+ return (
+ <tr key={`${t.term}:${i}`} data-redact-row={i + 1}>
+ <td className={cn(cell, "font-mono")}>{t.term}</td>
+ <td className={cn(cell, "text-muted")}>
+ {t.substring ? "inside words too " : ""}
+ {t.note ?? ""}
+ </td>
+ <td className={cn(cell, "text-right")}>
+ <button type="button" data-redact-remove={i + 1} disabled={busy} onClick={() => void post({ op: "redact-remove", n: i + 1 })} className={buttonVariants({ variant: "quiet", size: "sm" })} aria-label={`remove redaction ${i + 1}`}>
+ ✕
+ </button>
+ </td>
+ </tr>
+ );
+ })}
+ </tbody>
+ </table>
+ <div className="mt-1 flex flex-wrap items-center gap-1.5">
+ <input data-redact-term="" value={term} onChange={(e) => setTerm(e.target.value)} placeholder="a word or phrase to blank" className={cn(input, "w-48")} />
+ <button type="button" data-redact-add="" disabled={busy || !term.trim()} onClick={() => void post({ op: "redact-add", term }).then((ok) => ok && setTerm(""))} className={buttonVariants({ variant: "outline", size: "sm" })}>
+ Blank it
+ </button>
+ <span className="text-muted">a bar on the card, out of the read and the captions</span>
+ </div>
+ </section>
+ <section data-slurs={view?.slurs?.json?.on ? "on" : "off"}>
+ <h3 className="micro mb-1">
+ Slur filter · {view?.slurs?.json?.on ? "on" : "off"} · {view?.slurs?.json?.total ?? 0} masked
+ </h3>
+ <div className="flex flex-wrap items-center gap-1.5">
+ <button type="button" data-slurs-toggle="" disabled={busy || !view?.slurs?.json} onClick={() => void post({ op: "slurs", verb: view?.slurs?.json?.on ? "off" : "on" })} className={buttonVariants({ variant: view?.slurs?.json?.on ? "pressed" : "outline", size: "sm" })} aria-pressed={!!view?.slurs?.json?.on}>
+ {view?.slurs?.json?.on ? "On" : "Off"}
+ </button>
+ {(
+ [
+ ["level", ["strong", "all"]],
+ ["visual", ["blackout", "placeholder"]],
+ ["voice", ["skip", "beep", "placeholder"]],
+ ] as const
+ ).map(([k, opts]) => (
+ <label key={k} className="inline-flex items-center gap-1">
+ {k}
+ <select data-slurs-knob={k} value={String((view?.slurs?.json as Record<string, unknown> | null | undefined)?.[k] ?? "")} disabled={busy} onChange={(e) => void post({ op: "slurs", verb: k, value: e.target.value })} className={input}>
+ {opts.map((o) => (
+ <option key={o} value={o}>
+ {o}
+ </option>
+ ))}
+ </select>
+ </label>
+ ))}
+ </div>
+ <div className="mt-1 flex flex-wrap items-center gap-1.5">
+ <input data-slurs-word="" value={slurWord} onChange={(e) => setSlurWord(e.target.value)} placeholder="a word" className={cn(input, "w-32")} />
+ {(["add", "except", "remove"] as const).map((v) => (
+ <button key={v} type="button" data-slurs-word-op={v} disabled={busy || !slurWord.trim()} onClick={() => void post({ op: "slurs", verb: v, value: slurWord }).then((ok) => ok && setSlurWord(""))} className={buttonVariants({ variant: "quiet", size: "sm" })}>
+ {v === "add" ? "Mask it" : v === "except" ? "Never mask it" : "Back to the list"}
+ </button>
+ ))}
+ <span className="text-muted">
+ {view?.slurs?.json?.add ?? 0} added · {view?.slurs?.json?.except ?? 0} excepted
+ </span>
+ </div>
+ </section>
{/* The whole cut's reads, long: steps of the queue (/jobs: their state, Retry, Cancel). */}
<section className="flex flex-wrap items-center gap-1.5 lg:col-span-2" data-narrate-all="">
<span className="micro">every post</span>