import { mkdir, mkdtemp, readFile, readdir, rm, stat, writeFile } from "node:fs/promises"; import path from "node:path"; import { POST_DERIVE_OPS, POST_DERIVE_ROUTES, derivedFileOf, isNarrated, nextReadingOf, nextTakeNumber, pickedTake, postIdOf, takeFileOf, takeIdOf, takesDirOf, } from "umtool-report-to-video/post-narration"; import { postItemPlan } from "umtool-report-to-video/post-item"; import { jobState, resultLine, startJob } from "@/lib/research/case-editor"; import { withEditNotes } from "@/lib/report/guard"; import { StaleToken, StructureRefused, fitPostItems, manifestToken, undoStructural, updatePostNarration } from "@/lib/report/manifest.mjs"; import { resolveReport } from "@/lib/report/serve.mjs"; import { readManifest } from "@/lib/projects/report.mjs"; import { refuseCaller } from "@/lib/report/caller"; import { crossSiteRefusal } from "@/lib/report/sameOrigin.mjs"; import { deleteTake, measureTake, tunedOfResult } from "@/lib/report/postNarrationCli.mjs"; import { parseTtsTuning, ttsReadingError } from "yt-dlp-transcript-common/lib/ttsTuning.mjs"; import { parseTempoSpec, rereadTake } from "@/lib/report/postReread.mjs"; import { parsePauseSpec, pauseTake } from "@/lib/report/postPause.mjs"; import { withTakeScope } from "@/lib/report/takeScope.mjs"; import { isTakeId } from "@/lib/report/takes.mjs"; import { keepRecording, RECORD_LABEL_RE } from "@/lib/report/postRecord.mjs"; import { fitPostItem } from "@/lib/report/postFit.mjs"; import { askBody, benchSlurVoice, benchTakeAskOf } from "@/lib/report/postTakeAsk.mjs"; import { readAgainArgv } from "@/lib/report/readAgainArgv.mjs"; import { projectRedaction } from "@/lib/report/postRedaction.mjs"; import { spokenRead } from "umtool-report-to-video/post-redact"; import { characterById, recordedPresetOf, shownNameOf } from "umtool-report-to-video/cast"; import { readLayers, recordedTrimFor } from "@/lib/report/characterLayers.mjs"; import { convertAskOf, derivePitchOf, deriveRefusalOf, stepPitchOf } from "@/lib/report/derivePitch.mjs"; import { getJob, runningJob, startJob as startUmtoolJob, type Job } from "@/lib/jobs"; import { UMTOOL_DIR } from "@/lib/report/driver.mjs"; import { renderWaitSentence } from "@/lib/report/renderMode.mjs"; export const dynamic = "force-dynamic"; /** The slur filter's voice for a take synthesized on the bench: beep falls back to skip (lib/report/postTakeAsk.mjs, one rule). */ const benchVoice = (red: { slurs?: { voice?: string } | null } | null) => benchSlurVoice(red) 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. // // GET ?project the cut's narration progress: each post item, // what plays (recorded, synthesized, none), approved // GET ?project&id&job&file[¬e][&script] a synthesized take's job; once done, the take is // kept (measured, appended and picked) // POST multipart {project, id, label, script?, note?, part[] (audio), text[], para[]} // a RECORDING, part by part: trimmed, joined, // levelled, kept as take-.recorded-