commit 1ee27dc0f8053fd27a0eacf98ba80bf6abd76cc7
parent d5ce1d357d545144dacce730955fb43f125a274a
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Tue, 3 Nov 2026 21:37:35 -0500
Merge lane/slur-censor: a slur filter over the redaction -- a default list as data (slurs.json), whole-word matching through look-alike letters; published cuts draw a placeholder pill and beep the read by its word timings (operator: pill + beep), blackout and skip as knobs; umtool posts slurs; take/build-video --uncensored and Play's Uncensored
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
24 files changed, 1433 insertions(+), 40 deletions(-)
diff --git a/umtool/app/api/report/post-item/route.ts b/umtool/app/api/report/post-item/route.ts
@@ -23,7 +23,9 @@ export const dynamic = "force-dynamic";
// GET ?project&id&w&h[&phase=read|media][&take][&published=1] the card's page, the HTML the
// build screenshots, at w × h (the footage box);
// published=1 AS PUBLISHED: its redacted words bars
-// (post-redact.mjs), never in the page
+// (post-redact.mjs), never in the page, its slurs
+// masked (post-slurs.mjs); &uncensored=1 the
+// slurs as posted (the redaction kept)
// GET ?project&file=posts-media/… an attachment (byte ranges): only a file
// under the project's posts-media/
// GET ?project&font=regular|bold the cut's faces, for the page
@@ -163,7 +165,8 @@ export async function GET(request: Request) {
const avatars = avatarUrls(found.manifest, (src: string) => `${base}&file=${encodeURIComponent(src)}`) as Record<string, string>;
let redaction = null;
try {
- if (q.get("published") === "1") redaction = await projectRedaction(r.project.dir, found.manifest);
+ // uncensored=1: the slur filter off (post-slurs.mjs) -- Play's Uncensored; the redaction stays.
+ if (q.get("published") === "1") redaction = await projectRedaction(r.project.dir, found.manifest, { uncensored: q.get("uncensored") === "1" });
} catch (e) {
return new Response(e instanceof Error ? e.message : String(e), { status: 500 });
}
diff --git a/umtool/app/api/report/post-narration/route.ts b/umtool/app/api/report/post-narration/route.ts
@@ -14,10 +14,13 @@ import { deleteTake, measureTake } from "@/lib/report/postNarrationCli.mjs";
import { keepRecording, RECORD_LABEL_RE } from "@/lib/report/postRecord.mjs";
import { fitPostItem } from "@/lib/report/postFit.mjs";
import { projectRedaction } from "@/lib/report/postRedaction.mjs";
-import { spokenWithout, termsFor } from "umtool-report-to-video/post-redact";
+import { spokenRead } from "umtool-report-to-video/post-redact";
export const dynamic = "force-dynamic";
+/** The slur filter's voice for a take synthesized on the bench: beep falls back to skip (no word timings yet to beep by). */
+const benchVoice = (red: { slurs?: { voice?: string } | null } | null) => (red?.slurs?.voice === "beep" ? "skip" : undefined) as "skip" | undefined;
+
// A NARRATED POST ITEM's bench (report-to-video/post-narration.mjs; knobs.md,
// "A narrated post item"): the recording session, the takes, the mix's knobs.
//
@@ -100,7 +103,11 @@ export async function GET(request: Request) {
const { result } = await withEditNotes(r.project, async () => updatePostNarration(r.project.dir, id, { addTake: derived }, { token: await manifestToken(r.project.dir) }));
return Response.json({ state: "done", file: rel, entry: result.entry, token: result.token }, { headers: noStore });
}
+ // What its audio does with the script's slurs (post-slurs.mjs): as the POST above asked for it.
+ const red = await projectRedaction(r.project.dir, m);
+ const slurs = spokenRead(script, e, red, { voice: benchVoice(red) }).slurs;
const take = {
+ ...(slurs ? { slurs } : {}),
file: rel, engine: res.engine ?? q.get("engine") ?? "orpheus", voice: res.voice ?? q.get("voice") ?? "zac", seconds: meas.seconds,
source: { kind: "tts", engine: res.engine ?? q.get("engine") ?? "orpheus", voice: res.voice ?? q.get("voice") ?? "zac", script },
script, at: new Date().toISOString(), jobId: job, ...(Number.isFinite(meas.lufs) ? { lufs: meas.lufs } : {}), ...(note ? { note } : {}),
@@ -169,8 +176,11 @@ export async function POST(request: Request) {
await mkdir(dir, { recursive: true });
const rel = takeFileOf(pid, nextTakeNumber(e, await readdir(dir).catch(() => [])), engine, voice);
const speed = body.speed === undefined || body.speed === null || engine === "orpheus" ? undefined : Number(body.speed);
- // What the voice SAYS: the script with every redacted term left out (post-redact.mjs); the script is kept as written.
- const spoken = spokenWithout(script, termsFor(e, await projectRedaction(r.project.dir, m)));
+ // What the voice SAYS: the script with every redacted term left out (post-redact.mjs) and each slur as the cut's
+ // filter has it (post-slurs.mjs); the script is kept as written. The bench cannot word-time a take as it is made,
+ // so a beep falls back to skip here (the CLI's --take times it and beeps).
+ const red = await projectRedaction(r.project.dir, m);
+ const spoken = spokenRead(script, e, red, { voice: benchVoice(red) }).text;
const jobId = await startJob("/api/ops/tts", { text: spoken, engine, voice, out: path.join(r.project.dir, ...rel.split("/")), ...(speed ? { speed } : {}) });
return Response.json({ ok: true, jobId, file: rel, engine, voice, script }, { headers: noStore });
}
diff --git a/umtool/components/projects/review/PlayCut.tsx b/umtool/components/projects/review/PlayCut.tsx
@@ -174,6 +174,8 @@ const PAUSE_KEY = "umtool.play.pauseWhileWriting";
const SHOW_REJECTED_KEY = "umtool.play.showIncorrect";
/** Play's "As published": post cards drawn with their redacted words as bars (post-redact.mjs). Per browser. */
const AS_PUBLISHED_KEY = "umtool.play.asPublished";
+/** And which cut: censored (the slur filter on, post-slurs.mjs) or the uncensored one. Per browser. */
+const UNCENSORED_KEY = "umtool.play.uncensored";
/** The dailies' kinds of note: what it asks for, and its key (with Alt, in the composer). */
const ASKS: { id: CutAsk; label: string; key: string }[] = [
@@ -343,9 +345,11 @@ export default function PlayCut({
// (umtool check blocks on a fact error and lists the rest). Remembered per browser.
const [showRejected, setShowRejected] = useState(false);
const [asPublished, setAsPublished] = useState(false);
+ const [uncensored, setUncensored] = useState(false);
useEffect(() => {
try {
if (window.localStorage.getItem(AS_PUBLISHED_KEY) === "on") setAsPublished(true);
+ if (window.localStorage.getItem(UNCENSORED_KEY) === "on") setUncensored(true);
} catch {
// A preference, not state.
}
@@ -849,6 +853,7 @@ export default function PlayCut({
playing={ui.playing && !ui.waiting}
speed={rate}
published={asPublished}
+ uncensored={uncensored}
/>
) : null;
// A post item that repeats an earlier one's attachment: its combo badge, beside the player.
@@ -1078,7 +1083,7 @@ export default function PlayCut({
</select>
</label>
{hasPosts && (
- <label className="inline-flex items-center gap-1.5 text-[11.5px] text-text-2" title="the post cards as the video draws them: every redacted word a blank bar (umtool posts redact)">
+ <label className="inline-flex items-center gap-1.5 text-[11.5px] text-text-2" title="the post cards as the video draws them: every redacted word a blank bar (umtool posts redact), every slur masked (umtool posts slurs)">
<input
type="checkbox"
data-play-as-published=""
@@ -1093,7 +1098,26 @@ export default function PlayCut({
}
}}
/>
- As published
+ {asPublished ? (uncensored ? "As published (uncensored)" : "As published (censored)") : "As published"}
+ </label>
+ )}
+ {hasPosts && asPublished && (
+ <label className="inline-flex items-center gap-1.5 text-[11.5px] text-text-2" title="the UNCENSORED cut: the slurs as posted (umtool take … --uncensored; umtool posts slurs) -- the redacted words stay bars">
+ <input
+ type="checkbox"
+ data-play-uncensored=""
+ checked={uncensored}
+ onChange={(ev) => {
+ const on = ev.target.checked;
+ setUncensored(on);
+ try {
+ window.localStorage.setItem(UNCENSORED_KEY, on ? "on" : "off");
+ } catch {
+ // A preference, not state.
+ }
+ }}
+ />
+ Uncensored
</label>
)}
{item && (
diff --git a/umtool/components/projects/review/PostItemPlayer.tsx b/umtool/components/projects/review/PostItemPlayer.tsx
@@ -276,7 +276,7 @@ function MediaEl({
}
export default function PostItemPlayer({
- project, take = null, entry, plan, box, s, playing, cardKey = null, speed = 1, published = false,
+ project, take = null, entry, plan, box, s, playing, cardKey = null, speed = 1, published = false, uncensored = false,
}: {
project: string;
take?: string | null;
@@ -292,6 +292,8 @@ export default function PostItemPlayer({
speed?: number;
/** AS PUBLISHED (Play's toggle): the card with its redacted words as bars, as the build draws it. */
published?: boolean;
+ /** With `published`: the UNCENSORED cut -- the slurs as posted (post-slurs.mjs), the redaction kept. */
+ uncensored?: boolean;
}) {
const wrap = useRef<HTMLDivElement | null>(null);
const [scale, setScale] = useState(0);
@@ -329,7 +331,7 @@ export default function PostItemPlayer({
}, [box.width]);
const layout = useMemo(() => postLayout(entry, box), [entry, box]);
const pageUrl = (phase: "read" | "media") =>
- `/api/report/post-item?project=${encodeURIComponent(project)}&id=${encodeURIComponent(entry.id)}&w=${Math.round(box.width)}&h=${Math.round(box.height)}&phase=${phase}${take ? `&take=${encodeURIComponent(take)}` : ""}${cardKey ? `&v=${encodeURIComponent(cardKey)}` : ""}${published ? "&published=1" : ""}`;
+ `/api/report/post-item?project=${encodeURIComponent(project)}&id=${encodeURIComponent(entry.id)}&w=${Math.round(box.width)}&h=${Math.round(box.height)}&phase=${phase}${take ? `&take=${encodeURIComponent(take)}` : ""}${cardKey ? `&v=${encodeURIComponent(cardKey)}` : ""}${published ? `&published=1${uncensored ? "&uncensored=1" : ""}` : ""}`;
const reading = s < plan.reading || !plan.steps.length;
const current = stepAt(plan, s);
// Beside the card, the first attachment is up (its first frame) while the words are read.
diff --git a/umtool/docs/cli.md b/umtool/docs/cli.md
@@ -56,6 +56,7 @@ Inbox cannot disagree about what is wrong with one.
| `notes …` | operator notes: list, read, reply, resolve ([notes.md](notes.md)) |
| `take <project> --id <id> --label L [--group G] [--kind similar\|different] [--summary S] [--style NAME] [--patch FILE \| --patch-json JSON \| --set path=value …] [--effect NAME] [--at S --dur S \| --full] [--quick] [--force] [--progress ndjson]` | one **take**: the manifest with a montage style's patch, then an overlay effect's (`--effect`, release 35), then the take's own, rendered into `takes/<id>/` (the Takes page's New take); `--id <id> --rebuild` makes one again from its own `take.json` ([report-video.md](report-video.md#making-takes)) |
| `take <project> --id <id> --label L [--patch F \| …] --draft` (`--no-render`) · `take <project> --id <id> [--full \| --at S --dur S]` · `take <project> --id <id> --rebuild [--full \| --at S --dur S]` · `take <project> --id <id> --promote [--anyway] [--json]` | a **draft** take: recorded with nothing rendered, to be walked first; a draft named with no patch flags is rendered from its stored (walked) patch, and `--rebuild` takes a window flag; **make it the cut**: the take's patch applied to the manifest now, one undo point (`revisions/…-auto-before-promote-take`), refused (exit 1) when its timeline would replace a cut that changed since, until `--anyway` ([report-video.md](report-video.md#walking-a-take-drafts-edits-into-the-take-and-making-it-the-cut)) |
+| `take <project> --id <id> … --uncensored` · build-video `--uncensored` | the **uncensored cut** ([knobs.md](knobs.md#the-slur-filter-slurs-masked-in-what-is-published-off-for-the-uncensored-cut)): the same cut with the post items' slur filter off -- `render.posts.slurs.on: false` in the take's patch (a `--rebuild` keeps it; a censored take is not rebuilt uncensored, **exit 2**: make a take of its own), its label gains "(uncensored)", take.json's `slurs` records `censored` or `uncensored`. The redaction of private words and censored attachments stay on |
| `take … --priority` · `takes make … --priority` · `render-mode on [--for 90m] [--note T] [--json \| --print-token]` · `render-mode on [--for 90m] [--note T] [--print-token] -- <cmd …>` · `render-mode off [--force] [--json]` · `render-mode status [--json]` | **render mode**: a render the operator waits for gets the machine. `--priority` turns it on for the take's (or the batch's) lifetime — on at the start, off at the end, on a failure and on a signal; the Takes page's **Give renders the machine** is the same flag. While it is on, every other heavy job (e2e suites, `next build`s, the publish stages, other renders) waits at the heavy slot's door (`queue-lock: held for a render (…) — waiting`), the render runs on the floor 4000 MB and the cap 10240 MB, and the editor's transcription and download lanes are held through its ops (`lane`; only the ones not already held, and only those are released at off). `render-mode on` is a window (default 2h) for a chain of renders: every `umtool take` started in it renders in it, another command joins with the `RENDER_PRIORITY_TOKEN` it prints (`--print-token`: the token alone on stdout, the rest on stderr). **`on … -- <cmd …>` is the form for a script**: the command is spawned with the token in its environment, the hold is the command's pid, and it is released when the command exits — done, failed, or umtool signalled (the signal is passed on); umtool exits with the command's code, and inside a manual window the command joins it. A bare `on` in a script leaves the window behind (the chain trap). `off` ends it (a running take's hold only with `--force`, else it ends with the take); `status` says what holds it and releases a stale hold's lanes. A hold whose process is gone or whose window is over is no hold. Needs WORKER_TOKEN and the editor at ARCHILYZER_EDITOR_URL for the lanes; without them it still holds the door. **Exit 1** when it is already on, or a lane could not be released ([report-video.md](report-video.md#render-mode-giving-a-render-the-machine); WORKTREES.md, "Render mode") |
| `takes make <project> [--recipe FILE] [--only ID,ID] [--force]` · `takes make <project> --all-styles [--group G] [--at S --dur S \| --full]` | a recipe's takes, one at a time (default `takes/recipe.json`); every montage style, one take each (Make all styles); **exit 1** if any failed |
| `takes styles [--json]` · `takes effects <project> [--json]` · `takes pick <project> <take> [--anyway] [--pin \| --unpin] [--json]` | the montage styles; the overlay effects the cut offers (`render.chrome.fx` presets: the Takes page's **Effect** list); **Use this take** — refused (exit 1) when the project changed since the take was made, until `--anyway`; `--pin` keeps the pick when newer takes are built (each whole-cut take of the manifest is otherwise its group's pick once built), `--unpin` lets go ([report-video.md](report-video.md#takes-alternative-renders-judged-side-by-side)) |
@@ -88,6 +89,7 @@ Inbox cannot disagree about what is wrong with one.
| `posts fit <project> [--all \| <item> …] [--linger <s>] [--dry-run] [--json]` · `posts set-item <project> <item> fit=read[:<linger>]` | narrated posts' video attachments cut to their **best part** for the read (lead + take + tail + linger): a scored scan of the sound (loudness, its peaks), the speech (a transcript) and the scene cuts, the start snapped to a pause or a cut, recorded with why (`narration.window`) -- ONE write; each post's old and new length printed. A video no longer than the read is left as it is |
| `posts avatar <project> [<handle> <image-file> \| <handle> off] [--json]` · `posts avatars <project> [--dry-run] [--json]` | the **authors' pictures** (`postAvatars`): `avatar` copies a picture into `posts-media/_avatars/` for every card that draws that handle (manual; never replaced by the archive's), `off` clears it, no handle lists them; `avatars` copies the archive's (the channels' `posts-media/_avatars/avatars.json`, capture-posts') for every author the cut's cards draw unblurred that it has none of. A blurred author never shows one |
| `posts redact <project> ls \| add "<term>" [--substring] [--note "…"] \| remove <n> [--json]` | **REDACTED WORDS** ([knobs.md](knobs.md#redacted-words-blanked-from-what-is-published)): the project's list (`render.posts.redact`, `updatePostRedact`) of words or phrases blanked from everything the cut publishes -- a solid bar on the rendered card, left out of a synthesized read, a post's chapter line and an attachment's captions; matched without case, as whole words (`--substring`: inside words too), a phrase across any spaces or punctuation. The posts' words and the scripts are never rewritten. `ls` numbers the terms as `remove` takes them, and counts the corpus's (`transcripts/redactions.json`) and the posts marked up in the cut's channels (`posts-markup.json`). A term already listed is refused (**exit 1**) |
+| `posts slurs <project> [ls] \| on \| off \| level strong\|all \| visual blackout\|placeholder \| voice skip\|beep\|placeholder \| add <word> \| except <word> \| remove <word> [--json]` | **THE SLUR FILTER** ([knobs.md](knobs.md#the-slur-filter-slurs-masked-in-what-is-published-off-for-the-uncensored-cut)): `render.posts.slurs` (`updatePostSlurs`, one undo point each), on by default -- the slurs of the shipped list (`report-to-video/slurs.json`; `level strong`: only the strong ones) and the project's own (`add`; `except` never masks one) masked in everything the cut publishes: a dark pill with its mask (`visual placeholder`, the default, "f*****") or a bar (`blackout`) on the card; said and beeped by the take's word timings (`voice beep`, the default), left out of a synthesized read (`skip`), or its stand-in said (`placeholder`). `ls` counts what the cut masks per slur and per post -- masks only, never the word -- and names each narrated post whose take says one with no word timings (a censored build refuses it; `posts narrate <p> <item> --words`). `off` is the uncensored cut (the redaction stays). A word already on a list, or on neither for `remove`, is refused (**exit 1**); an unknown verb or value (**exit 2**) |
| `posts context <project> [--dry-run] [--json]` | every **post item's context from its capture** (`postContext.mjs`): the post it quotes and the post it answers, as its page showed them (`capture.json`'s `context`, read by the editor's `capture-posts` -- `"contextOnly": true` reads it alone), filled where the archive row lacks them -- `quoted` where the entry has none (or a named one with no words, the same post), `parents` where it has none (a thread shot stays on the entry; the card draws the parents). What the archive gave is never replaced. ONE write for every entry (`setPostItemsContext`: one undo point, refused whole in the build's words); a re-run with nothing new writes nothing. A post whose capture read no context is listed with the call that reads it (`pnpm ops capture-posts --json '{"slug":…,"ids":[…],"contextOnly":true}' --wait`). The card's blur of other authors is unchanged ([report-video.md](report-video.md#post-items-a-post-as-an-entry-of-the-cut)) |
| `posts repeats <project> [--match id\|file\|audio] [--json]` | the **combo counter**'s repeats ([report-video.md](report-video.md#the-combo-counter)): every attachment the cut's post items play more than once -- the same X media id (the capture's url), else the same file (the capture's sha256 when its bytes agree, else hashed; cached by path, size and mtime), else (`--match audio`) the same sound (fpcalc, else a coarse ffmpeg hash) -- its posts in the cut's ORDER with their dates, the tier that matched and the badge each draws (`×2` from the second use, `(×n)` counted but not drawn); a post whose CAPTURE holds the same file but whose entry carries no attachment is listed too, `NOT ATTACHED`, with the `posts attach` that brings it in. Reads only |
| `posts attach <project> [<item> … \| --all] [--dry-run] [--json]` | a post item with **no attachment whose capture holds one** (captured after it went in -- `posts repeats` marks them `NOT ATTACHED`): the capture's media (its own channel's `posts-media/<postId>/`, else any channel the cut's posts come from) copied into the project's `posts-media/<slug>/<postId>/` and measured, set as the entry's `media` as `posts reel` would have made it -- nothing else of the entry changes (its paraphrases, narration, knobs kept); an item that has an attachment is never touched. ONE write (one undo point: `timeline <p> undo`), refused whole in the build's words |
diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md
@@ -719,6 +719,48 @@ published card never pushes in on a blank.
| the corpus's list — `transcripts/redactions.json`, the same shape (or `{terms: […]}`): blanked in every project | — | read by every build; the editor's to write | — |
| one post's markup — `transcripts/channels/<slug>/posts-markup.json`, `{"<postId>": {redact?: [{term, wholeWord?, scope?} \| {start, end, scope?, index?}], censor?: [{media, blur?}]}}`: a term in a `scope` (`text`, `parent`, `quoted`; absent, the whole post), or a span of the archived text in code units (`index`: which parent, nearest first); `censor` blurs the post's attachment `media` (its index; `blur` as `media[i].blur`'s keys, absent the whole frame) in every project | — | read by every build of a cut playing the post; the editor's to write | — |
+## The slur filter (slurs masked in what is published; off for the uncensored cut)
+
+Slurs masked in everything a cut PUBLISHES -- on by default, and switched off for an **uncensored cut** of the same
+project (`report-to-video/post-slurs.mjs`, built on the redaction above). The list is DATA,
+`report-to-video/slurs.json`: each slur's forms (its plurals and inflections), its level (`strong`, or `mild`: masked
+only at level `all`), its mask (default: its first letter and an asterisk for each other letter, "f*****") and its
+spoken stand-in ("f-slur"). A slur matches as a WHOLE word without regard to case -- never inside another word
+("Scunthorpe", "niggardly", "retardant" are left alone) -- including the common ways of writing one past a filter: a
+letter swapped for a look-alike (`@`/`4` for a, `0` for o, `3` for e, `1`/`!` for i, `$`/`5` for s, `*` for a vowel)
+and the word spelt out letter by letter with ONE space, dot, dash or underscore between every pair ("f a g g o t",
+"f.a.g.g.o.t"; letters partly together are not read as one). Like the redaction, the archive's rows, the manifest's
+snapshot and every script keep their words.
+
+- **The card** (`visual`): `placeholder` (the default), a dark pill holding the mask (`data-post-slur`), the first letter in the case the post wrote it -- the same mask for the same
+ slur across the cut, and never the word in the card's HTML; `blackout`, the redaction's solid bar (no letters in the page). Its words, the authors' names, the repost line, the
+ posts it answers and quotes, a paraphrase; a video attachment's burnt-in captions (left out under blackout, the mask
+ under placeholder) and a chapter line (the mask). A slur spelt apart keeps its tokens, so a word zoom's indices hold;
+ a zoom on a masked word is refused, as on a redacted one.
+- **The read** (`voice`): `beep` (the default -- the operator, 3 Nov: "skip seems like it'd be unnatural"), said, and a 1 kHz tone laid over it (the voice silenced under it) at its time in the take's
+ word timings; `skip`, left out of a synthesized read (as a redacted term is); `placeholder`, its stand-in said in its place. `umtool posts narrate <p> <item> --take` word-times a beep take right after it is made (the editor's
+ transcribe op) and, when that cannot be done, synthesizes the read again with the slur skipped; the bench's re-take
+ cannot time it, so a beep is skipped there. A take records what its audio does (`takes[i].slurs`: `said`, `skip`,
+ `placeholder`). A take that SAYS a slur -- a recording, a beep take, a take from before the filter (no `slurs`), a
+ derived take of one -- is covered in the render by its word timings (`takes[i].words`): silenced over the word under
+ voice `skip`, beeped otherwise. **A censored build refuses a post whose take says a slur and has no word timings**
+ (`umtool posts slurs <p> ls` names each one, with the `--words` line that fixes it).
+- **The switch**: `on: false` -- the project's own, `umtool take <p> --id <id> … --uncensored` (the take's PATCH, so a
+ `--rebuild` keeps it; its label gains "(uncensored)" and take.json's `slurs` says `censored` or `uncensored`),
+ build-video's `--uncensored`, Play's **Uncensored** beside **As published**. Only the slurs are toggled: the
+ redaction of private words and a censored attachment stay on in the uncensored cut. A read synthesized with the slur
+ skipped or replaced stays that way in the uncensored cut (the take holds no word to restore): for an uncensored read,
+ use voice `beep` or a recorded take.
+
+| Knob | In umtool | From a terminal | Route |
+|---|---|---|---|
+| `render.posts.slurs.on` — `true` (default) \| `false`: the uncensored cut | Play the cut, **As published** + **Uncensored** | `umtool posts slurs <p> on` · `off` · `umtool take <p> --id <id> … --uncensored` · build-video `--uncensored` | `GET /api/report/post-item?…&published=1&uncensored=1` |
+| `render.posts.slurs.level` — `all` (default: strong and mild) \| `strong` | — | `umtool posts slurs <p> level strong\|all` | — |
+| `render.posts.slurs.visual` — `placeholder` (default) \| `blackout` | Play, **As published** | `umtool posts slurs <p> visual blackout\|placeholder` | — |
+| `render.posts.slurs.voice` — `beep` (default) \| `skip` \| `placeholder` | — | `umtool posts slurs <p> voice skip\|beep\|placeholder` | — |
+| `render.posts.slurs.add` — the project's own words (always masked; a word, or `{word, forms?, mask?, say?}`) · `.except` — never masked here (a form, a slur's word or its id) | — | `umtool posts slurs <p> add <word>` · `except <word>` · `remove <word>` (one writer, `updatePostSlurs`) | — |
+| what the cut masks | — | `umtool posts slurs <p> ls [--json]`: per slur (its mask, never the word) and per post, and each read that needs word timings | — |
+
## A word zoom (a post item's card pushed in on a word as it is read)
`fx: [{kind: "word-zoom", match, …}]` on a post item ([report-video.md](report-video.md#a-word-zoom): the shape, the
@@ -733,7 +775,7 @@ its bounds. Its bench is the post bench's **word zoom** block; Play the cut zoom
| `scale` 1.2–4 (default 2), `lead` 0–3 s in before the word (0.5), `hold` 0–10 s on it (1.2), `ease` `out`\|`inOut`\|`snap` (`inOut`), `highlight` a colour `#rrggbb` (`#ffd84d`, drawn at 42% under the words with a solid underline) or `false` | the zoom's **scale**, **lead**, **hold**, **ease**, **highlight** (and its colour); the way back out is 0.4 s on the same ease | `set <n> --scale 2.5 --lead 0.3 --hold 1.5 --ease snap --highlight off` (`default` clears one) | `fx: {set: <i>, patch: {…}}` |
| remove one | the zoom's **remove** | `umtool posts fx <p> <item> remove <n>` (1 = the first, as `ls` shows) | `fx: {remove: <i>}` |
| list them, each with its time and where it came from | the block's rows; the plan strip and the read lane mark each from its lead-in to back out | `umtool posts fx <p> <item> [ls] [--json]` | — |
-| `narration.takes[i].words` — the take's WORD TIMINGS, `[{w, start, end}]` per script word (take seconds): the editor's `transcribe` op (`words: true`; parakeet keeps word times) on the take -- or each of its parts' files, at their starts -- the words heard aligned to its script, fuzzy and in order (a typo read as the word it means still pairs; a word not heard is placed between its neighbours) | post bench, **Get word timings** (a job on the editor; the block says when the take is timed) | `umtool posts narrate <p> <item> --words [--worker <id>]` | `POST {op: "take-words", id, worker?}` → `{jobs}` · `GET ?project&id&takeWords=<job>,…` keeps them when done |
+| `narration.takes[i].words` — the take's WORD TIMINGS, `[{w, start, end}]` per script word (take seconds): the editor's `transcribe` op (`words: true`; parakeet keeps word times) on the take -- or each of its parts' files, at their starts -- the words heard aligned to its script, fuzzy and in order (a typo read as the word it means still pairs; a word not heard is placed between its neighbours); what a word zoom is timed by, and what the slur filter silences or beeps a said slur by | post bench, **Get word timings** (a job on the editor; the block says when the take is timed) | `umtool posts narrate <p> <item> --words [--worker <id>]` | `POST {op: "take-words", id, worker?}` → `{jobs}` · `GET ?project&id&takeWords=<job>,…` keeps them when done |
## Read-follow (the block being read lit, the card panned to it)
diff --git a/umtool/e2e/post-items.spec.ts b/umtool/e2e/post-items.spec.ts
@@ -130,6 +130,47 @@ test("a redacted term: Play shows the words; As published draws blank bars and t
expect(JSON.stringify(timeline())).toContain("here is the video");
});
+test("the slur filter: As published (censored) draws the placeholder pill and never the word; Uncensored draws the word; the redaction stays on in both", async ({ page }) => {
+ // A made-up word put on the filter (umtool posts slurs add; knobs.md, "The slur filter"), drawn as the default placeholder pill.
+ umtool(["posts", "slurs", PROJECT, "add", "video"]);
+ umtool(["posts", "redact", PROJECT, "add", "here is"]);
+ const ls = umtool(["posts", "slurs", PROJECT, "ls"]);
+ expect(ls).toContain("the slur filter is ON");
+ expect(ls).toMatch(/v\*{4} +\(its own\) +×1/);
+ expect(ls).not.toContain("video");
+ await page.setViewportSize({ width: 1366, height: 1000 });
+ await page.goto(urls.playHref(PROJECT, { bare: true, clip: "p-vid" }));
+ await page.evaluate(() => {
+ window.localStorage.removeItem("umtool.play.asPublished");
+ window.localStorage.removeItem("umtool.play.uncensored");
+ });
+ await page.reload();
+ await expect(root(page)).toHaveAttribute("data-play-item", "p-vid");
+ const card = page.frameLocator('[data-post-card-frame="read"]');
+ // umtool's own view: the words as posted; no Uncensored toggle until As published is on.
+ await expect(card.locator("[data-post-words]")).toContainText("the video.");
+ await expect(page.locator("[data-play-uncensored]")).toHaveCount(0);
+ await page.locator("[data-play-as-published]").check();
+ await expect(page.locator("label:has([data-play-as-published])")).toContainText("As published (censored)");
+ // CENSORED: the word a dark pill holding its mask; the redacted phrase still bars.
+ await expect(card.locator("[data-post-slur]")).toHaveCount(1);
+ await expect(card.locator("[data-post-slur]")).toHaveText("v****");
+ await expect(card.locator("[data-post-blanked]")).toHaveCount(2);
+ const dom = await card.locator("html").evaluate((el) => el.outerHTML);
+ expect(dom.toLowerCase()).not.toContain("video.");
+ expect(dom.toLowerCase()).not.toContain("here is");
+ if (SHOTS) await page.screenshot({ path: path.join(SHOTS, "post-items-slurs-censored.png") });
+ // UNCENSORED: the word as posted; the redaction is not part of the switch.
+ await page.locator("[data-play-uncensored]").check();
+ await expect(page.locator("label:has([data-play-as-published])")).toContainText("As published (uncensored)");
+ await expect(card.locator("[data-post-slur]")).toHaveCount(0);
+ await expect(card.locator("[data-post-words]")).toContainText("the video.");
+ await expect(card.locator("[data-post-blanked]")).toHaveCount(2);
+ if (SHOTS) await page.screenshot({ path: path.join(SHOTS, "post-items-slurs-uncensored.png") });
+ // The snapshot is never rewritten.
+ expect(JSON.stringify(timeline())).toContain("here is the video");
+});
+
test("a censored attachment: set-item blurs it, Play previews the blur and its label, the bench toggles it off and saves", async ({ page }) => {
umtool(["posts", "set-item", PROJECT, "p-vid", "media.0.blur=on"]);
await page.setViewportSize({ width: 1366, height: 1000 });
diff --git a/umtool/lib/report/manifest.mjs b/umtool/lib/report/manifest.mjs
@@ -2923,6 +2923,60 @@ export async function updatePostRedact(dir, change, { token = null } = {}) {
});
}
+// ---- the slur filter (post-slurs.mjs; `umtool posts slurs`) ---------------
+
+/**
+ * CHANGE THE CUT's SLUR FILTER (`render.posts.slurs`): `{ set: { on?, level?,
+ * visual?, voice? } }` sets its knobs (a null: back to the default), `{ add:
+ * "<word>" }` masks a word of the project's own, `{ except: "<word>" }` never
+ * masks one (a form, a slur's word or its id), `{ remove: "<word>" }` takes a
+ * word off both lists. A word already on the list it is added to is refused.
+ * The posts' words are never touched. Validated with the build's check.
+ *
+ * @param {string} dir
+ * @param {{ set?: Record<string, unknown>, add?: string, except?: string, remove?: string }} change
+ * @param {{ token?: string | null }} [opts]
+ */
+export async function updatePostSlurs(dir, change, { token = null } = {}) {
+ const ops = ["set", "add", "except", "remove"].filter((k) => isObj(change) && change[k] !== undefined);
+ if (ops.length !== 1) throw new Error("say set, add, except or remove");
+ return structural(dir, "post-slurs", token, (m) => {
+ if (!isObj(m.render)) m.render = {};
+ const posts = isObj(m.render.posts) ? m.render.posts : {};
+ const sl = isObj(posts.slurs) ? { ...posts.slurs } : {};
+ const word = (v) => String(v ?? "").trim().toLowerCase();
+ const has = (list, w) => (Array.isArray(list) ? list : []).some((x) => word(typeof x === "string" ? x : x?.word) === w);
+ if (change.set !== undefined) {
+ if (!isObj(change.set)) throw new Error("set takes {on?, level?, visual?, voice?}");
+ for (const [k, v] of Object.entries(change.set)) {
+ if (!["on", "level", "visual", "voice", "note"].includes(k)) throw new StructureRefused([`render.posts.slurs.${k} is not a knob a write sets (on, level, visual, voice, note)`]);
+ if (v === null || v === undefined) delete sl[k];
+ else sl[k] = v;
+ }
+ } else if (change.add !== undefined || change.except !== undefined) {
+ const key = change.add !== undefined ? "add" : "except";
+ const w = word(change[key]);
+ if (has(sl[key], w)) throw new Error(`that word is already on the ${key} list`);
+ sl[key] = [...(Array.isArray(sl[key]) ? sl[key] : []), w];
+ // A word is added or excepted, never both.
+ const other = key === "add" ? "except" : "add";
+ if (Array.isArray(sl[other])) sl[other] = sl[other].filter((x) => word(typeof x === "string" ? x : x?.word) !== w);
+ } else {
+ const w = word(change.remove);
+ if (!has(sl.add, w) && !has(sl.except, w)) throw new Error("that word is on neither list (add, except)");
+ for (const k of ["add", "except"]) if (Array.isArray(sl[k])) sl[k] = sl[k].filter((x) => word(typeof x === "string" ? x : x?.word) !== w);
+ }
+ for (const k of ["add", "except"]) if (Array.isArray(sl[k]) && !sl[k].length) delete sl[k];
+ if (Object.keys(sl).length) posts.slurs = sl;
+ else delete posts.slurs;
+ if (Object.keys(posts).length) m.render.posts = posts;
+ else delete m.render.posts;
+ const errors = validatePostsRender(m.render);
+ if (errors.length) throw new StructureRefused(errors);
+ return { slurs: sl };
+ });
+}
+
// ---- the link policy (UI notes 2026-10-30, #10; linkPolicy.mjs) -----------
/**
diff --git a/umtool/lib/report/postNarrationCli.mjs b/umtool/lib/report/postNarrationCli.mjs
@@ -26,7 +26,7 @@ import {
NARRATION_INDEX, POST_DERIVE_OPS, POST_DERIVE_ROUTES, derivedFileOf, draftScript, takeIdOf, isNarrated, nextTakeNumber, pickedTake, postIdOf, postNarrationKnobs, takeFileOf, takesDirOf,
} from "umtool-report-to-video/post-narration";
import { postItemPlan } from "umtool-report-to-video/post-item";
-import { spokenWithout, termsFor } from "umtool-report-to-video/post-redact";
+import { spokenRead } from "umtool-report-to-video/post-redact";
import { projectRedaction } from "./postRedaction.mjs";
import { readManifest } from "../projects/report.mjs";
import { withEditNotes } from "./edit-guard.mjs";
@@ -247,7 +247,7 @@ export function mixPatchOf(pairs, { cut = false } = {}) {
* the project, measured, appended (and picked) through the writer. Returns
* the take and the write's result.
*/
-export async function makeTake(project, e, { script = null, note = null, engine = null, voice = null, speed = null, render = {}, emit = () => {}, editor = null, ask = null, redaction = undefined } = {}) {
+export async function makeTake(project, e, { script = null, note = null, engine = null, voice = null, speed = null, render = {}, emit = () => {}, editor = null, ask = null, askOp = null, redaction = undefined } = {}) {
const k = postNarrationKnobs(e, render);
const words = String(script ?? e.narration?.script ?? "").trim();
if (!words) throw new NarrateError(`${e.id} has no script to read (--script "…", or --all --draft-scripts)`);
@@ -262,23 +262,59 @@ export async function makeTake(project, e, { script = null, note = null, engine
const rel = takeFileOf(pid, n, eng, vox);
const out = path.join(project.dir, ...rel.split("/"));
const askTts = ask ?? (await import("umtool-report-to-video/narrate-via-editor")).askEditorTts;
- // What the voice SAYS: the script with every redacted term left out (post-redact.mjs) -- the script itself is kept as written.
+ // What the voice SAYS: the script with every redacted term left out (post-redact.mjs), and each slur as the
+ // cut's filter has it (post-slurs.mjs: skipped, its stand-in, or said for a beep) -- the script itself is kept as written.
const red = redaction !== undefined ? redaction : await projectRedaction(project.dir, (await readManifest(project.dir)) ?? {});
- const body = { text: spokenWithout(words, termsFor(e, red)), engine: eng, voice: vox, out, ...(spd !== null && eng !== "orpheus" ? { speed: spd } : {}) };
- const { jobId, result } = await askTts(body, { ...(editor ? { editor } : {}), emit });
+ const said = spokenRead(words, e, red);
+ const ttsBody = (text) => ({ text, engine: eng, voice: vox, out, ...(spd !== null && eng !== "orpheus" ? { speed: spd } : {}) });
+ let { jobId, result } = await askTts(ttsBody(said.text), { ...(editor ? { editor } : {}), emit });
if (!(await stat(out).catch(() => null))?.isFile()) throw new NarrateError(`the editor's job ${jobId} finished but ${rel} is not there (its result names ${result?.wav ?? "no file"})`);
+ // A BEEP needs the slur's time: the take is word-timed now (the editor's transcription). When that cannot be
+ // done, the read is synthesized again with the slur left out -- a published take never says one it cannot cover.
+ let slurs = said.slurs;
+ let timed = null;
+ if (slurs === "said" && red?.slurs?.on && red.slurs.voice === "beep") {
+ try {
+ timed = await timeTakeWords(project, rel, words, { askOp, emit });
+ } catch (err) {
+ emit("note", { message: `${e.id}: its read could not be word-timed for the beep (${err instanceof Error ? err.message : err}) -- synthesized again with the slur left out` });
+ ({ jobId, result } = await askTts(ttsBody(spokenRead(words, e, red, { voice: "skip" }).text), { ...(editor ? { editor } : {}), emit }));
+ slurs = "skip";
+ }
+ }
const m = await measureTake(out);
const take = {
file: rel, engine: result?.engine ?? eng, voice: result?.voice ?? vox, seconds: m.seconds ?? Number(result?.seconds),
source: { kind: "tts", engine: result?.engine ?? eng, voice: result?.voice ?? vox, script: words },
script: words, at: new Date().toISOString(), ...(note ? { note } : {}), ...(spd !== null && eng !== "orpheus" ? { speed: spd } : {}),
...(Number.isFinite(m.lufs) ? { lufs: m.lufs } : {}), jobId,
+ // What its audio does with the slurs the script holds (post-slurs.mjs), and its words when timed for a beep.
+ ...(slurs ? { slurs } : {}), ...(timed ? { words: timed } : {}),
};
const patch = { addTake: take, ...(script !== null && script !== e.narration?.script ? { script: words } : {}) };
const { result: wrote, editNotes } = await withEditNotes(project, async () => updatePostNarration(project.dir, e.id, patch, { token: await manifestToken(project.dir) }));
return { take, result: wrote, editNotes };
}
+/**
+ * A just-made take's WORD TIMINGS (for a beep over a slur it says): the editor's
+ * transcription of its file, aligned to the script it read (word-zoom.mjs
+ * scriptWordTimes) -- `posts narrate --words`' way, before the take is kept.
+ * Throws when the editor cannot, or hears no words.
+ */
+async function timeTakeWords(project, rel, script, { askOp = null, emit = () => {} } = {}) {
+ const { recognizedOf, wordsFileOf } = await import("./postFxCli.mjs");
+ const { scriptWordTimes } = await import("umtool-report-to-video/word-zoom");
+ const ask = askOp ?? (await import("umtool-report-to-video/narrate-via-editor")).askEditorOp;
+ const abs = path.join(project.dir, ...rel.split("/"));
+ const outFile = path.join(project.dir, ...wordsFileOf(rel).split("/"));
+ emit("note", { message: `timing ${rel}'s words for the beep (the editor's transcription)…` });
+ await ask("/api/ops/transcribe", { path: abs, words: true, out: outFile }, { emit });
+ const heard = recognizedOf(JSON.parse(await readFile(outFile, "utf8")), 0);
+ if (!heard.length) throw new Error("the transcription came back with no word timings");
+ return scriptWordTimes(script, heard).words;
+}
+
/** `umtool posts narrate …` (postsCli.mjs routes it here). */
export async function narrateCommand(project, words, flags, { json = false, dryRun = false, out = (s) => console.log(s), str }) {
const manifest = await readManifest(project.dir);
diff --git a/umtool/lib/report/postRedaction.mjs b/umtool/lib/report/postRedaction.mjs
@@ -8,8 +8,9 @@ import { channelsDirFor, hasShadowChannels } from "../projects/report.mjs";
/**
* @param {string} dir the project's folder
* @param {Record<string, any>} manifest
+ * @param {{ uncensored?: boolean }} [o] the slur filter off (post-slurs.mjs), the redaction kept
*/
-export async function projectRedaction(dir, manifest) {
+export async function projectRedaction(dir, manifest, { uncensored = false } = {}) {
const channelsDir = channelsDirFor(dir, manifest, { shadowExists: await hasShadowChannels(dir) });
- return readPostRedaction(channelsDir, manifest);
+ return readPostRedaction(channelsDir, manifest, { uncensored });
}
diff --git a/umtool/lib/report/postSlurs.test.mjs b/umtool/lib/report/postSlurs.test.mjs
@@ -0,0 +1,195 @@
+// The slur filter's writer and CLI (`umtool posts slurs`), a take's read under
+// each voice (skip, placeholder, beep -- word-timed, or skipped when it cannot
+// be), and the uncensored take (`umtool take … --uncensored`). The slurs come
+// from the shipped list; no test spells one out, and no CLI line prints one.
+import assert from "node:assert/strict";
+import { execFileSync } from "node:child_process";
+import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
+import { readFileSync } from "node:fs";
+import { tmpdir } from "node:os";
+import path from "node:path";
+import { after, test } from "node:test";
+import { postsCommand } from "./postsCli.mjs";
+import { makeTake } from "./postNarrationCli.mjs";
+import { projectRedaction } from "./postRedaction.mjs";
+import { takeCommand } from "./takeCli.mjs";
+import { PROJECT_KINDS } from "../projects/kinds.mjs";
+
+const LIST = JSON.parse(readFileSync(new URL("../../report-to-video/slurs.json", import.meta.url), "utf8"));
+const F = LIST.entries.find((e) => e.id === "f-slur").word;
+const N = LIST.entries.find((e) => e.id === "n-word").word;
+const ROOT = await mkdtemp(path.join(tmpdir(), "umtool-post-slurs-"));
+after(() => rm(ROOT, { recursive: true, force: true }));
+const REPORTS = path.join(ROOT, "reports");
+const CH = path.join(ROOT, "channels");
+const wav = (f, secs) => execFileSync("ffmpeg", ["-v", "error", "-y", "-f", "lavfi", "-i", `sine=f=220:d=${secs}`, "-ar", "48000", "-ac", "1", f]);
+
+const item = (id, o = {}) => ({
+ type: "post", id: `p-${id}`, post: `subj-x/${id}`, platform: "x", author: "THE SUBJECT", handle: "Subject", date: "2026-10-30T10:00:00.000Z",
+ text: `post ${id}`, ...o,
+});
+async function project(name, timeline, render = {}) {
+ const dir = path.join(REPORTS, name);
+ await mkdir(dir, { recursive: true });
+ await writeFile(path.join(dir, "video.manifest.json"), JSON.stringify({
+ schemaVersion: 1, slug: name, title: name, provenance: { siteOrigin: "", channelSlug: "subj-x", channelsDir: CH },
+ render: { width: 1920, height: 1080, fps: 30, ...render }, timeline,
+ }, null, 2));
+ await writeFile(path.join(dir, "project.json"), JSON.stringify({ kind: PROJECT_KINDS.find((k) => k.makesTakes).id, title: name }) + "\n");
+ return { id: name, dir };
+}
+const manifest = async (p) => JSON.parse(await readFile(path.join(p.dir, "video.manifest.json"), "utf8"));
+const cli = async (args) => {
+ const lines = [];
+ const errs = [];
+ const code = await postsCommand(args, { root: REPORTS, out: (s) => lines.push(s), err: (s) => errs.push(s) });
+ return { code, out: lines.join("\n"), err: errs.join("\n") };
+};
+
+test("posts slurs ls: what the cut would mask, per slur and per post, masks only -- and each read's state", async () => {
+ const p = await project("ls", [
+ item("1", { text: `you ${F}, and ${F} again` }),
+ item("2", { text: "clean", quoted: { author: "Q", handle: "q", text: `a ${N}` } }),
+ item("3", { text: "nothing", narration: { script: `he said ${F}`, takes: [{ file: "narration/posts/3/take-1.orpheus-zac.wav", seconds: 2, script: `he said ${F}` }] } }),
+ item("4"),
+ ]);
+ const r = await cli(["slurs", "ls", "ls"]);
+ assert.equal(r.code, 0, r.err);
+ assert.match(r.out, /the slur filter is ON -- level all, visual placeholder, voice beep/);
+ assert.match(r.out, /masks 4 word\(s\) in 3 post item\(s\)/);
+ assert.match(r.out, /f\*{5} +f-slur +×3 +in 2 post\(s\): p-1, p-3/);
+ assert.match(r.out, /p-2 +n\*{5} ×1 +\(quoted\.text\)/);
+ assert.match(r.out, /p-3 +NEEDS WORD TIMINGS/);
+ assert.ok(!r.out.toLowerCase().includes(F) && !r.out.toLowerCase().includes(N), "ls never prints a slur");
+ const j = JSON.parse((await cli(["slurs", "ls", "--json"])).out);
+ assert.equal(j.total, 4);
+ assert.deepEqual(j.bySlur["f-slur"].posts, ["p-1", "p-3"]);
+ assert.equal(j.reads[0].needs, "word timings");
+ // Timed: covered (beeped, as the default voice beep has it).
+ const m = await manifest(p);
+ m.timeline[2].narration.takes[0].words = [{ w: "he", start: 0, end: 0.3 }, { w: "said", start: 0.3, end: 0.6 }, { w: F, start: 0.6, end: 1 }];
+ await writeFile(path.join(p.dir, "video.manifest.json"), JSON.stringify(m));
+ assert.match((await cli(["slurs", "ls", "ls"])).out, /p-3 +beeped \(1 span\(s\)\)/);
+});
+
+test("posts slurs on|off|level|visual|voice|add|except|remove: one writer, refused in the build's words, the posts untouched", async () => {
+ const p = await project("w", [item("1", { text: `a ${F} and a zorbo` })]);
+ const ok = async (...a) => {
+ const r = await cli(["slurs", "w", ...a]);
+ assert.equal(r.code, 0, r.err);
+ assert.ok(!r.out.toLowerCase().includes(F), "no line prints a slur");
+ return r.out;
+ };
+ assert.match(await ok("off"), /OFF: this is the uncensored cut/);
+ assert.deepEqual((await manifest(p)).render.posts.slurs, { on: false });
+ await ok("on");
+ assert.equal((await manifest(p)).render.posts, undefined, "the defaults leave no key");
+ await ok("level", "strong");
+ await ok("visual", "blackout");
+ await ok("voice", "skip");
+ assert.match(await ok("add", "zorbo"), /z\*{4} is masked in this cut/);
+ await ok("except", F);
+ assert.deepEqual((await manifest(p)).render.posts.slurs, { level: "strong", visual: "blackout", voice: "skip", add: ["zorbo"], except: [F] });
+ const red = await projectRedaction(p.dir, await manifest(p));
+ assert.equal(red.slurs.visual, "blackout");
+ assert.ok(red.slurs.entries.some((e) => e.word === "zorbo"));
+ assert.ok(!red.slurs.entries.some((e) => e.forms.includes(F)));
+ await ok("remove", F);
+ await ok("level", "all");
+ assert.deepEqual((await manifest(p)).render.posts.slurs, { visual: "blackout", voice: "skip", add: ["zorbo"] });
+ // The defaults (placeholder + beep) back: their keys go.
+ await ok("visual", "placeholder");
+ await ok("voice", "beep");
+ assert.deepEqual((await manifest(p)).render.posts.slurs, { add: ["zorbo"] });
+ assert.equal((await cli(["slurs", "w", "add", "zorbo"])).code, 1, "already on the list");
+ assert.equal((await cli(["slurs", "w", "voice", "hum"])).code, 2);
+ assert.equal((await cli(["slurs", "w", "remove", "nothing"])).code, 1);
+ assert.equal((await cli(["slurs", "w", "sideways"])).code, 2);
+ assert.equal((await manifest(p)).timeline[0].text, `a ${F} and a zorbo`, "the snapshot is never rewritten");
+ assert.match((await cli(["slurs", "--help"])).err, /THE SLUR FILTER/);
+});
+
+const asker = (asked) => async (body) => {
+ asked.push(body);
+ wav(body.out, 1);
+ return { jobId: `job-${asked.length}`, result: { wav: body.out, engine: body.engine, voice: body.voice, seconds: 1 } };
+};
+
+test("a take's read: skip leaves the slur out, placeholder says its stand-in; the take records which; the script keeps the word", async () => {
+ const script = `Hello, you ${F}. Welcome.`;
+ for (const [voice, said, state] of [["skip", "Hello, you. Welcome.", "skip"], ["placeholder", "Hello, you f-slur. Welcome.", "placeholder"]]) {
+ const p = await project(`r-${voice}`, [item("1", { narration: { script } })], { posts: { slurs: { voice } } });
+ const asked = [];
+ const r = await makeTake(p, (await manifest(p)).timeline[0], { ask: asker(asked) });
+ assert.equal(asked[0].text, said);
+ assert.equal(r.take.slurs, state);
+ assert.equal(r.take.script, script);
+ assert.equal((await manifest(p)).timeline[0].narration.takes[0].slurs, state);
+ }
+ // The filter off (an uncensored project): said, and recorded so -- a later censored cut will cover it.
+ const p = await project("r-off", [item("1", { narration: { script } })], { posts: { slurs: { on: false } } });
+ const asked = [];
+ assert.equal((await makeTake(p, (await manifest(p)).timeline[0], { ask: asker(asked) })).take.slurs, "said");
+ assert.equal(asked[0].text, script);
+ // No slur: no state.
+ const q = await project("r-none", [item("1", { narration: { script: "Hello there." } })]);
+ assert.equal((await makeTake(q, (await manifest(q)).timeline[0], { ask: asker([]) })).take.slurs, undefined);
+});
+
+test("a beep take: said, then word-timed so the render can beep it; when it cannot be timed, synthesized again with the slur left out", async () => {
+ const script = `Hello, you ${F}. Welcome.`;
+ const p = await project("b", [item("1", { narration: { script } })], { posts: { slurs: { voice: "beep" } } });
+ const asked = [];
+ const ops = [];
+ const askOp = async (route, body) => {
+ ops.push(route);
+ await writeFile(body.out, JSON.stringify({ words: [{ w: "Hello,", start: 0, end: 0.3 }, { w: "you", start: 0.3, end: 0.5 }, { w: `${F}.`, start: 0.5, end: 0.9 }, { w: "Welcome.", start: 1, end: 1.4 }] }));
+ return { jobId: "t-1", result: {} };
+ };
+ const r = await makeTake(p, (await manifest(p)).timeline[0], { ask: asker(asked), askOp });
+ assert.equal(asked.length, 1);
+ assert.equal(asked[0].text, script);
+ assert.deepEqual(ops, ["/api/ops/transcribe"]);
+ assert.equal(r.take.slurs, "said");
+ assert.equal(r.take.words.length, 4);
+ assert.deepEqual(r.take.words[2], { w: `${F}.`, start: 0.5, end: 0.9 });
+ // The editor cannot: the read again, the slur left out.
+ const q = await project("b2", [item("1", { narration: { script } })], { posts: { slurs: { voice: "beep" } } });
+ const asked2 = [];
+ const notes = [];
+ const r2 = await makeTake(q, (await manifest(q)).timeline[0], { ask: asker(asked2), askOp: async () => { throw new Error("no parakeet worker"); }, emit: (_e, f) => notes.push(f.message) });
+ assert.deepEqual(asked2.map((b) => b.text), [script, "Hello, you. Welcome."]);
+ assert.equal(r2.take.slurs, "skip");
+ assert.equal(r2.take.words, undefined);
+ assert.match(notes.join("\n"), /could not be word-timed for the beep \(no parakeet worker\)/);
+});
+
+test("umtool take … --uncensored: the slur filter off in the take's patch, its label and take.json say so", async () => {
+ const p = await project("u", [item("1", { text: `you ${F}` })]);
+ await mkdir(path.join(p.dir, "out", "clips-raw"), { recursive: true });
+ const seen = [];
+ const deps = {
+ render: async (job) => {
+ seen.push(JSON.parse(await readFile(job.manifestPath, "utf8")));
+ const file = path.join(job.outDir, `${job.slug}.mp4`);
+ await writeFile(file, "render");
+ return { file };
+ },
+ probe: async () => 1,
+ };
+ const errs = [];
+ const io = { reportsRoot: REPORTS, log: () => {}, err: (s) => errs.push(s), deps };
+ assert.equal(await takeCommand(["u", "--id", "unc", "--label", "Cut", "--full", "--uncensored"], io), 0, errs.join("\n"));
+ const take = JSON.parse(await readFile(path.join(p.dir, "takes", "unc", "take.json"), "utf8"));
+ assert.equal(take.label, "Cut (uncensored)");
+ assert.equal(take.slurs, "uncensored");
+ assert.deepEqual(take.patch, { render: { posts: { slurs: { on: false } } } });
+ assert.equal(seen[0].render.posts.slurs.on, false);
+ assert.equal(await takeCommand(["u", "--id", "cen", "--label", "Cut", "--full"], io), 0, errs.join("\n"));
+ assert.equal(JSON.parse(await readFile(path.join(p.dir, "takes", "cen", "take.json"), "utf8")).slurs, "censored");
+ // A censored take is not rebuilt uncensored: that is a take of its own.
+ assert.equal(await takeCommand(["u", "--id", "cen", "--rebuild", "--uncensored"], io), 2);
+ assert.match(errs.at(-1), /made censored/);
+ // The project's manifest is not touched.
+ assert.equal((await manifest(p)).render.posts, undefined);
+});
diff --git a/umtool/lib/report/postSlursCli.mjs b/umtool/lib/report/postSlursCli.mjs
@@ -0,0 +1,123 @@
+// `umtool posts slurs` -- THE SLUR FILTER of a cut's post items
+// (umtool-report-to-video/post-slurs.mjs; umtool/docs/knobs.md, "The slur
+// filter"): what it would mask, and its knobs.
+//
+// umtool posts slurs <p> [ls] what the cut would mask: per slur, per post, and each read's state
+// umtool posts slurs <p> on | off the filter (off: the cut is the uncensored one)
+// umtool posts slurs <p> level strong|all only the strong slurs, or the mild ones too
+// umtool posts slurs <p> visual blackout|placeholder
+// umtool posts slurs <p> voice skip|beep|placeholder
+// umtool posts slurs <p> add <word> | except <word> | remove <word>
+//
+// Every write goes through updatePostSlurs (one undo point each). Nothing
+// here prints a slur: a word is shown as its mask.
+//
+// Plain ESM: the CLI runs under bare node.
+import { isNarrated, pickedTake, rootTakeOf } from "umtool-report-to-video/post-narration";
+import { SLURS_DEFAULTS, SLUR_LEVELS, SLUR_VISUALS, SLUR_VOICES, maskOfWord, slurReport, takeBleeps } from "umtool-report-to-video/post-slurs";
+import { cutSlurs } from "umtool-report-to-video/post-redact-files";
+import { readManifest } from "../projects/report.mjs";
+import { withEditNotes } from "./edit-guard.mjs";
+import { manifestToken, updatePostSlurs } from "./manifest.mjs";
+
+export const SLURS_USAGE = [
+ " umtool posts slurs <project> [ls] | on | off | level strong|all | visual blackout|placeholder",
+ " | voice skip|beep|placeholder | add <word> | except <word> | remove <word> [--json]",
+ " THE SLUR FILTER (render.posts.slurs; on by default): every slur on the list (umtool/report-to-video/slurs.json,",
+ " strong and mild; `level strong` masks only the strong) masked in what the cut PUBLISHES -- matched whole-word,",
+ " without case, through look-alike letters and a word spelt out. visual: placeholder (default: a dark pill with",
+ " its mask, \"f*****\") or blackout (the redaction's bar); voice: beep (default: said, a tone over it by the take's",
+ " word timings), skip (left out of a synthesized read) or placeholder (its stand-in said, \"f-slur\"). A take that SAYS one (a",
+ " recording, a beep take, a take from before the filter) is silenced or beeped over it by its word timings, and",
+ " a censored build refuses one with none. `ls` counts what the cut would mask (masks only, never the word), per",
+ " slur and per post, and says which reads still need word timings. off -- or `umtool take … --uncensored` -- is",
+ " the uncensored cut; the redaction and censored attachments stay on. add/except/remove: the project's own words.",
+].join("\n");
+
+export class SlursError extends Error {
+ constructor(message) {
+ super(message);
+ this.name = "SlursError";
+ }
+}
+
+const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v);
+
+/** What a cut's filter would mask, and the state of each read that holds a slur. */
+export function slursListing(manifest) {
+ const s = cutSlurs(manifest);
+ const on = { ...s, on: true };
+ const tl = Array.isArray(manifest?.timeline) ? manifest.timeline : [];
+ const report = slurReport(tl, s);
+ const reads = [];
+ for (const e of tl) {
+ if (e?.type !== "post" || !isNarrated(e)) continue;
+ const t = pickedTake(e);
+ const root = rootTakeOf(e.narration.takes ?? [], t);
+ const state = t.slurs ?? root?.slurs ?? "said";
+ const b = takeBleeps(t, on, { state, script: t.script ?? e.narration?.script });
+ if (state !== "said") {
+ if (reportHas(report, e.id, "script")) reads.push({ id: e.id, take: t.file, state, covered: "left out of the read" });
+ continue;
+ }
+ if (!b) continue;
+ reads.push({ id: e.id, take: t.file, state, ...(b.error ? { needs: "word timings", error: b.error } : { covered: b.mode === "beep" ? "beeped" : "silenced", spans: b.spans.length }) });
+ }
+ return { slurs: s, report, reads };
+}
+
+const reportHas = (report, id, where) => report.posts.some((p) => p.id === id && p.where.includes(where));
+
+/** `umtool posts slurs <p> …` */
+export async function slursCommand(project, rest, { json = false, out = (s) => console.log(s) } = {}) {
+ const [sub = "ls", arg] = rest;
+ const write = async (change) => withEditNotes(project, async () => updatePostSlurs(project.dir, change, { token: await manifestToken(project.dir) }));
+ const said = async (change, line) => {
+ const { result } = await write(change);
+ out(json ? JSON.stringify({ ok: true, slurs: result.slurs, token: result.token }, null, 2) : `${project.id}: ${line}`);
+ return 0;
+ };
+ const one = (list, what) => {
+ if (!arg || !list.includes(arg)) throw new SlursError(`posts slurs ${sub} takes ${list.join(" or ")}${arg ? ` (not ${arg})` : ""}`);
+ return arg;
+ };
+ if (sub === "on") return said({ set: { on: null } }, "the slur filter is on (the default): the cut publishes its post items censored");
+ if (sub === "off") return said({ set: { on: false } }, "the slur filter is OFF: this is the uncensored cut (the redaction and censored attachments stay on)");
+ if (sub === "level") return said({ set: { level: one(SLUR_LEVELS) === SLURS_DEFAULTS.level ? null : arg } }, `level ${arg}: ${arg === "strong" ? "only the strong slurs are masked" : "strong and mild slurs are masked"}`);
+ if (sub === "visual") return said({ set: { visual: one(SLUR_VISUALS) === SLURS_DEFAULTS.visual ? null : arg } }, `visual ${arg}: ${arg === "blackout" ? "a solid bar, as a redacted word" : "a dark pill with the masked form"}`);
+ if (sub === "voice") return said({ set: { voice: one(SLUR_VOICES) === SLURS_DEFAULTS.voice ? null : arg } }, `voice ${arg}: ${arg === "skip" ? "left out of a synthesized read" : arg === "beep" ? "said, with a beep over it (the take's word timings)" : "its stand-in said in its place"}`);
+ if (sub === "add" || sub === "except" || sub === "remove") {
+ if (!arg || !/^[A-Za-z][A-Za-z-]{1,39}$/.test(arg)) throw new SlursError(`posts slurs ${sub} takes a word (letters, 2–40)`);
+ const what = sub === "add" ? "masked in this cut" : sub === "except" ? "never masked in this cut" : "off the project's lists";
+ return said({ [sub]: arg }, `${maskOfWord(arg.toLowerCase())} is ${what}`);
+ }
+ if (sub !== "ls") throw new SlursError(`posts slurs: ls, on, off, level, visual, voice, add, except or remove (not ${sub})`);
+ const manifest = await readManifest(project.dir);
+ if (!manifest) throw new SlursError(`${project.id} has no manifest`);
+ const { slurs: s, report, reads } = slursListing(manifest);
+ const cfg = isObj(manifest.render?.posts?.slurs) ? manifest.render.posts.slurs : {};
+ if (json) {
+ out(JSON.stringify({ ok: true, on: s.on, level: s.level, visual: s.visual, voice: s.voice, listed: s.entries.length, add: (cfg.add ?? []).length, except: (cfg.except ?? []).length, total: report.total, bySlur: report.bySlur, posts: report.posts, reads }, null, 2));
+ return 0;
+ }
+ out(
+ `${project.id}: the slur filter is ${s.on ? "ON" : "OFF (the uncensored cut)"} -- level ${s.level}, visual ${s.visual}, voice ${s.voice}` +
+ ` (${s.entries.length} slur(s) listed${cfg.add?.length ? `, ${cfg.add.length} of its own` : ""}${cfg.except?.length ? `, ${cfg.except.length} excepted` : ""})`,
+ );
+ if (!report.total) {
+ out(" no post item of the cut holds a slur on the list");
+ return 0;
+ }
+ out(` it ${s.on ? "masks" : "would mask"} ${report.total} word(s) in ${report.posts.length} post item(s):`);
+ const rows = Object.entries(report.bySlur).sort((a, b) => b[1].n - a[1].n);
+ // A project's own word is named by its mask alone (its id would spell it).
+ for (const [id, b] of rows) out(` ${b.mask.padEnd(10)} ${(b.added ? "(its own)" : id).padEnd(18)} ×${String(b.n).padEnd(4)} in ${b.posts.length} post(s): ${b.posts.slice(0, 8).join(", ")}${b.posts.length > 8 ? ", …" : ""}`);
+ out(" per post item:");
+ for (const p of report.posts) out(` ${p.id.padEnd(22)} ${Object.entries(p.hits).map(([id, n]) => `${report.bySlur[id]?.mask ?? id} ×${n}`).join(", ")} (${p.where.join(", ")})`);
+ if (reads.length) {
+ const need = reads.filter((r) => r.needs);
+ out(` the reads: ${reads.length} narrated post(s) hold a slur in their read -- ${reads.filter((r) => r.covered).length} covered, ${need.length} need word timings`);
+ for (const r of reads) out(` ${r.id.padEnd(22)} ${r.needs ? `NEEDS WORD TIMINGS (a censored build refuses it): umtool posts narrate ${project.id} ${r.id} --words` : `${r.covered}${r.spans ? ` (${r.spans} span(s))` : ""}`}`);
+ }
+ return 0;
+}
diff --git a/umtool/lib/report/postsCli.mjs b/umtool/lib/report/postsCli.mjs
@@ -36,6 +36,15 @@ import { withEditNotes } from "./edit-guard.mjs";
import { PostsRefused, StaleToken, StructureRefused, addArchiveAvatars, manifestToken, setPostAvatar, updatePostItem, updatePostRedact, updatePosts, upsertPost } from "./manifest.mjs";
import { postWarnings } from "./postCards.mjs";
+// `umtool posts slurs` (postSlursCli.mjs SLURS_USAGE): its lines, kept here so the usage is one block.
+const SLURS_USAGE_LINES = [
+ " umtool posts slurs <project> [ls] | on | off | level strong|all | visual blackout|placeholder",
+ " | voice skip|beep|placeholder | add <word> | except <word> | remove <word> [--json]",
+ " THE SLUR FILTER (render.posts.slurs, on by default): the list's slurs masked in what the cut publishes (a bar or",
+ " a placeholder pill on the card; left out, beeped or a stand-in in the read); `ls` counts what it masks (masks",
+ " only), off or `umtool take … --uncensored` is the uncensored cut. umtool posts slurs --help: the whole story.",
+];
+
export const POSTS_USAGE = [
"usage: umtool posts add <project> <archive-channel>/<postId> [--attach <clipId>] [--flag F] [--author A] [--id ID]",
" [--thread] [--crop <px>] [--dry-run] [--json]",
@@ -87,6 +96,7 @@ export const POSTS_USAGE = [
" as whole words (--substring: inside words too), a phrase across any spaces or punctuation. The posts' words are",
" never rewritten; Play's \"As published\" shows the bars. `ls` lists the project's terms (n as `remove` takes it)",
" and counts the corpus's (transcripts/redactions.json, channels/<slug>/posts-markup.json).",
+ ...SLURS_USAGE_LINES,
" umtool posts context <project> [--dry-run] [--json]",
" every post item's CONTEXT from its capture (capture.json's `context`: the post it quotes, the post it answers, as",
" its page showed them) where the archive row lacks it -- one write (one undo point). A post whose capture read",
@@ -397,6 +407,17 @@ export async function postsCommand(args, { root = REPORTS_ROOT, out = (s) => con
return await fitCommand(await projectOf(projectArg, root), words.slice(2), { all: flags.has("--all"), linger, json, dryRun, out });
}
if (verb === "redact" && projectArg && !flags.has("--help")) return await redactCommand(projectArg, words.slice(2), { root, json, out, flags, str });
+ if (verb === "slurs") {
+ // The slur filter (postSlursCli.mjs): its own words refused as a usage error.
+ const { SLURS_USAGE, slursCommand } = await import("./postSlursCli.mjs");
+ if (!projectArg || flags.has("--help")) {
+ err(SLURS_USAGE);
+ return 2;
+ }
+ return await slursCommand(await projectOf(projectArg, root), words.slice(2), { json, out }).catch((e) => {
+ throw e?.name === "SlursError" ? new CliError(e.message) : e;
+ });
+ }
if (verb === "avatar" && projectArg && !flags.has("--help")) return await avatarCommand(projectArg, words.slice(2), { root, json, out });
if (verb === "avatars" && projectArg && !flags.has("--help")) return await avatarsCommand(projectArg, { root, json, dryRun, out });
if (verb === "context" && projectArg && !flags.has("--help")) return await contextCommand(projectArg, { root, json, dryRun, out });
diff --git a/umtool/lib/report/takeCli.mjs b/umtool/lib/report/takeCli.mjs
@@ -42,7 +42,7 @@ export const TAKE_USAGE = [
"usage: umtool take <project> --id <id> --label \"<label>\" [--group G] [--kind similar|different]",
" [--summary S] [--style NAME] [--patch FILE | --patch-json JSON | --set path=value …]",
" [--effect NAME] [--at S --dur S | --full] [--quick] [--force] [--progress ndjson]",
- " [--from TAKE] [--keep-frames] [--priority]",
+ " [--from TAKE] [--keep-frames] [--priority] [--uncensored]",
" umtool take <project> --id <id> --rebuild [--at S --dur S | --full] [--from TAKE] [--keep-frames] [--priority]",
" made again from its own take.json (its stored patch, walked edits included); a window",
" flag renders it over that window instead of its own",
@@ -71,6 +71,10 @@ export const TAKE_USAGE = [
"and download lanes are held (only the ones not held already), and both end with the take — done,",
"failed or stopped. Close Firefox and other heavy apps while it renders. A take started inside a",
"`umtool render-mode on` window renders in that window, flag or not.",
+ "--uncensored renders the UNCENSORED cut: the post items' slur filter off (render.posts.slurs.on false in the",
+ "take's patch, so a --rebuild keeps it; post-slurs.mjs) -- the slurs drawn and played as posted. The redaction",
+ "of private words and a censored attachment stay on. Its label says \"(uncensored)\" and take.json's `slurs`",
+ "records which cut it is (censored | uncensored).",
].join("\n");
export const TAKES_USAGE = [
@@ -104,6 +108,9 @@ export const TAKES_USAGE = [
class CliError extends Error {}
+/** A take's patch for the uncensored cut: the slur filter off (post-slurs.mjs). */
+export const UNCENSORED_PATCH = Object.freeze({ render: { posts: { slurs: { on: false } } } });
+
/** The flags of one command line. */
function parse(args) {
const valued = new Set([
@@ -244,6 +251,7 @@ export async function takeCommand(args, { reportsRoot = REPORTS_ROOT, log = cons
let spec;
if (fromStored) {
if (!prev) throw new CliError(`${project.id} has no take ${id} to rebuild`);
+ if (p.has("--uncensored") && prev.patch?.render?.posts?.slurs?.on !== false) throw new CliError(`${id} was made censored: --uncensored makes a take of its own (a new --id), not a rebuild of this one`);
spec = {
id,
label: p.one("--label") ?? prev.label,
@@ -269,6 +277,11 @@ export async function takeCommand(args, { reportsRoot = REPORTS_ROOT, log = cons
quick: p.has("--quick"),
};
}
+ // THE UNCENSORED CUT (post-slurs.mjs): the slur filter off in the take's own patch; the redaction stays.
+ if (p.has("--uncensored") && !fromStored) {
+ spec.patch = mergePatch(spec.patch ?? {}, UNCENSORED_PATCH);
+ if (spec.label && !/uncensored/i.test(spec.label)) spec.label = `${spec.label} (uncensored)`;
+ }
if (draft) {
const d = await draftTake(project.dir, spec, { force: p.has("--force"), ...(deps?.styles ? { styles: /** @type {any} */ (deps.styles) } : {}) });
if (p.has("--json")) {
diff --git a/umtool/lib/report/takeMaker.mjs b/umtool/lib/report/takeMaker.mjs
@@ -49,6 +49,7 @@ import path from "node:path";
import { pathToFileURL } from "node:url";
import { mergePatch } from "umtool-report-to-video/montage-styles";
import { postItemSeconds } from "umtool-report-to-video/post-item";
+import { cutSlurState } from "umtool-report-to-video/post-slurs";
import { applyMontageRulings, readMontageRulings, rulingsLines } from "umtool-report-to-video/montage-rulings";
import { markKeepFrames } from "umtool-report-to-video/prune-frames";
import { PIPELINE_DIR, RENDER_BUDGET, UMTOOL_DIR } from "./driver.mjs";
@@ -739,6 +740,8 @@ async function makeTakeLocked(projectDir, rawSpec, opts) {
...(opts.from ? { from: opts.from } : {}),
// The render's own time, for the next take's ETA (takeEta.mjs).
renderSeconds,
+ // Which cut its post items are (post-slurs.mjs): censored, or the uncensored one (`umtool take … --uncensored`).
+ ...(cutSlurState(manifest) ? { slurs: cutSlurState(manifest) } : {}),
};
const tmp = `${takeFile}.tmp-${process.pid}`;
await writeFile(tmp, JSON.stringify(doc, null, 2) + "\n", "utf8");
diff --git a/umtool/report-to-video/build-video.mjs b/umtool/report-to-video/build-video.mjs
@@ -66,6 +66,10 @@
// --narration-unreviewed Build narrated cards the narration review has not
// approved (unreviewed, or edited since); a rejected one
// still refuses. Without a review file nothing is held.
+// --uncensored The post items' SLUR FILTER off (post-slurs.mjs,
+// render.posts.slurs): their slurs drawn and played as
+// posted. The redaction and a censored attachment stay on.
+// A take does it with its patch (umtool take … --uncensored).
// --final The deliverable (the driver's `final` preset passes it):
// every DRAFTED field (drafts-review.mjs) must be approved
// on its current value -- unapproved or rejected refuses.
@@ -6153,7 +6157,12 @@ export async function buildVideo({ manifestPath, opts = {}, out, only, fetchOnly
});
FX_CHANNELS_DIR = channelsDir;
// Read only for a cut that plays post items: a cut without them publishes nothing it could blank.
- POST_REDACTION = (manifest.timeline ?? []).some((e) => e?.type === "post") ? await readPostRedaction(channelsDir, manifest) : null;
+ POST_REDACTION = (manifest.timeline ?? []).some((e) => e?.type === "post") ? await readPostRedaction(channelsDir, manifest, { uncensored: opts.uncensored === true }) : null;
+ // Which cut this is (post-slurs.mjs): censored, or the uncensored one.
+ if (POST_REDACTION?.slurs) {
+ const sl = POST_REDACTION.slurs;
+ EMIT("note", { message: sl.on ? `slur filter: on (level ${sl.level}, visual ${sl.visual}, voice ${sl.voice})` : `slur filter: OFF -- the uncensored cut${sl.uncensored ? " (--uncensored)" : " (render.posts.slurs.on false)"}; the redaction stays on` });
+ }
// Speaker captions read the project's reactions.json and words beside the
// manifest (readLookSources); a short is framed by its clip's crop.
if (captionsOn(render)) dirs.look = await readLookSources(manifestDir);
@@ -7077,6 +7086,7 @@ async function main() {
" [--lint] [--no-lint] (lint the manifest and stop / build without the lint)\n" +
" [--no-rulings] (build as if there were no montage-rulings.json beside the manifest)\n" +
" [--narration-unreviewed] (build narrated cards the review has not approved; never a rejected one)\n" +
+ " [--uncensored] (the post items' slur filter off, render.posts.slurs; the redaction and the censored attachments stay)\n" +
" [--final] [--drafts-unreviewed] (the deliverable: drafted fields must be approved / build the unapproved anyway)\n" +
" [--site-origin <url>] [--resolve-site-ids] [--cue-source auto|local|http]\n" +
" [--thumbnail] (render.brand only: out/<slug>.thumbnail.png and stop)",
@@ -7116,6 +7126,7 @@ async function main() {
noLint: argv.includes("--no-lint"),
noRulings: argv.includes("--no-rulings"),
narrationUnreviewed: argv.includes("--narration-unreviewed"),
+ uncensored: argv.includes("--uncensored"),
final: argv.includes("--final"),
draftsUnreviewed: argv.includes("--drafts-unreviewed"),
short: flag("--short") ?? null,
diff --git a/umtool/report-to-video/package.json b/umtool/report-to-video/package.json
@@ -69,6 +69,7 @@
"./post-censor": "./post-censor.mjs",
"./post-redact": "./post-redact.mjs",
"./post-redact-files": "./post-redact-files.mjs",
+ "./post-slurs": "./post-slurs.mjs",
"./post-render": "./post-render.mjs",
"./word-zoom": "./word-zoom.mjs",
"./read-follow": "./read-follow.mjs",
diff --git a/umtool/report-to-video/post-narration.mjs b/umtool/report-to-video/post-narration.mjs
@@ -166,7 +166,7 @@ const MIX_KEYS = ["lead", "tail", "ramp", "linger", "clip", "wet", "lowpassHz",
// `follow`: the cut's read-follow (read-follow.mjs) -- { on, dim, ease } -- kept here with the mix it rides on.
const RENDER_KEYS = new Set([...MIX_KEYS.filter((k) => k !== "attach"), "engine", "voice", "follow"]);
const ITEM_KEYS = new Set([...MIX_KEYS, "script", "excerpt", "engine", "voice", "speed", "takes", "pick", "approved", "off", "window"]);
-const TAKE_KEYS = new Set(["file", "engine", "voice", "seconds", "script", "at", "note", "speed", "lufs", "jobId", "parts", "label", "source", "steps", "words"]);
+const TAKE_KEYS = new Set(["file", "engine", "voice", "seconds", "script", "at", "note", "speed", "lufs", "jobId", "parts", "label", "source", "steps", "words", "slurs"]);
const STEP_KEYS = new Set(["op", "engine", "voice", "params", "ranAt", "job"]);
const PART_KEYS = new Set(["n", "para", "text", "file", "start", "seconds", "gapBefore", "note", "at", "jobId"]);
const VOICE_RE = /^[A-Za-z0-9][A-Za-z0-9_.+-]{0,63}$/;
@@ -528,6 +528,8 @@ export function validatePostNarration(e) {
);
if (!ok) errors.push(`${tw}.source must be {kind: "tts", engine, voice}, {kind: "recorded", voice} or {kind: "take", from: <one of its takes' id>}`);
}
+ // What its audio does with the slurs its script holds (post-slurs.mjs): said (a beep or a mute covers them), left out, or a stand-in said.
+ if (t.slurs !== undefined && !["said", "skip", "placeholder"].includes(t.slurs)) errors.push(`${tw}.slurs must be said, skip or placeholder`);
if (t.words !== undefined) {
// Its script's words, timed in take seconds (the editor's transcription, aligned: word-zoom.mjs scriptWordTimes).
const ws = t.words;
diff --git a/umtool/report-to-video/post-redact-files.mjs b/umtool/report-to-video/post-redact-files.mjs
@@ -1,5 +1,6 @@
// THE REDACTION A BUILD PUBLISHES WITH (post-redact.mjs): the corpus's terms,
-// each post's channel markup and the project's own list, read together. Read
+// each post's channel markup and the project's own list, read together, and
+// the cut's slur filter. Read
// only -- the corpus's two files are the editor's to write.
//
// <transcripts>/redactions.json [{ term, wholeWord?, note? }] (or { terms: […] })
@@ -8,9 +9,40 @@
// A file that is there and does not parse, or is refused by its validator,
// FAILS the read: a public render that silently ignored its redaction would
// publish what it was told to blank. A file that is not there is nothing.
+//
+// And the SLUR FILTER (post-slurs.mjs): the default list shipped beside this
+// module (slurs.json) under the project's `render.posts.slurs` -- off for an
+// uncensored cut (`{ uncensored: true }`: build-video's --uncensored, Play's
+// Uncensored), the redaction itself untouched by it.
+import { readFileSync } from "node:fs";
import { readFile } from "node:fs/promises";
import path from "node:path";
+import { fileURLToPath } from "node:url";
import { normalizeTerms, projectRedactOf, validatePostsMarkup, validateRedactTerms } from "./post-redact.mjs";
+import { resolveSlurs, slurListErrors } from "./post-slurs.mjs";
+
+const HERE = path.dirname(/* turbopackIgnore: true */ fileURLToPath(import.meta.url));
+/** The slur filter's default list. */
+export const SLURS_FILE = path.join(/* turbopackIgnore: true */ HERE, "slurs.json");
+let SLUR_LIST = null;
+
+/** The default slur list (slurs.json), read once; a list that does not parse or is refused FAILS (a public render does not run without its filter). */
+export function defaultSlurList() {
+ if (SLUR_LIST) return SLUR_LIST;
+ let doc;
+ try {
+ doc = JSON.parse(readFileSync(/* turbopackIgnore: true */ SLURS_FILE, "utf8"));
+ } catch (e) {
+ throw new Error(`${SLURS_FILE} does not read (${e instanceof Error ? e.message : e}) -- a public render does not run without its slur filter`);
+ }
+ const errors = slurListErrors(doc);
+ if (errors.length) throw new Error(`${SLURS_FILE} is refused: ${errors.join("; ")}`);
+ SLUR_LIST = doc;
+ return doc;
+}
+
+/** The cut's slur filter: its `render.posts.slurs` over the default list. */
+export const cutSlurs = (manifest, { uncensored = false } = {}) => resolveSlurs(manifest?.render?.posts?.slurs, defaultSlurList(), { uncensored });
export const CORPUS_REDACTIONS_FILE = "redactions.json";
export const POSTS_MARKUP_FILE = "posts-markup.json";
@@ -41,10 +73,12 @@ async function readJson(file) {
*
* @param {string|null} channelsDir
* @param {Record<string, any>} manifest
+ * @param {{ uncensored?: boolean }} [o] the slur filter off (the redaction kept)
*/
-export async function readPostRedaction(channelsDir, manifest) {
+export async function readPostRedaction(channelsDir, manifest, { uncensored = false } = {}) {
const project = projectRedactOf(manifest?.render);
const terms = [];
+ /** @type {Record<string, any>} */
const markup = {};
if (channelsDir) {
const file = corpusRedactionsPath(channelsDir);
@@ -67,5 +101,5 @@ export async function readPostRedaction(channelsDir, manifest) {
}
}
terms.push(...normalizeTerms(project));
- return { terms, markup };
+ return { terms, markup, slurs: cutSlurs(manifest, { uncensored }) };
}
diff --git a/umtool/report-to-video/post-redact.mjs b/umtool/report-to-video/post-redact.mjs
@@ -29,6 +29,7 @@
//
// PURE (the build, the route, Play and the writers).
import { censorMarkupErrors } from "./post-censor.mjs";
+import { BLACKOUT_MARK, SLUR_CSS, decodePlaceholder, hasSlurMarks, maskSlurs, placeholdersHtml, sayFor, slurMatches, slursOn, validateSlursRender } from "./post-slurs.mjs";
/** The mark a redacted code unit becomes (a private-use character: never typed, never drawn as a letter). */
export const REDACT_MARK = "";
@@ -110,8 +111,8 @@ export function redactText(text, terms, { spans: extra = [] } = {}) {
return { text: out + s.slice(at), spans: merged.map(([start, end]) => ({ start, end })) };
}
-/** Does `text` hold a redacted match? */
-export const hasMarks = (text) => str(text).includes(REDACT_MARK);
+/** Does `text` hold a redacted match (or a masked slur, post-slurs.mjs)? */
+export const hasMarks = (text) => str(text).includes(REDACT_MARK) || hasSlurMarks(text);
/**
* Marked text with the marks DROPPED, as a read or a line of text says it:
@@ -120,8 +121,10 @@ export const hasMarks = (text) => str(text).includes(REDACT_MARK);
* at a sentence's start -- taken away. Only around a mark; the rest verbatim.
*/
export function dropMarks(marked) {
+ // A masked slur (post-slurs.mjs): its placeholder read as its mask, the gaps of one spelt apart gone.
+ const unmasked = decodePlaceholder(str(marked).replace(/[ \t]*\uE0FF/g, ""));
// A phrase's marks with its spaces between them are one run to drop.
- const parts = str(marked).split(/\uE000(?:[\s\uE000]*\uE000)?/);
+ const parts = unmasked.split(/\uE000(?:[\s\uE000]*\uE000)?/);
if (parts.length === 1) return parts[0];
let out = parts[0];
for (let i = 1; i < parts.length; i += 1) {
@@ -150,10 +153,10 @@ export const barEm = (n) => Math.round(n * 0.52 * 100) / 100;
/** HTML (already escaped) with each run of marks drawn as a solid bar of its width -- no letters inside. */
export const barsHtml = (html) =>
- str(html).replace(MARKS_RE, (m) => `<span class="rbar" data-post-blanked="" style="width:${barEm(m.length)}em"></span>`);
+ placeholdersHtml(str(html)).replace(MARKS_RE, (m) => `<span class="rbar" data-post-blanked="" style="width:${barEm(m.length)}em"></span>`);
/** The bar's CSS, for a page that draws them. */
-export const BAR_CSS = (fg) => `.rbar { display: inline-block; height: 0.92em; vertical-align: -0.12em; background: ${fg}; border-radius: 0.12em; }`;
+export const BAR_CSS = (fg) => `.rbar { display: inline-block; height: 0.92em; vertical-align: -0.12em; background: ${fg}; border-radius: 0.12em; }\n${SLUR_CSS(fg)}`;
// ---------------------------------------------------------------------------
// The project's list and a post's markup.
@@ -184,8 +187,8 @@ export function validateRedactTerms(list, where = "render.posts.redact") {
export function validatePostsRender(render) {
const p = render?.posts;
if (p === undefined) return [];
- if (!isObj(p)) return ["render.posts must be an object ({redact})"];
- return validateRedactTerms(p.redact);
+ if (!isObj(p)) return ["render.posts must be an object ({redact, slurs})"];
+ return [...validateRedactTerms(p.redact), ...validateSlursRender(p.slurs)];
}
/** Every reason a channel's posts-markup.json is refused. */
@@ -221,11 +224,13 @@ export function validatePostsMarkup(doc, where = "posts-markup.json") {
* that applies everywhere (the corpus's and the project's) and each post's
* markup by `<channel>/<postId>` (the entry's `post`).
*
- * @typedef {{ terms: Array<{term: string, wholeWord?: boolean}>, markup?: Record<string, {redact: any[]}> }} Redaction
+ * and `slurs`, the cut's SLUR FILTER (post-slurs.mjs resolveSlurs: its list, on or off).
+ *
+ * @typedef {{ terms: Array<{term: string, wholeWord?: boolean}>, markup?: Record<string, {redact: any[]}>, slurs?: ReturnType<typeof import("./post-slurs.mjs").resolveSlurs> | null }} Redaction
*/
/** Is there anything to blank? */
-export const redactionOn = (red) => !!red && (normalizeTerms(red.terms).length > 0 || Object.keys(red.markup ?? {}).length > 0);
+export const redactionOn = (red) => !!red && (normalizeTerms(red.terms).length > 0 || Object.keys(red.markup ?? {}).length > 0 || slursOn(red.slurs));
/** The terms that apply to post item `entry` in `scope` (everywhere, then its markup's). */
export function termsFor(entry, red, scope = null) {
@@ -271,5 +276,77 @@ export function redactEntry(entry, red) {
if (isObj(entry.repostedBy)) out.repostedBy = { ...entry.repostedBy, author: mark(entry.repostedBy.author, all), handle: mark(entry.repostedBy.handle, all) };
if (Array.isArray(entry.parents)) out.parents = entry.parents.map((p, i) => ref(p, "parent", i));
if (isObj(entry.quoted)) out.quoted = ref(entry.quoted, "quoted");
+ return slurEntry(out, red?.slurs);
+}
+
+/**
+ * A post item's words with every SLUR masked (post-slurs.mjs maskSlurs) as
+ * the filter's `visual` draws them: its words, its author's name, the repost
+ * line's, the posts it answers and quotes (their words, a paraphrase, their
+ * names). Handles are left as they are (they are what the card's rules match
+ * on). A copy; the entry itself when the filter is off.
+ */
+export function slurEntry(entry, slurs) {
+ if (!slursOn(slurs) || !isObj(entry)) return entry;
+ const m = (v) => (typeof v === "string" ? maskSlurs(v, slurs).text : v);
+ const ref = (r) => (isObj(r) ? { ...r, ...("author" in r ? { author: m(r.author) } : {}), ...("text" in r ? { text: m(r.text) } : {}), ...("paraphrase" in r ? { paraphrase: m(r.paraphrase) } : {}) } : r);
+ const out = { ...entry, text: m(entry.text) };
+ if ("author" in out) out.author = m(out.author);
+ if (isObj(entry.repostedBy)) out.repostedBy = { ...entry.repostedBy, author: m(entry.repostedBy.author) };
+ if (Array.isArray(entry.parents)) out.parents = entry.parents.map(ref);
+ if (isObj(entry.quoted)) out.quoted = ref(entry.quoted);
return out;
}
+
+// ---------------------------------------------------------------------------
+// What is SAID and what a line of text SHOWS, the redaction and the slur filter together.
+// ---------------------------------------------------------------------------
+
+/**
+ * The words a voice is asked to SAY for `text` (a post item's script): every
+ * redacted term left out, and each slur as the filter's voice has it -- skip,
+ * left out as a redacted term is; placeholder, its stand-in said ("f-slur");
+ * beep, said (the render lays the beep over it by the take's word timings,
+ * post-render.mjs). Returns `{ text, slurs }`: `slurs` is what the take's
+ * audio will do with them (take.slurs: "said" | "skip" | "placeholder"), null
+ * when the text holds none.
+ *
+ * @param {string} text
+ * @param {Record<string, any>} entry
+ * @param {Redaction|null|undefined} red
+ * @param {{ voice?: "skip"|"beep"|"placeholder" }} [o] the voice to use (default the filter's)
+ */
+export function spokenRead(text, entry, red, { voice = undefined } = {}) {
+ const s = red?.slurs;
+ const terms = termsFor(entry, red);
+ const t = str(text);
+ const hits = s ? slurMatches(t, s) : [];
+ if (!hits.length) return { text: spokenWithout(t, terms), slurs: null };
+ const v = voice ?? s.voice;
+ if (!slursOn(s) || v === "beep") return { text: spokenWithout(t, terms), slurs: "said" };
+ if (v === "placeholder") {
+ let said = "";
+ let at = 0;
+ for (const h of hits) {
+ said += t.slice(at, h.start) + sayFor(s, h);
+ at = h.end;
+ }
+ return { text: spokenWithout(said + t.slice(at), terms), slurs: "placeholder" };
+ }
+ const marked = redactText(t, terms, { spans: hits });
+ return { text: marked.spans.length ? dropMarks(marked.text) : t, slurs: "skip" };
+}
+
+/**
+ * A line of text as published (an attachment's burnt-in caption): a
+ * redacted term left out; a slur, blacked out, left out too, or drawn as its
+ * mask (placeholder).
+ */
+export function shownLine(text, entry, red) {
+ const r = redactText(text, termsFor(entry, red));
+ const masked = slursOn(red?.slurs) ? maskSlurs(r.text, red.slurs).text : r.text;
+ return masked === str(text) ? str(text) : dropMarks(masked);
+}
+
+/** The redaction's mark is the blackout's (post-slurs.mjs draws a blacked-out slur with the redaction's bar). */
+export const MARKS_AGREE = BLACKOUT_MARK === REDACT_MARK;
diff --git a/umtool/report-to-video/post-render.mjs b/umtool/report-to-video/post-render.mjs
@@ -19,9 +19,10 @@ import { mkdir, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
import path from "node:path";
import { pathToFileURL } from "node:url";
import { POST_PICTURE_XFADE, POST_PUSH, fxRedactionErrors, postCardHtml, postItemPlan, postLayout, stepBoxes } from "./post-item.mjs";
-import { isNarrated, narrationLevelDb, pickedTake, postNarrationFilters } from "./post-narration.mjs";
+import { isNarrated, narrationLevelDb, pickedTake, postNarrationFilters, rootTakeOf } from "./post-narration.mjs";
import { applyFollowState, followPath, followStateAt, followStateKey, measureFollow } from "./read-follow.mjs";
-import { redactEntry, redactionOn, spokenWithout, termsFor } from "./post-redact.mjs";
+import { redactEntry, redactionOn, shownLine, termsFor } from "./post-redact.mjs";
+import { bleepFilters, slursOn, takeBleeps } from "./post-slurs.mjs";
import { blurFilters, blurOn, censorEntry, labelFilter } from "./post-censor.mjs";
import { WORD_ZOOM_DEFAULTS, findMatch, overlappingZooms, resolveWordZoom, targetScope, targetTextOf, wordZoomTimes, zoomSpan, zoomTarget, zoompanExprs } from "./word-zoom.mjs";
@@ -202,7 +203,10 @@ export function postSegmentArgs({ entry, box, plan, layout, cards, files, render
} else parts.push(`[${sil}:a]anull[${media}]`);
if (media === "pm") {
const vi = add(["-i", narration.file]);
- parts.push(...postNarrationFilters({ media: "pm", voice: `${vi}:a`, out: "a", sch: plan.narration, gainDb: narration.gainDb ?? 0, audioRate: render.audioRate ?? 48000 }));
+ // A take that says a slur the cut masks (post-slurs.mjs takeBleeps): silenced or beeped over it, on the take's own clock.
+ const bl = narration.bleeps?.spans?.length ? bleepFilters(`${vi}:a`, "pnbl", narration.bleeps, { audioRate: render.audioRate ?? 48000, seconds: narration.bleeps.seconds ?? 600 }) : [];
+ parts.push(...bl);
+ parts.push(...postNarrationFilters({ media: "pm", voice: bl.length ? "pnbl" : `${vi}:a`, out: "a", sch: plan.narration, gainDb: narration.gainDb ?? 0, audioRate: render.audioRate ?? 48000 }));
}
return [
"-nostdin", "-v", "error", "-y",
@@ -454,13 +458,15 @@ export async function buildPostSegment(entry, { render, outDir, manifestDir, box
const take = isNarrated(entry) ? pickedTake(entry) : null;
const takeFile = take ? path.resolve(manifestDir, take.file) : null;
if (takeFile && !(await stat(takeFile).catch(() => null))) throw new Error(`${entry.id}: its narration take is not on disk: ${takeFile} (${take.file})`);
+ // The slurs its take SAYS, covered (post-slurs.mjs): a public render never plays one -- without word timings it is refused.
+ const bleeps = take ? takeSlurBleeps(entry, take, redaction) : null;
const stamps = await Promise.all([...files, ...wordFiles.filter(Boolean), ...Object.values(avatars), ...(takeFile ? [takeFile] : []), ...(entry.parentShot ? [path.resolve(manifestDir, entry.parentShot)] : [])].map(async (f) => {
const st = await stat(f).catch(() => null);
return st ? `${f}:${st.size}:${Math.round(st.mtimeMs)}` : `${f}:-`;
}));
const key = createHash("sha256")
// A redaction that changes what the card draws changes the key; none leaves it as it was.
- .update(JSON.stringify({ v: 1, entry, ...(redactionOn(redaction) ? { published: redactEntry(entry, redaction), blank: termsFor(entry, redaction) } : {}), box, place, palette: render.palette, fonts: [render.fontRegular, render.fontBold], fps: render.fps, encode, stamps, ...(Object.keys(avatars).length ? { avatars } : {}), ...(take ? { narration: plan.narration, postNarration: render.postNarration ?? null } : {}), ...(plan.follow ? { follow: plan.follow } : {}) }))
+ .update(JSON.stringify({ v: 1, entry, ...(redactionOn(redaction) ? { published: redactEntry(entry, redaction), blank: termsFor(entry, redaction) } : {}), box, place, palette: render.palette, fonts: [render.fontRegular, render.fontBold], fps: render.fps, encode, stamps, ...(Object.keys(avatars).length ? { avatars } : {}), ...(take ? { narration: plan.narration, postNarration: render.postNarration ?? null } : {}), ...(plan.follow ? { follow: plan.follow } : {}), ...(bleeps ? { bleeps } : {}), ...(slursOn(redaction?.slurs) ? { slurs: redaction.slurs } : {}) }))
.digest("hex");
const record = postRecordPath(seg);
const had = await readFile(record, "utf8").then((t) => JSON.parse(t), () => null);
@@ -480,8 +486,8 @@ export async function buildPostSegment(entry, { render, outDir, manifestDir, box
const wf = wordFiles[m.i];
if (!wf) continue;
for (const [ci, c0] of stepCaptions(step, await readMediaCues(wf)).entries()) {
- // A redacted term is left out of the burnt-in words, as it is left out of a read.
- const c = { ...c0, text: spokenWithout(c0.text, termsFor(entry, redaction)) };
+ // A redacted term is left out of the burnt-in words, as it is left out of a read; a slur masked (post-slurs.mjs).
+ const c = { ...c0, text: shownLine(c0.text, entry, redaction) };
if (!c.text.trim()) continue;
const textfile = path.join(cardDir, `cue-${si}-${ci}.txt`);
await writeFile(textfile, c.text, "utf8");
@@ -492,7 +498,7 @@ export async function buildPostSegment(entry, { render, outDir, manifestDir, box
let narration = null;
if (take) {
const lufs = Number.isFinite(take.lufs) ? take.lufs : await measureLufsOf(takeFile, { exec, ffmpeg });
- narration = { file: takeFile, gainDb: narrationLevelDb(lufs, plan.narration.lufs), lufs };
+ narration = { file: takeFile, gainDb: narrationLevelDb(lufs, plan.narration.lufs), lufs, ...(bleeps ? { bleeps } : {}) };
}
const argv = postSegmentArgs({ entry, box, plan, layout, cards, files, render, place, encode, captions, fontfile: render.fontBold ?? render.fontRegular ?? null, outPath: tmp, narration, zooms, follow: cards.follow ?? null });
try {
@@ -504,7 +510,7 @@ export async function buildPostSegment(entry, { render, outDir, manifestDir, box
await rename(tmp, seg);
// The follow frames are in the segment now: a rebuild shoots them again (they are many, and the key decides).
if (cards.follow) await rm(path.dirname(cards.follow.list), { recursive: true, force: true });
- await writeFile(record, JSON.stringify({ version: 1, id: entry.id, key, layout: layout.mode, total: plan.total, steps: plan.steps.length, ...(zooms.length ? { zooms: zooms.map((z) => ({ i: z.i, at: z.t, source: z.source, span: z.span, region: z.region, word: z.word })) } : {}), ...(narration ? { narration: { take: take.file, ...plan.narration, gainDb: narration.gainDb, measured: narration.lufs } } : {}), ...(cards.follow ? { follow: { blocks: plan.follow.blocks.length, shots: cards.follow.shots, frames: cards.follow.frames, pan: cards.follow.path.segments.length, max: cards.follow.path.max } } : {}) }, null, 2) + "\n", "utf8");
+ await writeFile(record, JSON.stringify({ version: 1, id: entry.id, key, layout: layout.mode, total: plan.total, steps: plan.steps.length, ...(zooms.length ? { zooms: zooms.map((z) => ({ i: z.i, at: z.t, source: z.source, span: z.span, region: z.region, word: z.word })) } : {}), ...(narration ? { narration: { take: take.file, ...plan.narration, gainDb: narration.gainDb, measured: narration.lufs, ...(bleeps ? { slurs: { mode: bleeps.mode, spans: bleeps.spans } } : {}) } } : {}), ...(cards.follow ? { follow: { blocks: plan.follow.blocks.length, shots: cards.follow.shots, frames: cards.follow.frames, pan: cards.follow.path.segments.length, max: cards.follow.path.max } } : {}) }, null, 2) + "\n", "utf8");
emit("note", {
message: narration
? `${entry.id}: post item ${plan.total.toFixed(1)} s, narrated (${take.file}: ${plan.narration.seconds.toFixed(1)} s from ${plan.narration.at} s, muffled to ${plan.narration.voiceEnd.toFixed(1)} s)`
@@ -515,6 +521,27 @@ export async function buildPostSegment(entry, { render, outDir, manifestDir, box
return seg;
}
+/**
+ * The slurs post item `entry`'s take says that the cut masks, as its bleeps
+ * (`{ mode, spans, seconds }`, post-slurs.mjs takeBleeps), or null. Its
+ * audio's state is its own `slurs`, else its source take's (a derived take
+ * reads what its source read). Throws, in the build's words, when the take
+ * says one it has no word timings to find.
+ */
+export function takeSlurBleeps(entry, take, redaction) {
+ const takes = Array.isArray(entry?.narration?.takes) ? entry.narration.takes : [];
+ const root = rootTakeOf(takes, take);
+ // The script it read: its own, else the post's (a take from before takes kept theirs).
+ const b = takeBleeps(take, redaction?.slurs, { state: take.slurs ?? root?.slurs ?? null, script: typeof take.script === "string" ? take.script : String(entry?.narration?.script ?? "") });
+ if (b?.error) {
+ throw new Error(
+ `${entry.id}: ${b.error} -- a published cut never plays a slur: time its words (umtool posts narrate <p> ${entry.id} --words), ` +
+ `synthesize a take without it (umtool posts narrate <p> ${entry.id} --take; the filter's voice skip or placeholder), or render the uncensored cut (--uncensored)`,
+ );
+ }
+ return b ? { ...b, seconds: take.seconds } : null;
+}
+
/** A sound's integrated loudness (EBU R128, LUFS) by ffmpeg's ebur128 through `exec`; null when silent or unread. */
export async function measureLufsOf(file, { exec, ffmpeg = "ffmpeg" }) {
try {
diff --git a/umtool/report-to-video/post-slurs.mjs b/umtool/report-to-video/post-slurs.mjs
@@ -0,0 +1,416 @@
+// THE SLUR FILTER (operator, 3 Nov: "add a censor-slurs feature ... that can
+// be turned off for an uncensored cut -- black out the visual and skip the
+// word in narration, or maybe replace it with a TOS friendly but similar
+// placeholder visually distinct on the tweet"). umtool/docs/knobs.md, "The
+// slur filter".
+//
+// Built on the REDACTION (post-redact.mjs): like it, it changes only what is
+// PUBLISHED -- the rendered card, the read a voice synthesizes or the take
+// that plays, a chapter line, an attachment's burnt-in captions -- and never
+// the archive's rows, the manifest's snapshot or a script. Unlike it, it is a
+// LIST OF SLURS shipped as data (slurs.json: each slur's forms, a level, its
+// masked form and its spoken stand-in), matched whole-word and without case,
+// through the common ways of writing one past a filter (a letter swapped for
+// a look-alike -- "@" for a, "0" for o, "*" for a vowel -- or the word spelt
+// out letter by letter with a space, dot, dash or underscore between).
+//
+// render.posts.slurs = {
+// on?: true (default) | false false: the uncensored cut
+// level?: "all" (default) | "strong" strong: only the strong slurs
+// add?: ["<word>" | {word, forms?, mask?, say?}] the project's own (always masked)
+// except?: ["<form or word>"] never masked in this project
+// visual?: "placeholder" (default) a dark pill with the masked form ("f*****")
+// | "blackout" the redaction's solid bar
+// voice?: "beep" (default) said, and a tone laid over it at its time
+// | "skip" left out of a synthesized read
+// | "placeholder" its stand-in said instead ("f-slur")
+// (the operator's choice, 3 Nov: "pill + beep" -- "skip seems like it'd be unnatural")
+// }
+//
+// THE SWITCH: `on: false` -- a take's patch (`umtool take <p> … --uncensored`)
+// or build-video's --uncensored -- renders the same cut with the slurs left as
+// they are. The redaction (private words) and an attachment's censoring are
+// NOT part of it: they stay on.
+//
+// PURE and dependency-free (post-redact.mjs builds on it; the readers hand it
+// the list, post-redact-files.mjs).
+
+export const SLUR_LEVELS = Object.freeze(["all", "strong"]);
+export const SLUR_VISUALS = Object.freeze(["blackout", "placeholder"]);
+export const SLUR_VOICES = Object.freeze(["skip", "beep", "placeholder"]);
+export const SLURS_DEFAULTS = Object.freeze({ on: true, level: "all", visual: "placeholder", voice: "beep" });
+export const SLUR_LIST_LEVELS = Object.freeze(["strong", "mild"]);
+export const SLURS_ADD_MAX = 100;
+export const SLUR_KEYS = Object.freeze(["on", "level", "add", "except", "visual", "voice", "note"]);
+
+/** The redaction's mark (post-redact.mjs REDACT_MARK): a blacked-out slur is drawn as its bar. */
+export const BLACKOUT_MARK = "";
+/** A slur's second and later letters spelt apart ("f a g …"): kept as a token so the card's word indices hold, drawn as nothing. */
+export const SLUR_GAP = "";
+/** A placeholder's characters, each moved into the private-use area (U+E100 + its ASCII code): never typed, decoded only where drawn. */
+const PH_BASE = 0xe100;
+export const PLACEHOLDER_RE = /[-]+/g;
+
+const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v);
+const str = (v) => (typeof v === "string" ? v : "");
+const lc = (v) => str(v).trim().toLowerCase();
+const WORD_RE = /^[a-z]{2,40}$/;
+const MASK_RE = /^[\x21-\x7E]{1,40}$/;
+
+// ---------------------------------------------------------------------------
+// The list.
+// ---------------------------------------------------------------------------
+
+/** Every reason a slur list document (slurs.json's shape) is refused. */
+export function slurListErrors(doc, where = "slurs.json") {
+ if (!isObj(doc) || !Array.isArray(doc.entries)) return [`${where} must be {entries: [{id, level, word, forms, say}]}`];
+ const errors = [];
+ const ids = new Set();
+ doc.entries.forEach((e, i) => {
+ const w = `${where} entries[${i}]`;
+ if (!isObj(e)) return errors.push(`${w} must be an object`);
+ if (typeof e.id !== "string" || !/^[a-z0-9-]{1,40}$/.test(e.id) || ids.has(e.id)) errors.push(`${w}.id must be a unique short id`);
+ ids.add(e.id);
+ if (!SLUR_LIST_LEVELS.includes(e.level)) errors.push(`${w}.level must be ${SLUR_LIST_LEVELS.join(" or ")}`);
+ if (!WORD_RE.test(str(e.word))) errors.push(`${w}.word must be lower-case letters`);
+ if (!Array.isArray(e.forms) || !e.forms.length || !e.forms.every((f) => WORD_RE.test(str(f)))) errors.push(`${w}.forms must be a list of lower-case words`);
+ if (e.mask !== undefined && !MASK_RE.test(str(e.mask))) errors.push(`${w}.mask must be printable ASCII, no spaces`);
+ if (typeof e.say !== "string" || !e.say.trim() || e.say.length > 40) errors.push(`${w}.say must be the words said in its place`);
+ });
+ return errors;
+}
+
+/** A project's added slur as an entry of the list (a bare word: that word alone, its default mask, said "slur"). */
+function addedEntry(a) {
+ const x = typeof a === "string" ? { word: a } : a;
+ const word = lc(x?.word);
+ const forms = Array.isArray(x?.forms) && x.forms.length ? x.forms.map(lc) : [word];
+ return { id: `add:${word}`, level: "strong", word, forms: forms.includes(word) ? forms : [word, ...forms], ...(x?.mask ? { mask: x.mask } : {}), say: str(x?.say).trim() || "slur", added: true };
+}
+
+/**
+ * THE FILTER this cut publishes with: `render.posts.slurs` over the list --
+ * `{ on, level, visual, voice, entries }`, the entries those of the level
+ * (strong, or strong and mild), the project's additions, the exceptions taken
+ * out (a form, a slur's word or its id). `uncensored` turns it off (the
+ * entries kept: what WOULD be masked is still known).
+ *
+ * @param {Record<string, any>|undefined} cfg render.posts.slurs
+ * @param {{ entries: any[] }|null|undefined} list the default list (slurs.json)
+ * @param {{ uncensored?: boolean }} [o]
+ */
+export function resolveSlurs(cfg, list, { uncensored = false } = {}) {
+ const c = isObj(cfg) ? cfg : {};
+ const level = SLUR_LEVELS.includes(c.level) ? c.level : SLURS_DEFAULTS.level;
+ const ex = new Set((Array.isArray(c.except) ? c.except : []).map(lc).filter(Boolean));
+ const base = (Array.isArray(list?.entries) ? list.entries : []).filter((e) => level === "all" || e.level === "strong");
+ const added = (Array.isArray(c.add) ? c.add : []).filter((a) => WORD_RE.test(lc(typeof a === "string" ? a : a?.word))).map(addedEntry);
+ const entries = [...base, ...added]
+ .filter((e) => !ex.has(e.id) && !ex.has(e.word))
+ .map((e) => ({ id: e.id, level: e.level, word: e.word, forms: e.forms.filter((f) => !ex.has(f)), mask: e.mask ?? maskOfWord(e.word), say: e.say, ...(e.added ? { added: true } : {}) }))
+ .filter((e) => e.forms.length);
+ return {
+ on: !uncensored && c.on !== false,
+ level,
+ visual: SLUR_VISUALS.includes(c.visual) ? c.visual : SLURS_DEFAULTS.visual,
+ voice: SLUR_VOICES.includes(c.voice) ? c.voice : SLURS_DEFAULTS.voice,
+ entries,
+ ...(uncensored ? { uncensored: true } : {}),
+ };
+}
+
+/** Does the filter mask anything? */
+export const slursOn = (s) => !!s && s.on === true && Array.isArray(s.entries) && s.entries.length > 0;
+
+/** Every reason `render.posts.slurs` is refused. */
+export function validateSlursRender(s, where = "render.posts.slurs") {
+ if (s === undefined) return [];
+ if (!isObj(s)) return [`${where} must be {on?, level?, add?, except?, visual?, voice?}`];
+ const errors = [];
+ for (const k of Object.keys(s)) if (!SLUR_KEYS.includes(k)) errors.push(`${where}.${k} is not a knob of the slur filter (${SLUR_KEYS.join(", ")})`);
+ if (s.on !== undefined && typeof s.on !== "boolean") errors.push(`${where}.on must be true or false`);
+ if (s.level !== undefined && !SLUR_LEVELS.includes(s.level)) errors.push(`${where}.level must be one of ${SLUR_LEVELS.join(", ")}`);
+ if (s.visual !== undefined && !SLUR_VISUALS.includes(s.visual)) errors.push(`${where}.visual must be one of ${SLUR_VISUALS.join(", ")}`);
+ if (s.voice !== undefined && !SLUR_VOICES.includes(s.voice)) errors.push(`${where}.voice must be one of ${SLUR_VOICES.join(", ")}`);
+ if (s.note !== undefined && typeof s.note !== "string") errors.push(`${where}.note must be words`);
+ for (const key of ["add", "except"]) {
+ const list = s[key];
+ if (list === undefined) continue;
+ if (!Array.isArray(list) || list.length > SLURS_ADD_MAX) {
+ errors.push(`${where}.${key} must be a list of at most ${SLURS_ADD_MAX} words`);
+ continue;
+ }
+ list.forEach((a, i) => {
+ const w = `${where}.${key}[${i}]`;
+ if (key === "except" || typeof a === "string") {
+ if (typeof a !== "string" || !/^[a-z0-9-]{2,40}$/.test(lc(a))) errors.push(`${w} must be a word (letters, 2–40)`);
+ return;
+ }
+ if (!isObj(a)) return errors.push(`${w} must be a word or {word, forms?, mask?, say?}`);
+ for (const k of Object.keys(a)) if (!["word", "forms", "mask", "say"].includes(k)) errors.push(`${w}.${k} is not a key of an added slur (word, forms, mask, say)`);
+ if (!WORD_RE.test(lc(a.word))) errors.push(`${w}.word must be a word (letters, 2–40)`);
+ if (a.forms !== undefined && !(Array.isArray(a.forms) && a.forms.length <= 20 && a.forms.every((f) => WORD_RE.test(lc(f))))) errors.push(`${w}.forms must be a list of words`);
+ if (a.mask !== undefined && !MASK_RE.test(str(a.mask))) errors.push(`${w}.mask must be printable ASCII, no spaces`);
+ if (a.say !== undefined && !(typeof a.say === "string" && a.say.length <= 40)) errors.push(`${w}.say must be words (at most 40 characters)`);
+ });
+ }
+ return errors;
+}
+
+// ---------------------------------------------------------------------------
+// The matcher.
+// ---------------------------------------------------------------------------
+
+/** The look-alikes a letter may be written as (a filter-dodger's spellings): "*" stands in for a vowel only. */
+const SWAPS = Object.freeze({ a: "a@4*", e: "e3*", i: "i1!*", o: "o0*", u: "u*", s: "s$5", t: "t7", l: "l1" });
+/** What may sit between the letters of a word spelt out ("f a g …", "f.a.g", "f-a-g"): one, between every pair. */
+const SPELT_SEP = "[ .\\-_]";
+const escRe = (s) => s.replace(/[.*+?^${}()|[\]\\/-]/g, "\\$&");
+const letterRe = (c) => (SWAPS[c] ? `[${SWAPS[c].replace(/[\]\\^-]/g, "\\$&")}]` : escRe(c));
+
+/** One form's pattern: its letters (each with its look-alikes), together or spelt out (three letters or more). */
+export function formPattern(form) {
+ const letters = [...lc(form)].map(letterRe);
+ const together = letters.join("");
+ return letters.length >= 3 ? `(?:${together}|${letters.join(SPELT_SEP)})` : together;
+}
+
+const COMPILED = new WeakMap();
+/** The filter's one pattern (a capture group per slur, its forms longest first), or null. */
+function compiled(s) {
+ if (!s || !Array.isArray(s.entries) || !s.entries.length) return null;
+ const hit = COMPILED.get(s);
+ if (hit) return hit;
+ const groups = s.entries.map((e) => `(${[...e.forms].sort((a, b) => b.length - a.length).map(formPattern).join("|")})`);
+ const re = new RegExp(`(?<![\\p{L}\\p{N}])(?:${groups.join("|")})(?![\\p{L}\\p{N}])`, "giu");
+ COMPILED.set(s, re);
+ return re;
+}
+
+/**
+ * Every slur in `text`: `[{ start, end, id }]` (code units), in order. Whole
+ * words only -- a letter or digit either side refuses a match ("Scunthorpe",
+ * "niggardly", "retardant").
+ *
+ * @param {string} text
+ * @param {{ entries: any[] } | null | undefined} s resolveSlurs' filter (on or off)
+ */
+export function slurMatches(text, s) {
+ const re = compiled(s);
+ const t = str(text);
+ if (!re || !t) return [];
+ const out = [];
+ for (const m of t.matchAll(new RegExp(re.source, re.flags))) {
+ if (!m[0]) continue;
+ const g = m.slice(1).findIndex((x) => x !== undefined);
+ out.push({ start: m.index, end: m.index + m[0].length, id: s.entries[g]?.id ?? null });
+ }
+ return out;
+}
+
+/** A slur's entry in the filter. */
+export const slurEntryOf = (s, id) => (Array.isArray(s?.entries) ? s.entries.find((e) => e.id === id) ?? null : null);
+
+/** A word's default masked form: its first letter, an asterisk for each other. */
+export const maskOfWord = (word) => (str(word) ? `${str(word)[0]}${"*".repeat(Math.max(1, str(word).length - 1))}` : "*");
+
+/** The masked form a hit is drawn as: the slur's mask, its first letter in the case the text wrote it. */
+export function maskFor(s, hit, matched) {
+ const e = slurEntryOf(s, hit.id);
+ const mask = e?.mask ?? "*****";
+ const first = str(matched)[0] ?? "";
+ return first && first !== first.toLowerCase() && /\p{L}/u.test(first) ? mask[0].toUpperCase() + mask.slice(1) : mask;
+}
+
+/** The words a read says in a hit's place (voice placeholder). */
+export const sayFor = (s, hit) => slurEntryOf(s, hit.id)?.say ?? "slur";
+
+/** A mask moved into the private-use area (one character each), decoded only where it is drawn. */
+export const encodePlaceholder = (mask) => [...str(mask)].map((c) => String.fromCharCode(PH_BASE + Math.min(0x7e, Math.max(0x21, c.charCodeAt(0))))).join("");
+/** And back. */
+export const decodePlaceholder = (marked) => str(marked).replace(PLACEHOLDER_RE, (run) => [...run].map((c) => String.fromCharCode(c.charCodeAt(0) - PH_BASE)).join(""));
+
+/** Does `text` hold a masked slur (a placeholder or a gap)? */
+export const hasSlurMarks = (text) => /[-]/.test(str(text));
+
+/**
+ * `text` with every slur MASKED as the card draws it: `visual` blackout, the
+ * redaction's mark for each letter (a bar of its width); placeholder, the
+ * mask in the private-use area. A slur spelt apart keeps its tokens (the
+ * card's word indices hold): the first holds the mark, the others a gap
+ * drawn as nothing. Returns `{ text, hits }`.
+ */
+export function maskSlurs(text, s, visual = s?.visual ?? SLURS_DEFAULTS.visual) {
+ const t = str(text);
+ const hits = slursOn(s) ? slurMatches(t, s) : [];
+ if (!hits.length) return { text: t, hits };
+ let out = "";
+ let at = 0;
+ for (const h of hits) {
+ out += t.slice(at, h.start);
+ const seg = t.slice(h.start, h.end);
+ let first = true;
+ for (const p of seg.split(/(\s+)/)) {
+ if (!p) continue;
+ if (/^\s+$/.test(p)) out += p;
+ else if (first) {
+ out += visual === "placeholder" ? encodePlaceholder(maskFor(s, h, seg)) : BLACKOUT_MARK.repeat(seg.replace(/\s/g, "").length);
+ first = false;
+ } else out += SLUR_GAP;
+ }
+ at = h.end;
+ }
+ return { text: out + t.slice(at), hits };
+}
+
+/** HTML (already escaped) with each placeholder drawn as the censor pill and each gap as nothing. */
+export const placeholdersHtml = (html) =>
+ str(html)
+ .replace(//g, "")
+ .replace(PLACEHOLDER_RE, (run) => `<span class="slur" data-post-slur="">${decodePlaceholder(run).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")}</span>`);
+
+/** The pill's CSS: a dark capsule, the mask in the card's colour, spaced a little -- not to be read as the post's own letters. */
+export const SLUR_CSS = (fg) =>
+ `.slur { display: inline-block; padding: 0 0.32em; border-radius: 0.5em; background: #0b0b0b; color: ${fg}; box-shadow: inset 0 0 0 0.06em rgba(255,255,255,0.28); letter-spacing: 0.08em; font-size: 0.86em; line-height: 1.25; vertical-align: 0.04em; }`;
+
+// ---------------------------------------------------------------------------
+// The voice.
+// ---------------------------------------------------------------------------
+
+/** A word reduced as word-zoom.mjs normWord does (lower case, its edge punctuation gone). */
+const normWord = (w) => str(w).toLowerCase().normalize("NFKC").replace(/[‘’]/g, "'").replace(/^[^\p{L}\p{N}]+|[^\p{L}\p{N}]+$/gu, "");
+
+/** A script's spoken words with their offsets: word-zoom.mjs scriptWordsOf's words (a take's `words` are one per each), in order. */
+export function scriptTokens(script) {
+ const clean = str(script).replace(/<[^<>]*>/g, (m) => " ".repeat(m.length));
+ const out = [];
+ for (const m of clean.matchAll(/\S+/g)) if (normWord(m[0])) out.push({ w: m[0], start: m.index, end: m.index + m[0].length });
+ return out;
+}
+
+/** Each take's slur state: what its audio does with the slurs its script holds. Absent: it says them (a recording; a take from before the filter). */
+export const TAKE_SLUR_STATES = Object.freeze(["said", "skip", "placeholder"]);
+
+/** The before/after pad of a beep or a mute around the word, seconds. */
+export const SLUR_BLEEP_PAD = Object.freeze({ before: 0.04, after: 0.06 });
+/** The beep: a sine at this pitch and amplitude, under the narrator's chain. */
+export const SLUR_BEEP = Object.freeze({ hz: 1000, amp: 0.18 });
+
+/**
+ * A TAKE's slurs to cover, in take seconds: `{ mode: "beep" | "mute", spans:
+ * [[from, to]] }` (beep: the voice's choice beep or placeholder -- a
+ * recorded take cannot say a stand-in; mute: skip), null when there is none
+ * (the filter off, the take's audio leaves them out, its script holds none),
+ * or `{ error }` when the take says one and has no word timings to find it by.
+ *
+ * @param {{ script?: string, words?: Array<{w: string, start: number, end: number}>, slurs?: string, file?: string, seconds?: number }} take
+ * @param {ReturnType<typeof resolveSlurs> | null | undefined} s
+ * @param {{ script?: string, state?: string | null }} [o] the script it read (default its own), its state (default its own)
+ */
+export function takeBleeps(take, s, { script = undefined, state = undefined } = {}) {
+ if (!slursOn(s) || !take) return null;
+ const st = state ?? take.slurs ?? "said";
+ if (st !== "said") return null;
+ const text = str(script ?? take.script);
+ const hits = slurMatches(text, s);
+ if (!hits.length) return null;
+ const words = Array.isArray(take.words) ? take.words : [];
+ const toks = scriptTokens(text);
+ const masks = [...new Set(hits.map((h) => maskFor(s, h, "")))].join(", ");
+ if (!words.length) return { error: `its take ${take.file ?? ""} says ${hits.length} slur(s) (${masks}) and has no word timings to ${s.voice === "skip" ? "silence" : "beep"} them by` };
+ if (words.length !== toks.length) return { error: `its take ${take.file ?? ""}'s word timings are not of its script (${words.length} timed, ${toks.length} in the script)` };
+ const spans = [];
+ for (const h of hits) {
+ const ks = toks.map((t, k) => (t.end > h.start && t.start < h.end ? k : -1)).filter((k) => k >= 0);
+ if (!ks.length) continue;
+ const a = Math.max(0, Math.min(...ks.map((k) => words[k].start)) - SLUR_BLEEP_PAD.before);
+ const b = Math.max(...ks.map((k) => words[k].end)) + SLUR_BLEEP_PAD.after;
+ spans.push([Math.round(a * 1000) / 1000, Math.round(b * 1000) / 1000]);
+ }
+ spans.sort((x, y) => x[0] - y[0]);
+ const merged = [];
+ for (const sp of spans) {
+ const last = merged[merged.length - 1];
+ if (last && sp[0] <= last[1]) last[1] = Math.max(last[1], sp[1]);
+ else merged.push([...sp]);
+ }
+ return merged.length ? { mode: s.voice === "skip" ? "mute" : "beep", spans: merged } : null;
+}
+
+/**
+ * The narrator's filters that cover the spans (before its levelling and
+ * tempo, on the take's own clock): `[inLabel]` → `[outLabel]`, the voice
+ * silenced over each span and, for a beep, a tone mixed in over it.
+ */
+export function bleepFilters(inLabel, outLabel, bleeps, { audioRate = 48000, seconds = 600 } = {}) {
+ const gate = bleeps.spans.map(([a, b]) => `between(t,${a},${b})`).join("+");
+ const out = [`[${inLabel}]aresample=${audioRate},aformat=sample_fmts=fltp:channel_layouts=stereo,volume=0:enable='${gate}'[${outLabel}_m]`];
+ if (bleeps.mode !== "beep") return [...out, `[${outLabel}_m]anull[${outLabel}]`];
+ const tone = `${SLUR_BEEP.amp}*sin(2*PI*${SLUR_BEEP.hz}*t)*(${gate})`;
+ return [
+ ...out,
+ `aevalsrc=exprs='${tone}|${tone}':s=${audioRate}:d=${Math.ceil(seconds + 1)}[${outLabel}_t]`,
+ `[${outLabel}_m][${outLabel}_t]amix=inputs=2:normalize=0:duration=first[${outLabel}]`,
+ ];
+}
+
+// ---------------------------------------------------------------------------
+// What a cut would mask (`umtool posts slurs ls`).
+// ---------------------------------------------------------------------------
+
+/** The words of a post item a slur may be in, by where: its words, its authors' names, the posts it answers and quotes, its read. */
+export function postSlurTexts(entry) {
+ const out = [];
+ const add = (where, v) => typeof v === "string" && v && out.push({ where, text: v });
+ add("text", entry?.text);
+ add("author", entry?.author);
+ if (isObj(entry?.repostedBy)) add("repostedBy", entry.repostedBy.author);
+ (Array.isArray(entry?.parents) ? entry.parents : []).forEach((p, i) => {
+ add(`parents[${i}].text`, p?.text);
+ add(`parents[${i}].paraphrase`, p?.paraphrase);
+ add(`parents[${i}].author`, p?.author);
+ });
+ if (isObj(entry?.quoted)) {
+ add("quoted.text", entry.quoted.text);
+ add("quoted.paraphrase", entry.quoted.paraphrase);
+ add("quoted.author", entry.quoted.author);
+ }
+ add("script", entry?.narration?.script);
+ return out;
+}
+
+/**
+ * The slurs a cut's post items hold: `{ total, posts: [{ id, hits: {<slur id>: n}, where: [...] }], bySlur: {<slur id>: { mask, n, posts: [ids] }} }`.
+ * The filter's state does not matter (an uncensored cut is counted as if on).
+ */
+export function slurReport(timeline, s) {
+ const on = { ...s, on: true };
+ const posts = [];
+ const bySlur = {};
+ let total = 0;
+ for (const e of Array.isArray(timeline) ? timeline : []) {
+ if (e?.type !== "post") continue;
+ const hits = {};
+ const where = new Set();
+ for (const { where: w, text } of postSlurTexts(e)) {
+ for (const h of slurMatches(text, on)) {
+ hits[h.id] = (hits[h.id] ?? 0) + 1;
+ where.add(w.replace(/\[\d+\]/, ""));
+ total += 1;
+ const se = slurEntryOf(on, h.id);
+ const b = (bySlur[h.id] ??= { mask: se?.mask ?? "*", n: 0, posts: [], ...(se?.added ? { added: true } : {}) });
+ b.n += 1;
+ if (!b.posts.includes(e.id)) b.posts.push(e.id);
+ }
+ }
+ if (Object.keys(hits).length) posts.push({ id: e.id, hits, where: [...where] });
+ }
+ return { total, posts, bySlur };
+}
+
+/** A take's record of the cut's slur state (take.json `slurs`): the cut has post items, and whether it publishes them censored. */
+export function cutSlurState(manifest) {
+ const tl = Array.isArray(manifest?.timeline) ? manifest.timeline : [];
+ if (!tl.some((e) => e?.type === "post")) return null;
+ return manifest?.render?.posts?.slurs?.on === false ? "uncensored" : "censored";
+}
diff --git a/umtool/report-to-video/post-slurs.test.mjs b/umtool/report-to-video/post-slurs.test.mjs
@@ -0,0 +1,234 @@
+// post-slurs.mjs: the slur filter -- the list, the matcher (its spellings and
+// no substring matches), the masks on the card, the read (skip, stand-in,
+// beep), the switch -- and its place in the redaction (post-redact.mjs).
+// The words come from slurs.json: no test spells one out.
+import { test } from "node:test";
+import assert from "node:assert/strict";
+import { readFileSync } from "node:fs";
+
+import {
+ BLACKOUT_MARK, SLUR_GAP, bleepFilters, cutSlurState, decodePlaceholder, encodePlaceholder, maskSlurs, placeholdersHtml, resolveSlurs, scriptTokens,
+ slurListErrors, slurMatches, slurReport, slursOn, takeBleeps, validateSlursRender,
+} from "./post-slurs.mjs";
+import { REDACT_MARK, barsHtml, dropMarks, redactEntry, redactionOn, shownLine, spokenRead, validatePostsRender } from "./post-redact.mjs";
+import { cutSlurs, defaultSlurList } from "./post-redact-files.mjs";
+import { postCardHtml } from "./post-item.mjs";
+import { scriptWordsOf } from "./word-zoom.mjs";
+
+const LIST = JSON.parse(readFileSync(new URL("./slurs.json", import.meta.url), "utf8"));
+const byId = (id) => LIST.entries.find((e) => e.id === id);
+const F = byId("f-slur").word; // the f-slur, six letters
+const FS = byId("f-slur").forms.find((f) => f === `${F}s`);
+const R = byId("r-word").word; // a mild one
+const N = byId("n-word").word;
+const ON = resolveSlurs(undefined, LIST);
+const spaced = (w, sep = " ") => [...w].join(sep);
+const leet = (w) => w.replace("a", "@").replace("o", "0");
+
+test("the shipped list is well formed, and every entry has forms, a level and a stand-in", () => {
+ assert.deepEqual(slurListErrors(LIST), []);
+ assert.equal(defaultSlurList().entries.length, LIST.entries.length);
+ assert.ok(LIST.entries.some((e) => e.level === "mild") && LIST.entries.some((e) => e.level === "strong"));
+ assert.match(slurListErrors({ entries: [{ id: "x", level: "loud", word: "X1", forms: [], say: "" }] }).join(" "), /level.*word.*forms.*say/);
+});
+
+test("matching: whole words, without case, through look-alike letters and a word spelt out", () => {
+ const hit = (t) => slurMatches(t, ON).map((h) => t.slice(h.start, h.end));
+ assert.deepEqual(hit(`you ${F}`), [F]);
+ assert.deepEqual(hit(`${F.toUpperCase()}!`), [F.toUpperCase()]);
+ assert.deepEqual(hit(`two ${FS}, ok`), [FS]);
+ assert.deepEqual(hit(`a ${leet(F)} here`), [leet(F)]);
+ assert.deepEqual(hit(`${F[0]}*${F.slice(2)}`), [`${F[0]}*${F.slice(2)}`]);
+ assert.deepEqual(hit(`a ${spaced(F)} b`), [spaced(F)]);
+ assert.deepEqual(hit(`a ${spaced(F, ".")} b`), [spaced(F, ".")]);
+ assert.deepEqual(hit(`a ${spaced(F, "-")}.`), [spaced(F, "-")]);
+ assert.deepEqual(hit(`#${F} @x_${F}`), [F, F]);
+ assert.deepEqual(hit(`${F}'s thing`), [F]);
+ // The id says which slur it was.
+ assert.equal(slurMatches(`${N}s`, ON)[0].id, "n-word");
+});
+
+test("no substring matches: a slur inside a longer word, or a word that only looks like one, is left alone", () => {
+ const none = (t) => assert.deepEqual(slurMatches(t, ON), [], t);
+ none("Scunthorpe");
+ none("niggardly praise");
+ none("fire retardant");
+ none(`${R}ant`);
+ none("raccoon, spice, spicy, Fagin, faggio, kiker, troonish, gooky, tardis");
+ none(`x${F}`);
+ none(`${F}2`);
+ // Spelt apart only with a separator between EVERY letter: "it's pic" is not one.
+ none("it's pic, the s pic, s pi c");
+ // Mixed spacing (some letters together) is not a spelling the filter reads.
+ none(`${N.slice(0, 3)} ${N.slice(3)}`);
+});
+
+test("the level, the project's additions and exceptions", () => {
+ const strong = resolveSlurs({ level: "strong" }, LIST);
+ assert.equal(slurMatches(R, strong).length, 0);
+ assert.equal(slurMatches(R, ON).length, 1);
+ assert.equal(slurMatches(F, strong).length, 1);
+ const own = resolveSlurs({ add: ["zorbo", { word: "blerg", forms: ["blergs"], mask: "b***", say: "b-word" }], except: [FS, "r-word"] }, LIST);
+ assert.equal(slurMatches("a zorbo and two blergs", own).length, 2);
+ assert.equal(slurMatches(FS, own).length, 0, "an excepted form");
+ assert.equal(slurMatches(F, own).length, 1, "the rest of its slur");
+ assert.equal(slurMatches(R, own).length, 0, "an excepted slur, by its id");
+ assert.equal(slursOn(resolveSlurs({ on: false }, LIST)), false);
+ assert.equal(slursOn(resolveSlurs({}, LIST, { uncensored: true })), false);
+ assert.equal(resolveSlurs({}, LIST, { uncensored: true }).entries.length, ON.entries.length, "what would be masked is still known");
+});
+
+test("validateSlursRender refuses what the filter cannot use; render.posts carries it", () => {
+ assert.deepEqual(validateSlursRender({ on: false, level: "strong", visual: "placeholder", voice: "beep", add: ["zorbo"], except: ["n-word"] }), []);
+ const errs = validateSlursRender({ on: "yes", level: "loud", visual: "blur", voice: "hum", add: [3], except: [""], nope: 1 }).join(" | ");
+ for (const k of ["nope", ".on", ".level", ".visual", ".voice", "add[0]", "except[0]"]) assert.ok(errs.includes(k), k);
+ assert.match(validatePostsRender({ posts: { slurs: { visual: "blur" } } }).join(" "), /slurs\.visual/);
+});
+
+test("the card's masks: a blackout is the redaction's bar; a placeholder is a pill with the mask, never the word", () => {
+ assert.equal(BLACKOUT_MARK, REDACT_MARK);
+ const b = maskSlurs(`you ${F}!`, { ...ON, visual: "blackout" }).text;
+ assert.equal(b, `you ${REDACT_MARK.repeat(F.length)}!`);
+ const p = maskSlurs(`you ${F}! ${F[0].toUpperCase()}${F.slice(1)}`, { ...ON, visual: "placeholder" }).text;
+ assert.equal(decodePlaceholder(p), `you ${F[0]}*****! ${F[0].toUpperCase()}*****`);
+ assert.ok(!p.toLowerCase().includes(F));
+ // Spelt apart: as many tokens as before (the card's word indices hold), the first the mask, the rest gaps.
+ const sp = maskSlurs(`a ${spaced(F)} b`, { ...ON, visual: "placeholder" }).text;
+ assert.equal(sp.split(/\s+/).length, `a ${spaced(F)} b`.split(/\s+/).length);
+ assert.equal(sp.split(SLUR_GAP).length - 1, F.length - 1);
+ assert.equal(placeholdersHtml(sp), `a <span class="slur" data-post-slur="">${F[0]}*****</span>${" ".repeat(F.length - 1)} b`);
+ assert.equal(decodePlaceholder(encodePlaceholder("n*****")), "n*****");
+ assert.equal(dropMarks(sp), `a ${F[0]}***** b`);
+ // Off: untouched.
+ assert.equal(maskSlurs(F, resolveSlurs({ on: false }, LIST)).text, F);
+});
+
+const post = (text, extra = {}) => ({
+ id: "p1", type: "post", platform: "x", post: "chan/1", author: "Some One", handle: "someone", date: "2026-01-01T00:00:00Z", text, ...extra,
+});
+
+test("redactEntry masks the slurs with the redaction, and the card's HTML never holds the word", () => {
+ const e = post(`what a ${F}, said the ${leet(F)}`, { quoted: { author: "Q", handle: "q", text: `${FS} again` }, parents: [{ author: "P", handle: "p", text: `${spaced(F)} indeed` }] });
+ const red = { terms: [{ term: "said" }], slurs: { ...ON, visual: "placeholder" } };
+ assert.ok(redactionOn({ terms: [], slurs: ON }));
+ const shown = redactEntry(e, red);
+ for (const v of [shown.text, shown.quoted.text, shown.parents[0].text]) assert.equal(slurMatches(decodePlaceholder(v), ON).length, 0, v);
+ const html = postCardHtml(e, { width: 1280, height: 720, redaction: red });
+ const low = html.toLowerCase();
+ for (const w of [F, FS, leet(F), spaced(F)]) assert.ok(!low.includes(w), `the page holds ${w.length}-letter form`);
+ assert.ok(!low.includes(">said<"), "the redaction still applies");
+ assert.ok((html.match(/data-post-slur=""/g) ?? []).length >= 4);
+ assert.ok(html.includes(`${F[0]}*****`));
+ assert.ok(html.includes("data-post-blanked"), "the redacted term's bar");
+ // Blackout: bars, no pill.
+ const bhtml = postCardHtml(e, { width: 1280, height: 720, redaction: { terms: [], slurs: { ...ON, visual: "blackout" } } });
+ assert.ok(!bhtml.toLowerCase().includes(F) && !bhtml.includes('data-post-slur=""') && bhtml.includes("data-post-blanked"));
+ // UNCENSORED: the words, the redaction still on.
+ const u = postCardHtml(e, { width: 1280, height: 720, redaction: { terms: [{ term: "said" }], slurs: resolveSlurs({}, LIST, { uncensored: true }) } });
+ assert.ok(u.includes(F) && !u.includes(">said<"));
+ // The entry itself is never touched.
+ assert.ok(e.text.includes(F));
+});
+
+test("the read: skip leaves the slur out, placeholder says its stand-in, beep says it (the render covers it); off says it", () => {
+ const e = post("x");
+ const red = (o) => ({ terms: [{ term: "Quentin" }], slurs: resolveSlurs(o, LIST) });
+ const text = `Quentin called him a ${F}, twice.`;
+ assert.deepEqual(spokenRead(text, e, red({ voice: "skip" })), { text: "called him a, twice.", slurs: "skip" });
+ // The default (the operator's "pill + beep"): said, for the render's beep.
+ assert.deepEqual(spokenRead(text, e, red({})), { text: `called him a ${F}, twice.`, slurs: "said" });
+ assert.deepEqual(spokenRead(text, e, red({ voice: "placeholder" })), { text: "called him a f-slur, twice.", slurs: "placeholder" });
+ assert.deepEqual(spokenRead(text, e, red({ voice: "beep" })), { text: `called him a ${F}, twice.`, slurs: "said" });
+ assert.deepEqual(spokenRead(text, e, red({ on: false })), { text: `called him a ${F}, twice.`, slurs: "said" });
+ assert.deepEqual(spokenRead("nothing here", e, red({})), { text: "nothing here", slurs: null });
+ // A caption: left out (blackout), or its mask (placeholder); the redaction too.
+ assert.equal(shownLine(`Quentin, you ${F}`, e, red({ visual: "blackout" })), "you");
+ assert.equal(shownLine(`Quentin, you ${F}`, e, red({})), `you ${F[0]}*****`);
+});
+
+test("takeBleeps: a take that says a slur is covered at its words' times; without timings it is refused", () => {
+ const script = `<sigh> He said ${F} and then ${spaced(F)} again.`;
+ const toks = scriptTokens(script);
+ assert.deepEqual(toks.map((t) => t.w), scriptWordsOf(script), "the take's words are one per these");
+ const words = toks.map((t, i) => ({ w: t.w, start: i, end: i + 0.5 }));
+ const take = { file: "narration/posts/1/take-1.orpheus-zac.wav", script, words, seconds: 20 };
+ const s = resolveSlurs({ voice: "beep" }, LIST);
+ const b = takeBleeps(take, s);
+ // "He"(0) "said"(1) F(2) "and"(3) "then"(4) f,a,g,g,o,t (5..10) "again."(11)
+ assert.deepEqual(b, { mode: "beep", spans: [[1.96, 2.56], [4.96, 10.56]] });
+ assert.equal(takeBleeps(take, resolveSlurs({ voice: "skip" }, LIST)).mode, "mute");
+ assert.equal(takeBleeps(take, resolveSlurs({}, LIST)).mode, "beep", "the default");
+ assert.equal(takeBleeps(take, resolveSlurs({ on: false }, LIST)), null);
+ assert.equal(takeBleeps({ ...take, slurs: "skip" }, s), null, "its audio left them out");
+ assert.match(takeBleeps({ ...take, words: undefined }, s).error, /no word timings/);
+ assert.match(takeBleeps({ ...take, words: words.slice(1) }, s).error, /not of its script/);
+ const f = bleepFilters("v", "vb", b, { seconds: 20 }).join(";");
+ assert.match(f, /volume=0:enable='between\(t,1\.96,2\.56\)\+between\(t,4\.96,10\.56\)'/);
+ assert.match(f, /aevalsrc=exprs='0\.18\*sin\(2\*PI\*1000\*t\)/);
+ assert.doesNotMatch(bleepFilters("v", "vb", { mode: "mute", spans: [[1, 2]] }).join(";"), /aevalsrc/);
+});
+
+test("slurReport counts what the cut would mask, per slur and per post; cutSlurState says which a take is", () => {
+ const tl = [post(`${F} ${F}`, { id: "a" }), post("clean", { id: "b", narration: { script: `${N}` } }), { id: "c", type: "clip" }];
+ const r = slurReport(tl, resolveSlurs({ on: false }, LIST));
+ assert.equal(r.total, 3);
+ assert.deepEqual(r.bySlur["f-slur"], { mask: `${F[0]}*****`, n: 2, posts: ["a"] });
+ assert.deepEqual(r.posts.map((p) => p.id), ["a", "b"]);
+ assert.deepEqual(r.posts[1].where, ["script"]);
+ assert.equal(cutSlurState({ timeline: tl }), "censored");
+ assert.equal(cutSlurState({ timeline: tl, render: { posts: { slurs: { on: false } } } }), "uncensored");
+ assert.equal(cutSlurState({ timeline: [{ type: "clip" }] }), null);
+ assert.equal(cutSlurs({ render: { posts: { slurs: { level: "strong" } } } }).level, "strong");
+});
+
+test("barsHtml draws placeholders and gaps with the redaction's bars", () => {
+ const html = barsHtml(`${REDACT_MARK.repeat(3)} ${encodePlaceholder("k***")}${SLUR_GAP}`);
+ assert.equal(html, `<span class="rbar" data-post-blanked="" style="width:1.56em"></span> <span class="slur" data-post-slur="">k***</span>`);
+});
+
+test("takeSlurBleeps (post-render.mjs): a take's state is its own or its source's; no script of its own reads the post's; refused in the build's words", async () => {
+ const { takeSlurBleeps } = await import("./post-render.mjs");
+ const script = `you ${F} there`;
+ const words = scriptTokens(script).map((t, i) => ({ w: t.w, start: i, end: i + 0.5 }));
+ const red = { terms: [], slurs: resolveSlurs({ voice: "beep" }, LIST) };
+ const entry = (takes) => ({ id: "p1", type: "post", narration: { script, takes } });
+ const tts = { file: "narration/posts/1/take-1.orpheus-zac.wav", seconds: 3, words };
+ assert.deepEqual(takeSlurBleeps(entry([tts]), tts, red), { mode: "beep", spans: [[0.96, 1.56]], seconds: 3 });
+ // Skipped at synthesis: nothing to cover -- and a take derived from it reads the same.
+ const skipped = { ...tts, slurs: "skip", words: undefined };
+ const derived = { file: "narration/posts/1/take-2.enhance-x.wav", seconds: 3, source: { kind: "take", from: "take-1.orpheus-zac" } };
+ assert.equal(takeSlurBleeps(entry([skipped, derived]), derived, red), null);
+ assert.throws(() => takeSlurBleeps(entry([{ ...tts, words: undefined }]), { ...tts, words: undefined }, red), /p1: .*no word timings to beep.*posts narrate <p> p1 --words.*--uncensored/);
+ assert.equal(takeSlurBleeps(entry([tts]), tts, { terms: [], slurs: resolveSlurs({}, LIST, { uncensored: true }) }), null);
+ assert.equal(takeSlurBleeps(entry([tts]), tts, null), null);
+});
+
+test("with read-follow: the pill sits in its word's slot inside the read's block, as a redaction bar does", () => {
+ const e = post(`First para here.\n\nThen you ${F} and more words follow here.`);
+ const html = postCardHtml(e, { width: 1280, height: 720, follow: true, redaction: { terms: [{ term: "more" }], slurs: ON } });
+ assert.match(html, /data-post-follow=/);
+ assert.ok(!html.toLowerCase().includes(F));
+ assert.match(html, /<span class="fblock" data-post-block="1"><span data-w="post:3">Then<\/span> <span data-w="post:4">you<\/span> <span data-w="post:5"><span class="slur" data-post-slur="">f\*{5}<\/span><\/span> <span data-w="post:6">and<\/span> <span data-w="post:7"><span class="rbar" data-post-blanked=""/);
+});
+
+test("with the narration mix: the beep is laid on the take's own voice before the narrator's chain, the bed and the muffle unchanged", async () => {
+ const { postSegmentArgs } = await import("./post-render.mjs");
+ const { postItemPlan, postLayout } = await import("./post-item.mjs");
+ const e = post(`you ${F} there`, { narration: { script: `you ${F} there`, takes: [{ file: "narration/posts/1/take-1.orpheus-zac.wav", seconds: 3, script: `you ${F} there` }] } });
+ const plan = postItemPlan(e, {});
+ const box = { width: 1440, height: 810 };
+ const args = (bleeps) => {
+ const argv = postSegmentArgs({
+ entry: e, box, plan, layout: postLayout(e, box), cards: { read: "/c/read.png" }, files: [], render: { fps: 30, audioRate: 48000 }, outPath: "/o/p1.mp4",
+ narration: { file: "/t/take.wav", gainDb: 0, ...(bleeps ? { bleeps } : {}) },
+ });
+ return argv[argv.indexOf("-filter_complex") + 1];
+ };
+ const plain = args(null);
+ const beeped = args({ mode: "beep", spans: [[0.96, 1.56]], seconds: 3 });
+ assert.doesNotMatch(plain, /pnbl/);
+ assert.match(beeped, /\[\d+:a\]aresample=48000,aformat=sample_fmts=fltp:channel_layouts=stereo,volume=0:enable='between\(t,0\.96,1\.56\)'\[pnbl_m\]/);
+ assert.match(beeped, /\[pnbl_m\]\[pnbl_t\]amix=inputs=2:normalize=0:duration=first\[pnbl\];\[pnbl\]aresample=48000/);
+ // Everything after the voice's input is the same mix.
+ assert.equal(beeped.slice(beeped.indexOf("[pnbl]aresample")).replace("[pnbl]", ""), plain.slice(plain.search(/\[\d+:a\]aresample/)).replace(/^\[\d+:a\]/, ""));
+});
diff --git a/umtool/report-to-video/slurs.json b/umtool/report-to-video/slurs.json
@@ -0,0 +1,21 @@
+{
+ "version": 1,
+ "about": "The slur filter's default list (post-slurs.mjs; umtool/docs/knobs.md, \"The slur filter\"). Each entry is one slur: the forms it is written in (matched whole-word, case-insensitive, with common letter swaps and letter-by-letter spacing), its level (strong: always masked when the filter is on; mild: only at level all), the masked form a card draws in place of it (default: its first letter and an asterisk for every other letter of `word`), and the words a synthesized read says for it under voice placeholder. A project adds to it and excepts from it in render.posts.slurs. Kept tight: no word that is also an ordinary English word in common use.",
+ "entries": [
+ { "id": "n-word", "level": "strong", "word": "nigger", "forms": ["nigger", "niggers", "niggerz", "nigga", "niggas", "niggaz", "niggah", "niggahs"], "say": "n-word" },
+ { "id": "f-slur", "level": "strong", "word": "faggot", "forms": ["faggot", "faggots", "faggotry", "faggoty", "faggy"], "say": "f-slur" },
+ { "id": "f-slur-short", "level": "strong", "word": "fag", "forms": ["fag", "fags"], "say": "f-slur" },
+ { "id": "t-slur", "level": "strong", "word": "tranny", "forms": ["tranny", "trannies", "trannys"], "say": "t-slur" },
+ { "id": "t-slur-troon", "level": "strong", "word": "troon", "forms": ["troon", "troons", "troony"], "say": "t-slur" },
+ { "id": "k-slur", "level": "strong", "word": "kike", "forms": ["kike", "kikes"], "say": "k-slur" },
+ { "id": "s-slur", "level": "strong", "word": "spic", "forms": ["spic", "spics"], "say": "s-slur" },
+ { "id": "w-slur", "level": "strong", "word": "wetback", "forms": ["wetback", "wetbacks"], "say": "w-slur" },
+ { "id": "g-slur", "level": "strong", "word": "gook", "forms": ["gook", "gooks"], "say": "g-slur" },
+ { "id": "b-slur", "level": "strong", "word": "beaner", "forms": ["beaner", "beaners"], "say": "b-slur" },
+ { "id": "r-slur-raghead", "level": "strong", "word": "raghead", "forms": ["raghead", "ragheads"], "say": "slur" },
+ { "id": "t-slur-towelhead", "level": "strong", "word": "towelhead", "forms": ["towelhead", "towelheads"], "say": "slur" },
+ { "id": "r-word", "level": "mild", "word": "retard", "forms": ["retard", "retards", "retarded"], "say": "r-word" },
+ { "id": "r-word-short", "level": "mild", "word": "tard", "forms": ["tard", "tards"], "say": "r-word" },
+ { "id": "s-slur-shemale", "level": "mild", "word": "shemale", "forms": ["shemale", "shemales"], "say": "slur" }
+ ]
+}