import { getPaths } from "yt-dlp-transcript-common/lib/paths"; import { VOICE_ENHANCE_BODY_KEYS, enqueueVoiceFile, } from "yt-dlp-transcript-common/controller/voiceFile"; import { jobResponse, ops } from "../_lib"; export const dynamic = "force-dynamic"; // POST { file, out, engine?, params?, parts? } -> { ok: true, jobId } // // Clean up a speech recording — denoise, soften the room, level it — as a job // on /jobs (`voice-enhance`, the `voice` queue, one at a time, the engine run // behind the heavy slot). `file` is an absolute path to the recording (`path` // is the same key), `out` an absolute .wav path the result is written to: 48 // kHz mono 16-bit, exactly as long as the input. `engine` is `deepfilternet` // (DeepFilterNet 3; `archilyzer voice setup --engine deepfilternet`) or // `rnnoise` (nothing to install), default settings.voice.enhance.engine; // `params` its knobs (common/lib/voiceApps.ts); `parts` a take recorded part by // part, `[{file, out}]`, each enhanced the same way. umtool's derived takes // (`umtool posts narrate … --derive --op enhance`) are the caller. // // The job's log ends with the result as ONE line, `@@voice-result {json}` // (`{op, engine, wav, seconds, samples, sampleRate, engineMs, durationMs, // waitedMs, gainDb, params, parts?, synthetic}`); `pnpm ops voice-enhance // --wait` prints that JSON on stdout. // // AN ADAPTER: every refusal is the controller's (controller/voiceFile.ts) — an // unknown engine or knob, an engine not installed, a file that is not audio or // is over 30 minutes, an `out` inside the corpus or in a directory that does // not exist. export async function POST(request: Request) { return ops(request, VOICE_ENHANCE_BODY_KEYS, async (body) => jobResponse(await enqueueVoiceFile("enhance", body, { paths: getPaths() })), ); }