import { getPaths } from "yt-dlp-transcript-common/lib/paths"; import { VOICE_CONVERT_BODY_KEYS, enqueueVoiceFile, } from "yt-dlp-transcript-common/controller/voiceFile"; import { jobResponse, ops } from "../_lib"; export const dynamic = "force-dynamic"; // POST { file, out, voice?, engine?, pitch?, semitones?, params?, parts? } -> { ok: true, jobId } // // Keep a recording's PERFORMANCE — its timing, pitch contour and emphasis — // and give it a STOCK synthetic voice's timbre, as a job on /jobs // (`voice-convert`, the `voice` queue, one at a time, the engine run behind // the heavy slot). `voice` (or `target`) names the stock voice, // `:` — `orpheus:zac`, `orpheus:leah`, // `kokoro:am_michael` — default settings.voice.convert.target. A FILE, A PATH // OR A RECORDING IS REFUSED as a target, whatever it holds: these engines would // make anyone's voice from seconds of it, so the only voices that come out are // voices no person owns. The target's reference clip (the stock voice reading a // fixed public-domain passage) is asked of the tts op the first time and kept. // `engine` is `openvoice` (OpenVoice v2's converter) or `seed-vc` (Seed-VC v1), // default settings.voice.convert.engine — `archilyzer voice setup --engine // ` installs one; `file`/`path`, `out`, `params` and `parts` as for // voice-enhance. `pitch` says where the result's pitch comes from — `target` // (the stock voice's own: the read's intonation is flattened to it), `source` // (the pitch the take was read at) or `contour` (the read's rises and falls at // the stock voice's register) — and `semitones` (-12 to 12) moves a followed // one; defaults settings.voice.convert. source and contour are seed-vc's, on // its optional f0 model (`archilyzer voice setup --engine seed-vc --with f0`). umtool's derived takes (`umtool posts narrate … --derive // --op convert`) are the caller. // // The job's log ends with `@@voice-result {json}` — voice-enhance's shape plus // `target`, `synthetic: true` and the `disclosure` line. // // AN ADAPTER: every refusal is the controller's (controller/voiceFile.ts). export async function POST(request: Request) { return ops(request, VOICE_CONVERT_BODY_KEYS, async (body) => jobResponse(await enqueueVoiceFile("convert", body, { paths: getPaths() })), ); }