import { getPaths } from "yt-dlp-transcript-common/lib/paths"; import { TRANSCRIBE_FILE_BODY_KEYS, enqueueTranscribeFile, } from "yt-dlp-transcript-common/controller/transcribeFile"; import { jobResponse, ops } from "../_lib"; export const dynamic = "force-dynamic"; // POST { path, start?, end?, workerId?, out? } -> { ok: true, jobId } // // Transcribe ONE local file — or the window [start, end) seconds of it — on a // local transcription worker, as a job on /jobs: the engine, model and // command line the corpus uses, never a hand-run whisper or parakeet. No // `workerId` = the worker auto-transcribe would get (the pool's highest-priority // free local one). // // The job's log ends with the result as ONE line, `@@transcribe-result // {json}`: `{version, path, window, worker: {id, name, appId, model, device}, // transcriptFormat, transcribedAt, durationMs (the engine's time), waitedMs (the // wait for a free worker), cues: [{start, end, text}], // text}`, cue times on the SOURCE file's clock. `pnpm ops transcribe --wait` // prints that JSON on stdout. `out` writes it to that file as well. // // AN ADAPTER: every refusal is the controller's (controller/transcribeFile.ts) // — a relative or unreadable `path`, `end` not after `start`, an unknown or // non-local `workerId`, a named worker switched off, an `out` inside the corpus // (resolved through symlinks) or in a directory that does not exist. export async function POST(request: Request) { return ops(request, TRANSCRIBE_FILE_BODY_KEYS, async (body) => jobResponse(await enqueueTranscribeFile(body, { paths: getPaths() })), ); }