// ONE POST's TAKE, AS ASKED OF THE EDITOR (lane reads-find, the orchestrator's ruling 3: the queue's read of a post is // the same ask a bench press makes): the voice (readVoice.mjs: the one asked for, the item's own character, the // project's characters and voice map, the cast, the narrator), the speed (the one asked for, the item's own, the // character's; none for Orpheus), the tuning (post-say.mjs tuningAskOf: the line's own values over the character's, // field by field, and whose it is) and what the voice SAYS (post-redact.mjs spokenRead: the redaction, the slurs, the // lexicon, an anonymous handle as its shown name). The bench's take op (app/api/report/post-narration) and // `umtool posts narrate

--take` (makeTake) both build their ask here; the re-read queue asks through // makeTake with the bench's slur rule, so the two can never drift apart. // // THE SLURS: the bench cannot word-time a take as it is made, so a cut that BEEPS a slur has it left out of a bench // read (`benchSlurVoice`); the CLI's own --take says it and times its words for the beep (makeTake). // // Plain ESM: the CLI runs it under bare node. import { postNarrationKnobs } from "umtool-report-to-video/post-narration"; import { spokenRead } from "umtool-report-to-video/post-redact"; import { tuningAskOf } from "umtool-report-to-video/post-say"; /** The slur filter's voice for a read made on the bench (and by the re-read queue): a beep falls back to skip. */ export const benchSlurVoice = (red) => (red?.slurs?.voice === "beep" ? "skip" : undefined); /** * THE ASK: `{ engine, voice, speed, speedAsked, tuning, tuningAsked, tuningOwn, reading, said }` -- `said` spokenRead's * result; askBody makes the editor's tts op body of it. `speed`/`tuning`/`reading` are the press's own (null: none); * `slurVoice` the slur rule (benchSlurVoice for a bench read; undefined: the cut's own). * * @param {{ id: string, dir: string }} project * @param {Record} e * @param {{ render?: Record, script: string, engine?: string | null, voice?: string | null, speed?: number | null, * tuning?: Record | null, reading?: number | null, red: any, slurVoice?: string }} o */ export async function postTakeAskOf(project, e, { render = {}, script, engine = null, voice = null, speed = null, tuning = null, reading = null, red, slurVoice = undefined }) { const k = postNarrationKnobs(e, render); const { itemReadVoice } = await import("./readVoice.mjs"); const v = await itemReadVoice(project, e, { render, engine, voice }); const eng = String(v.engine ?? k.engine); const vox = String(v.voice ?? k.voice); // Its speed: the press's, else the item's own (`narration.speed`), else its character's -- none for Orpheus. const asked = speed ?? e.narration?.speed ?? v.speed ?? null; // A speed only when it is a number other than 0 (a falsy or NaN one left out, as the bench always left it). const n = asked === null || asked === undefined || eng === "orpheus" ? null : Number(asked); const spd = n !== null && Number.isFinite(n) && n ? n : null; const speedAsked = spd === null ? undefined : speed !== null && speed !== undefined ? true : e.narration?.speed != null ? "item" : "preset"; // Its tuning: the line's own values over its character's, field by field; whose it is; the line's own as asked. const ta = tuningAskOf({ own: tuning, preset: v.tuning ?? null, engine: eng }); const said = spokenRead(script, e, red, slurVoice ? { voice: slurVoice } : {}); return { engine: eng, voice: vox, speed: spd, speedAsked, tuning: ta.tuning, tuningAsked: ta.asked, tuningOwn: ta.own, reading: reading ?? null, said }; } /** The editor's tts op body of an ask, writing `out` (`text`: other words than the ask's, e.g. a slur left out). */ export const askBody = (a, out, text = a.said.text) => ({ text, engine: a.engine, voice: a.voice, out, ...(a.speed !== null ? { speed: a.speed } : {}), ...(a.tuning ? { tuning: a.tuning } : {}), ...(a.reading !== null ? { reading: a.reading } : {}), }); /** * THE BENCH's TAKE OP's ASK (app/api/report/post-narration, op "take"): from the POST's body -- its engine and voice * when named, its speed when given -- with the press's tuning and reading (checked by the route) and the bench's slur * rule. The route builds with this; the parity test compares the queue's read with it. * * @param {{ id: string, dir: string }} project * @param {Record} e * @param {{ manifest: any, script: string, body: Record, tuning?: Record | null, reading?: number | null, red: any }} o */ export function benchTakeAskOf(project, e, { manifest, script, body, tuning = null, reading = null, red }) { return postTakeAskOf(project, e, { render: manifest?.render ?? {}, script, engine: typeof body.engine === "string" && body.engine ? body.engine : null, voice: typeof body.voice === "string" && body.voice ? body.voice : null, speed: body.speed === undefined || body.speed === null ? null : Number(body.speed), tuning, reading: reading === null || reading === undefined ? null : Number(reading), red, slurVoice: benchSlurVoice(red), }); }