commit 55053e8246097d25bba98bdea5d6261aea208583
parent 61b5162c260e4a0a84a555ae5406a8d5761cca0b
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 11 Nov 2026 17:02:43 -0500
voice-convert: pitch and semitones on the op, settings.voice.convert defaults, and seed-vc's f0 files as an optional setup group (--with f0) -- openvoice refuses a pitch, a missing f0 model names its setup command, the f0 run declares its own estimate
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat:
14 files changed, 606 insertions(+), 61 deletions(-)
diff --git a/COMMANDS.md b/COMMANDS.md
@@ -103,7 +103,7 @@ Run from the repo root (in the container: `docker compose exec editor pnpm archi
| `archilyzer docs cli` | `[--check]` | write COMMANDS.md from this command table and `pnpm ops --help` |
| `archilyzer settings example` | `[--check]` | write settings.json.example + SETTINGS.md from the schema |
| `archilyzer tts setup` | `[--engine kokoro\|orpheus\|espeak-ng] [--from <dir>] [--python <py>] [--check]` | install a text-to-speech engine under settings.tts.home/<engine> (default ~/.local/share/archilyzer/tts/<engine>): a python venv with its pinned packages (uv venv --python 3.12 when uv is on PATH, else --python <py> -m venv) — kokoro-onnx for kokoro, onnxruntime and numpy for orpheus — and its model files, downloaded once (kokoro: the kokoro-onnx model-files-v1.0 release; orpheus: the Q8\_0 GGUF and the SNAC decoder from Hugging Face, 3.5 GB) one stream at a time with no retries, verified by size and sha256; --from <dir> takes already-downloaded model files from <dir> instead (hard links where it can, else copies; verified the same way); orpheus's llama-server is not installed here (settings.tts.orpheus.serverBin) but is checked; --check installs nothing, lists what is missing and exits 1 when anything is |
-| `archilyzer voice setup` | `--engine deepfilternet\|openvoice\|seed-vc\|rnnoise [--from <dir>] [--python <py>] [--home <dir>] [--dry-run] [--check]` | install a voice engine under settings.voice.home/<engine> (default ~/.local/share/archilyzer/voice/<engine>), saying first what it fetches and how big: deepfilternet is DeepFilterNet's static binary (v0.5.6, 36 MB, its GitHub release); openvoice and seed-vc are a python 3.12 venv (uv venv when uv is on PATH, else --python <py> -m venv) with torch 2.4.0's CPU wheels and their pinned packages, the engine's code at a pinned commit (git fetch --depth 1), and its weights from Hugging Face (openvoice: the v2 converter, 131 MB; seed-vc: the DiT, whisper-small, BigVGAN v2 and CAM++, 1.9 GB) — one download at a time with no retries, each verified by size and sha256; rnnoise needs nothing (ffmpeg's arnndn and the model in the repo) and setup says whether ffmpeg has it; --from <dir> takes already-downloaded files from <dir>/<name> (hard links where it can); --home installs elsewhere (then point settings.voice.home at it); --dry-run says what it would fetch and stops; --check installs nothing, lists what is missing and exits 1 when anything is |
+| `archilyzer voice setup` | `--engine deepfilternet\|openvoice\|seed-vc\|rnnoise [--with f0] [--from <dir>] [--python <py>] [--home <dir>] [--dry-run] [--check]` | install a voice engine under settings.voice.home/<engine> (default ~/.local/share/archilyzer/voice/<engine>), saying first what it fetches and how big: deepfilternet is DeepFilterNet's static binary (v0.5.6, 36 MB, its GitHub release); openvoice and seed-vc are a python 3.12 venv (uv venv when uv is on PATH, else --python <py> -m venv) with torch 2.4.0's CPU wheels and their pinned packages, the engine's code at a pinned commit (git fetch --depth 1), and its weights from Hugging Face (openvoice: the v2 converter, 131 MB; seed-vc: the DiT, whisper-small, BigVGAN v2 and CAM++, 1.9 GB; --with f0 adds seed-vc's OPTIONAL f0-conditioned 44.1 kHz model, its BigVGAN and the RMVPE pitch tracker, 1.49 GB — what voice-convert's pitch source and contour run on, and an install without it still converts at the target's pitch) — one download at a time with no retries, each verified by size and sha256; rnnoise needs nothing (ffmpeg's arnndn and the model in the repo) and setup says whether ffmpeg has it; --from <dir> takes already-downloaded files from <dir>/<name> (hard links where it can); --home installs elsewhere (then point settings.voice.home at it); --dry-run says what it would fetch and stops; --check installs nothing, lists what is missing and exits 1 when anything is (an optional group is said, and counted only with --with) |
| `archilyzer service install` | `[--mode docker\|host] [--apps <a,b>] [--sites <id>:<port>,…] [--overlays <name,…>\|none] [--bind <host>] [--editor-port <n>] [--umtool-port <n>] [--editor-memory <N>G] [--umtool-memory <N>G] [--idle-boot] [--no-housekeeping] [--linger] [--no-start] [--force] [--dry-run]` | install the apps as systemd USER units and start them: docker mode (the default when `docker compose` answers) is ONE unit, archilyzer.service, running `docker compose up` in the foreground with a profile per --apps (editor, umtool, site, homepage, ollama; default editor) and the overlays given or found (anthropic when the key file exists, storage when docker-compose.storage.yml does); host mode is archilyzer-editor.service and archilyzer-umtool.service (node running `next start` from the app dir, -H --bind default 0.0.0.0, ports 3001/3050, MemoryHigh/Max sized from MemTotal) plus archilyzer-site-<id>.service per --sites (a built bundle on 127.0.0.1) and archilyzer-housekeeping.timer, weekly and Persistent, starting the oneshot archilyzer-housekeeping.service (`archilyzer housekeeping --by timer`; a run the heavy slot turns away exits 75 and is retried hourly for a day; --no-housekeeping leaves the pair out); each unit refuses to start while its build or image is missing. A unit already installed under the same name is ADOPTED when identical and shown as a diff and refused when not (--force replaces it; a running unit is not restarted); --no-start enables without starting; --linger runs loginctl enable-linger (start at boot with nobody logged in); --dry-run prints the units and commands and writes nothing. Linux and systemd only |
| `archilyzer service status` | | read-only: each installed archilyzer unit's state, enablement and pid; for an app its build id, its port and what / answers; the transcription lane's held state; in docker mode each container; for archilyzer-housekeeping.timer its next and last trigger and the last recorded run |
| `archilyzer service logs` | `[--apps <a,b>] [--lines <n>] [--follow]` | the units' journal (journalctl --user), the last 200 lines by default |
@@ -184,7 +184,7 @@ Drives a running editor over HTTP (`/api/ops/*`, the same actions its pages run)
| `transcribe` | transcribe runs ONE local file through a local transcription worker, as a job: {"path": "/abs/file"} (audio or video), "start"/"end" (seconds) for a window, "workerId" (a settings worker id; default: the one auto-transcribe would get), "out" (an absolute path for the result JSON, never inside the corpus). The result is {path, window, worker: {id, appId, model, device}, cues: \[{start, end, text}\], text, ...}, cue times on the file's own clock. "words": true adds words: \[{w, start, end, conf?}\] on the same clock -- from parakeet, which keeps its word timestamps; \[\] from an engine that does not. "whilePaused": true runs it during a pause-all on a worker the pause alone switched off (never one drained, degraded or disabled by hand); the pause stays on. With --wait it is printed on stdout (the response and the log go to stderr), so `pnpm ops transcribe ... --wait \| jq -r .text` works. | `pnpm ops transcribe --json '{"path":"/abs/clip.mp4","start":120,"end":150}' --wait`<br>`pnpm ops transcribe --json '{"path":"/abs/a.wav","workerId":"parakeet-cpu","out":"/tmp/a.json"}' --wait` |
| `tts` | tts speaks a line with a local text-to-speech engine and a STOCK voice, as a job on the `tts` queue: {"text": "..."} or {"file": "/abs/script.txt"} (UTF-8, at most 20,000 characters), "engine" (kokoro \| orpheus \| espeak-ng), "voice" (one of the engine's stock voices; kokoro: af\_heart, bm\_george, ...; orpheus: leah, zac, ...), "speed" (0.5-2; orpheus has none) — defaults from settings.tts (kokoro, af\_heart, 1) — and "out" (an absolute .wav path the result is copied to, never inside the corpus). The expressive tags <laugh> <chuckle> <sigh> <cough> <sniffle> <groan> <yawn> <gasp> are performed by orpheus and stripped for the others; any other <...> is refused. Numbers, years, money and times are spoken (2024: "twenty twenty-four"). The result is {wav, seconds, engine, voice, cached, durationMs, waitedMs, sha, sampleRate, speed, disclosure}: wav is the 48 kHz mono WAV the editor wrote (out, or its cache), disclosure the line a narrated export carries. The same ask again is answered from the cache (cached: true, no engine run). Kokoro and orpheus need `archilyzer tts setup [--engine orpheus]` first; orpheus runs on the GPU (a local llama-server the editor starts and stops) and waits while a transcription holds it. With --wait the result is printed on stdout. | `pnpm ops tts --json '{"text":"In 2024 the archive spoke."}' --wait`<br>`pnpm ops tts --json '{"file":"/abs/script.txt","voice":"bm_george","out":"/abs/line.wav"}' --wait` |
| `voice-enhance` | voice-enhance cleans a speech recording up (denoise, soften the room, level it) as a job on the `voice` queue, behind the heavy slot: {"file": "/abs/take.wav", "out": "/abs/clean.wav"} (never inside the corpus; 48 kHz mono, exactly as long as the input), "engine" (deepfilternet \| rnnoise; settings.voice), "params" (the engine's knobs: lufs, highpass, attenLimDb, postFilter, mix), "parts" (\[{file, out}\], a take recorded part by part). deepfilternet needs `archilyzer voice setup --engine deepfilternet`; rnnoise needs nothing. The result is {op, engine, wav, seconds, samples, sampleRate, engineMs, durationMs, waitedMs, gainDb, params, parts?, synthetic}; with --wait it is printed on stdout. | |
-| `voice-convert` | voice-convert keeps a recording's performance (timing, pitch contour) and swaps its timbre for a STOCK synthetic voice, as voice-enhance's job: the same body plus "voice" — "<tts engine>:<stock voice>" (orpheus:zac, orpheus:leah, kokoro:am\_michael, ...; settings.voice.convert.target); a file, a path or a recording is REFUSED as a target (no real person's voice) — and "engine" (openvoice \| seed-vc, each installed by `archilyzer voice setup --engine <id>`). The target's reference is synthesized once through the tts op and kept. The result adds target, voice, synthetic: true and the disclosure line. | |
+| `voice-convert` | voice-convert keeps a recording's performance (timing, pitch contour) and swaps its timbre for a STOCK synthetic voice, as voice-enhance's job: the same body plus "voice" — "<tts engine>:<stock voice>" (orpheus:zac, orpheus:leah, kokoro:am\_michael, ...; settings.voice.convert.target); a file, a path or a recording is REFUSED as a target (no real person's voice) — and "engine" (openvoice \| seed-vc, each installed by `archilyzer voice setup --engine <id>`). "pitch" is where the result's pitch comes from (settings.voice.convert.pitch): "target" — the stock voice's own, the read's intonation flattened to it; "source" — the pitch the take was read at (raise your voice and it rises); "contour" — the read's rises and falls, moved as a whole to the stock voice's register. "semitones" (-12 to 12) then moves a followed pitch. source and contour are seed-vc's, on its optional f0 model (`archilyzer voice setup --engine seed-vc --with f0`; slower, 44.1 kHz); openvoice refuses them. The target's reference is synthesized once through the tts op and kept. The result adds target, voice, pitch (semitones and f0 — the medians heard and the move applied — when followed), synthetic: true and the disclosure line. | |
| `settings` | settings patches settings.json through the editor's one writer: {"patch": {"<top-level key>": value, …}} (SETTINGS.md). A block's keys merge one level; an array, a scalar or an object nested in a block replaces. Refused before anything is written: an unknown key; a key another writer owns (channelPriority, autoQueue, workers, storage — the refusal names it); a value the schema would not keep as sent (clamped, dropped), named with what would be saved. Answers the saved values. | `pnpm ops settings --json '{"patch":{"diarization":{"cleanAfterCapture":true}}}'`<br>`pnpm ops settings --json '{"patch":{"minFreeDiskGB":20}}'` |
| `clear-platform-hold` | clear-platform-hold clears a platform's rate-limit hold, backoff and raised pace, as the lane strip's Clear hold: {"platform"}. Answers the sentence. | |
| `recheck-service` | recheck-service asks a service whose cookie refresh alert is up ONE request through its own path, as the dashboard banner's Recheck: {"service"} ("rumble", "youtube", "odysee", "archive.today", "x" or a forum host). Waits for it: {jobId, result: "clean" \| "stale" \| "failed", message}; "clean" clears the alert (and a yt-dlp service's backoff, as any clean request). For "x" it sends X NO request: clean when the login on disk was renewed after the alert (Refresh cookies on /settings) — for a jar-age alert, when the jar is within social.x.maxCookieAgeMinutes. The editor also rechecks by itself on a timer (settings.serviceCookies.recheckIntervalMinutes, default 180, 0 = off; `pnpm ops settings --json '{"patch":{"serviceCookies":{"recheckIntervalMinutes":0}}}'`). dismiss-service clears a service's cookie alert by hand: {"service"}. rerun-service-jobs retries every job a service's cookie alert stopped, once it is OK again: {"service"} -> {jobIds, skipped}. --wait follows them. | `pnpm ops recheck-service --json '{"service":"rumble"}'`<br>`pnpm ops recheck-service --json '{"service":"x"}'` |
diff --git a/SETTINGS.md b/SETTINGS.md
@@ -1057,8 +1057,8 @@ The voice ops (release 39): a speech recording ENHANCED (denoised, de-reverbed,
| `home` | `""` | Where `archilyzer voice setup` installs the voice engines, one directory per engine (`<home>/deepfilternet`: its binary; `<home>/openvoice`, `<home>/seed-vc`: a python venv, a pinned checkout and the weights), and where the stock targets' reference clips are kept (`<home>/targets/`). Blank = `~/.local/share/archilyzer/voice`. Absolute, or `~/`-relative. |
| `threads` | `4` | CPU threads a torch engine (openvoice, seed-vc) may use. 1–16. |
| `enhance` | object — see below | The enhance op's default engine. See VoiceEnhanceSettings (`voice.enhance` below). |
-| `convert` | object — see below | The convert op's default engine and target. See VoiceConvertSettings (`voice.convert` below). |
-| `heavyEstimateMB` | object — see below | Per engine id: the memory (MB) its job is admitted to the machine's heavy slot with (`queue-lock --heavy --estimate`) — it runs only when that much is free above the floor. The defaults are the 2026-11-03 bake-off's measured peaks plus a margin. An engine left out takes its default; 0 declares nothing (the job then runs ALONE in the slot). |
+| `convert` | object — see below | The convert op's default engine, target and pitch. See VoiceConvertSettings (`voice.convert` below). |
+| `heavyEstimateMB` | object — see below | Per engine id: the memory (MB) its job is admitted to the machine's heavy slot with (`queue-lock --heavy --estimate`) — it runs only when that much is free above the floor. The defaults are the 2026-11-03 bake-off's measured peaks plus a margin; `seed-vc-f0` is seed-vc's run when it follows the input's pitch (`pitch: source \| contour` — another, bigger model; measured 2026-11-11). An engine left out takes its default; 0 declares nothing (the job then runs ALONE in the slot). |
#### `voice.enhance`
@@ -1072,6 +1072,8 @@ The voice ops (release 39): a speech recording ENHANCED (denoised, de-reverbed,
|---|---|---|
| `engine` | `"openvoice"` | The engine `voice-convert` uses when the request names none: `openvoice` (OpenVoice v2's tone-colour converter, MIT, light) or `seed-vc` (Seed-VC v1, GPL-3.0, a closer timbre match, slower). Both run on the CPU; `archilyzer voice setup --engine <id>` installs one. An unknown id falls back to the default. |
| `target` | `"orpheus:zac"` | The stock synthetic voice a conversion lands on when the request names none: `<tts engine>:<stock voice>` (`orpheus:zac`, `orpheus:leah`, `kokoro:am_michael`, …). Never a file or a recording — no real person's voice is a target. Its reference clip is synthesized once through the `tts` op and kept under `home`. Anything else falls back to `orpheus:zac`. |
+| `pitch` | `"target"` | The pitch a conversion lands on when the request names none — for an engine that can follow the input's (seed-vc, with its optional f0 model: `archilyzer voice setup --engine seed-vc --with f0`; openvoice always lands on the target's). `target`: the stock voice's own pitch — the read's intonation is flattened to it (what there was before). `source`: the pitch the take was read at — raise your voice and the result rises. `contour`: the read's rises and falls, moved as a whole so their median sits on the stock voice's. Anything else falls back to `target`. |
+| `semitones` | `0` | Semitones a FOLLOWED pitch (`source`, `contour`) is moved by when the request names none: -12 to 12, 0 = as followed. Ignored for `target`. |
Default:
@@ -1084,13 +1086,16 @@ Default:
},
"convert": {
"engine": "openvoice",
- "target": "orpheus:zac"
+ "target": "orpheus:zac",
+ "pitch": "target",
+ "semitones": 0
},
"heavyEstimateMB": {
"deepfilternet": 400,
"rnnoise": 300,
"openvoice": 2000,
- "seed-vc": 3500
+ "seed-vc": 3500,
+ "seed-vc-f0": 4500
}
}
```
diff --git a/common/bin/archilyzer.ts b/common/bin/archilyzer.ts
@@ -1131,11 +1131,12 @@ export const COMMANDS: Command[] = [
{
path: ["voice", "setup"],
usage:
- "--engine deepfilternet|openvoice|seed-vc|rnnoise [--from <dir>] [--python <py>] [--home <dir>] [--dry-run] [--check] install a voice engine under settings.voice.home/<engine> (default ~/.local/share/archilyzer/voice/<engine>), saying first what it fetches and how big: deepfilternet is DeepFilterNet's static binary (v0.5.6, 36 MB, its GitHub release); openvoice and seed-vc are a python 3.12 venv (uv venv when uv is on PATH, else --python <py> -m venv) with torch 2.4.0's CPU wheels and their pinned packages, the engine's code at a pinned commit (git fetch --depth 1), and its weights from Hugging Face (openvoice: the v2 converter, 131 MB; seed-vc: the DiT, whisper-small, BigVGAN v2 and CAM++, 1.9 GB) — one download at a time with no retries, each verified by size and sha256; rnnoise needs nothing (ffmpeg's arnndn and the model in the repo) and setup says whether ffmpeg has it; --from <dir> takes already-downloaded files from <dir>/<name> (hard links where it can); --home installs elsewhere (then point settings.voice.home at it); --dry-run says what it would fetch and stops; --check installs nothing, lists what is missing and exits 1 when anything is",
- flags: { engine: "string", from: "string", python: "string", home: "string", "dry-run": "boolean", check: "boolean" },
+ "--engine deepfilternet|openvoice|seed-vc|rnnoise [--with f0] [--from <dir>] [--python <py>] [--home <dir>] [--dry-run] [--check] install a voice engine under settings.voice.home/<engine> (default ~/.local/share/archilyzer/voice/<engine>), saying first what it fetches and how big: deepfilternet is DeepFilterNet's static binary (v0.5.6, 36 MB, its GitHub release); openvoice and seed-vc are a python 3.12 venv (uv venv when uv is on PATH, else --python <py> -m venv) with torch 2.4.0's CPU wheels and their pinned packages, the engine's code at a pinned commit (git fetch --depth 1), and its weights from Hugging Face (openvoice: the v2 converter, 131 MB; seed-vc: the DiT, whisper-small, BigVGAN v2 and CAM++, 1.9 GB; --with f0 adds seed-vc's OPTIONAL f0-conditioned 44.1 kHz model, its BigVGAN and the RMVPE pitch tracker, 1.49 GB — what voice-convert's pitch source and contour run on, and an install without it still converts at the target's pitch) — one download at a time with no retries, each verified by size and sha256; rnnoise needs nothing (ffmpeg's arnndn and the model in the repo) and setup says whether ffmpeg has it; --from <dir> takes already-downloaded files from <dir>/<name> (hard links where it can); --home installs elsewhere (then point settings.voice.home at it); --dry-run says what it would fetch and stops; --check installs nothing, lists what is missing and exits 1 when anything is (an optional group is said, and counted only with --with)",
+ flags: { engine: "string", with: "string", from: "string", python: "string", home: "string", "dry-run": "boolean", check: "boolean" },
run: async ({ flags }) =>
(await import("./voice-setup")).main({
...(typeof flags.engine === "string" ? { engine: flags.engine } : {}),
+ ...(typeof flags.with === "string" ? { with: flags.with.split(",").map((x) => x.trim()).filter(Boolean) } : {}),
...(typeof flags.from === "string" ? { from: flags.from } : {}),
...(typeof flags.python === "string" ? { python: flags.python } : {}),
...(typeof flags.home === "string" ? { home: flags.home } : {}),
diff --git a/common/bin/voice-setup.test.ts b/common/bin/voice-setup.test.ts
@@ -1,10 +1,11 @@
import { test, after } from "node:test";
import assert from "node:assert/strict";
-import { mkdtemp, mkdir, rm, writeFile } from "node:fs/promises";
+import { mkdtemp, mkdir, open, rm, writeFile } from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import { main, voiceSetupPlan } from "./voice-setup";
-import { VOICE_ENGINES } from "../lib/voiceApps";
+import { SEEDVC_F0_FILES, SEEDVC_FILES, VOICE_ENGINES } from "../lib/voiceApps";
+import { VOICE_CODE_MARKER, voiceGroupState, voiceInstallState } from "../lib/voiceInstall";
// Run with:
// pnpm --filter yt-dlp-transcript-common exec tsx --test bin/voice-setup.test.ts
@@ -32,7 +33,16 @@ test("the plan names every file, its size and its source, and the total", () =>
assert.ok(plan.some((l) => /a python 3\.12 venv \(uv\), with: torch==2\.4\.0\+cpu/.test(l)));
assert.ok(plan.some((l) => /the code: https:\/\/github\.com\/Plachtaa\/seed-vc at 51383efd/.test(l)));
assert.ok(plan.some((l) => /whisper-small\/model\.safetensors — 967\.0 MB from https:\/\/huggingface\.co\/openai\/whisper-small\/resolve\/973afd24/.test(l)));
- assert.match(plan.at(-1)!, /files: 1\.88 GB/);
+ // The optional f0 group is listed after the total, not fetched or counted…
+ const total = plan.findIndex((l) => /^ {2}files: /.test(l));
+ assert.match(plan[total], /files: 1\.88 GB/);
+ assert.match(plan[total + 1], /optional, not fetched without `--with f0` — the f0-conditioned 44\.1 kHz model/);
+ assert.ok(plan.slice(total).some((l) => /rmvpe\.pt — 181\.2 MB from https:\/\/huggingface\.co\/lj1995\/VoiceConversionWebUI\/resolve\/e6d0c1a1/.test(l)));
+ assert.match(plan.at(-1)!, /1\.49 GB more/);
+ // …and with --with f0 it is part of what is fetched.
+ const withF0 = voiceSetupPlan(VOICE_ENGINES["seed-vc"], ["f0"]);
+ assert.ok(withF0.some((l) => /bigvgan-44k\/bigvgan_generator\.pt — 489\.0 MB from https:\/\/huggingface\.co\/nvidia\/bigvgan_v2_44khz_128band_512x\/resolve\/95a9d1dc/.test(l)));
+ assert.match(withF0.at(-1)!, /files: 3\.38 GB/);
assert.match(voiceSetupPlan(VOICE_ENGINES.deepfilternet).at(-1)!, /files: 36\.4 MB$/);
assert.match(voiceSetupPlan(VOICE_ENGINES.rnnoise)[0], /nothing to download/);
});
@@ -55,6 +65,58 @@ test("--check over an empty home lists what is missing and exits 1", async () =>
assert.match(c.lines.join("\n"), /DeepFilterNet 3 at .*empty\/deepfilternet — missing:\n {2}- deep-filter\nRun `archilyzer voice setup --engine deepfilternet`/);
});
+async function sparse(dir: string, files: readonly { name: string; bytes: number }[]) {
+ for (const f of files) {
+ const p = path.join(dir, f.name);
+ await mkdir(path.dirname(p), { recursive: true });
+ const fh = await open(p, "w");
+ await fh.truncate(f.bytes);
+ await fh.close();
+ }
+}
+
+test("seed-vc's f0 files are optional: an install without them checks out, --with f0 counts them", async () => {
+ const home = path.join(ROOT, "seed-home");
+ const dir = path.join(home, "seed-vc");
+ const seed = VOICE_ENGINES["seed-vc"];
+ assert.ok(seed.setup.kind === "python-venv");
+ if (seed.setup.kind !== "python-venv") return;
+ await mkdir(path.join(dir, "venv", "bin"), { recursive: true });
+ await writeFile(path.join(dir, "venv", "bin", "python"), "");
+ await mkdir(path.join(dir, "code"), { recursive: true });
+ await writeFile(path.join(dir, "code", VOICE_CODE_MARKER), `${seed.setup.code.commit}\n`);
+ await sparse(dir, SEEDVC_FILES);
+ // The install made before the group existed is installed; the group is said.
+ const state = voiceInstallState(seed, { home, voiceModelsDir: ROOT });
+ assert.equal(state.installed, true);
+ assert.deepEqual(state.optional.map((g) => [g.id, g.installed, g.missing.length]), [["f0", false, SEEDVC_F0_FILES.length]]);
+ // --check (the venv here is a stub, so the import fails: read the lines about the group).
+ const plain = capture();
+ await main({ engine: "seed-vc", check: true, home, log: plain.log });
+ assert.ok(plain.lines.some((l) => /optional f0 \(.*follows the input's pitch.*\): not installed — `archilyzer voice setup --engine seed-vc --with f0` fetches it/.test(l)), plain.lines.join("\n"));
+ assert.equal(plain.lines.some((l) => /- rmvpe\.pt/.test(l)), false);
+ const asked = capture();
+ assert.equal(await main({ engine: "seed-vc", check: true, with: ["f0"], home, log: asked.log }), 1);
+ assert.ok(asked.lines.some((l) => /^ {2}- rmvpe\.pt$/.test(l)));
+ assert.match(asked.lines.at(-1)!, /Run `archilyzer voice setup --engine seed-vc --with f0`/);
+ // There: said as installed.
+ await sparse(dir, SEEDVC_F0_FILES);
+ assert.equal(voiceGroupState(seed, "f0", { home })!.installed, true);
+ const there = capture();
+ await main({ engine: "seed-vc", check: true, with: ["f0"], home, log: there.log });
+ assert.ok(there.lines.some((l) => /with f0 \(.*\): installed/.test(l)));
+ assert.equal(there.lines.some((l) => /rmvpe/.test(l)), false);
+ // A group the engine does not have.
+ const no = capture();
+ assert.equal(await main({ engine: "seed-vc", with: ["f1"], dryRun: true, home, log: no.log }), 2);
+ assert.match(no.lines[0], /seed-vc has no optional group "f1" — --with is one of f0/);
+ assert.equal(await main({ engine: "openvoice", with: ["f0"], dryRun: true, home, log: no.log }), 2);
+ // --dry-run --with f0 lists them as fetched.
+ const dry = capture();
+ assert.equal(await main({ engine: "seed-vc", with: ["f0"], dryRun: true, home, log: dry.log }), 0);
+ assert.ok(dry.lines.some((l) => /with f0 — the f0-conditioned/.test(l)));
+});
+
test("an engine is required, by its id", async () => {
const c = capture();
assert.equal(await main({ log: c.log }), 2);
diff --git a/common/bin/voice-setup.ts b/common/bin/voice-setup.ts
@@ -15,6 +15,11 @@
// code/ Plachtaa/seed-vc at a pinned commit
// … the DiT (440 MB), whisper-small (967
// MB), BigVGAN v2 (449 MB), CAM++ (28 MB)
+// … (--with f0) OPTIONAL: the f0-conditioned 44.1 kHz
+// DiT (821 MB), its BigVGAN (489 MB) and
+// RMVPE (181 MB) — what `pitch: source |
+// contour` runs on; an install without
+// them converts at the target's pitch
// install.json what was installed, and when
// rnnoise has nothing to install (ffmpeg, and the model in the repo): setup
// says whether ffmpeg has `arnndn`.
@@ -31,7 +36,9 @@
//
// `--check` installs nothing: it lists what is missing (the venv, the package
// importing, the checkout at its commit, each file at its size) and exits 1
-// when anything is.
+// when anything is. An optional group that is not there is SAID (with the
+// command that fetches it) and does not fail the check, unless it was asked
+// for (`--check --with f0`).
//
// Scratch (pip's build dirs) goes to `<install dir>/.tmp`, never the OS temp
// dir: it may be a small RAM tmpfs.
@@ -48,6 +55,7 @@ import {
voiceInstallDir,
voiceVenvPython,
type VoiceEngine,
+ type VoiceFileGroup,
} from "../lib/voiceApps";
import { VOICE_CODE_MARKER, voiceInstallState } from "../lib/voiceInstall";
import { DEFAULT_VOICE_SETTINGS, resolveVoiceHome } from "../lib/voiceSettings";
@@ -58,6 +66,8 @@ import { adoptModelFile, downloadModelFile, verifyModelFile } from "./tts-setup"
export type VoiceSetupOptions = {
engine?: string;
from?: string;
+ // Optional file groups to install too (seed-vc: "f0").
+ with?: string[];
python?: string;
check?: boolean;
dryRun?: boolean;
@@ -76,8 +86,22 @@ function mb(n: number): string {
return n >= 1_000_000 ? `${(n / 1_000_000).toFixed(1)} MB` : `${(n / 1000).toFixed(1)} kB`;
}
-/** What setup fetches for an engine, in words: one line each, then the total. */
-export function voiceSetupPlan(engine: VoiceEngine): string[] {
+/** The engine's optional groups by these ids, or the ids it does not have. */
+export function pickVoiceGroups(engine: VoiceEngine, ids: readonly string[]): { groups: VoiceFileGroup[]; unknown: string[]; known: string[] } {
+ const all = engine.setup.kind === "python-venv" ? engine.setup.optional ?? [] : [];
+ return {
+ groups: all.filter((g) => ids.includes(g.id)),
+ unknown: ids.filter((id) => !all.some((g) => g.id === id)),
+ known: all.map((g) => g.id),
+ };
+}
+
+/**
+ * What setup fetches for an engine, in words: one line each, then the total.
+ * The optional groups asked for (`withGroups`) are fetched and counted; the
+ * others are listed after, as what `--with <id>` would add.
+ */
+export function voiceSetupPlan(engine: VoiceEngine, withGroups: readonly string[] = []): string[] {
const s = engine.setup;
if (s.kind === "bundled") return [`${engine.label}: nothing to download (${s.hint})`];
const lines: string[] = [];
@@ -90,7 +114,20 @@ export function voiceSetupPlan(engine: VoiceEngine): string[] {
lines.push(` ${f.name} — ${mb(f.bytes)} from ${f.url}`);
total += f.bytes;
}
+ const optional = s.kind === "python-venv" ? s.optional ?? [] : [];
+ for (const g of optional.filter((x) => withGroups.includes(x.id))) {
+ lines.push(` with ${g.id} — ${g.label}:`);
+ for (const f of g.files) {
+ lines.push(` ${f.name} — ${mb(f.bytes)} from ${f.url}`);
+ total += f.bytes;
+ }
+ }
lines.push(` files: ${mb(total)}${s.kind === "python-venv" ? " (plus the packages: torch's CPU wheels are ~200 MB)" : ""}`);
+ for (const g of optional.filter((x) => !withGroups.includes(x.id))) {
+ lines.push(` optional, not fetched without \`--with ${g.id}\` — ${g.label}:`);
+ for (const f of g.files) lines.push(` ${f.name} — ${mb(f.bytes)} from ${f.url}`);
+ lines.push(` ${mb(g.files.reduce((n, f) => n + f.bytes, 0))} more`);
+ }
return lines;
}
@@ -138,24 +175,43 @@ export async function main(opts: VoiceSetupOptions = {}): Promise<number> {
}
const dir = voiceInstallDir(home, engine);
+ const picked = pickVoiceGroups(engine, opts.with ?? []);
+ if (picked.unknown.length) {
+ log(`voice setup: ${engine.id} has no optional group "${picked.unknown.join('", "')}" — ${picked.known.length ? `--with is one of ${picked.known.join(", ")}` : "it has none"}`);
+ return 2;
+ }
+ const withIds = picked.groups.map((g) => g.id);
if (opts.check) {
const state = voiceInstallState(engine, { home, voiceModelsDir: paths.voiceModelsDir });
const missing = [...state.missing];
if (setup.kind === "python-venv" && !missing.some((m) => m.startsWith("the python venv"))) {
if ((await importsAt(voiceVenvPython(dir), setup.importName)) === null) missing.push(`${setup.importName} does not import in the venv`);
}
+ // A group asked for is part of the check; one not asked for is only said.
+ for (const g of state.optional) if (withIds.includes(g.id)) missing.push(...g.missing);
+ const said = () => {
+ for (const g of state.optional) {
+ if (g.installed) log(` with ${g.id} (${g.label}): installed`);
+ else if (!withIds.includes(g.id)) {
+ log(` optional ${g.id} (${g.label}): not installed — \`archilyzer voice setup --engine ${engine.id} --with ${g.id}\` fetches it`);
+ }
+ }
+ };
+ const withArg = withIds.map((id) => ` --with ${id}`).join("");
if (missing.length === 0) {
log(`${engine.label}: installed at ${dir}`);
+ said();
return 0;
}
log(`${engine.label} at ${dir} — missing:`);
for (const m of missing) log(` - ${m}`);
- log(`Run \`archilyzer voice setup --engine ${engine.id}\` to install it.`);
+ said();
+ log(`Run \`archilyzer voice setup --engine ${engine.id}${withArg}\` to install it.`);
return 1;
}
log(`${opts.dryRun ? "Would install" : "Installing"} ${engine.label} (${engine.license}) at ${dir}:`);
- for (const l of voiceSetupPlan(engine)) log(l);
+ for (const l of voiceSetupPlan(engine, withIds)) log(l);
if (opts.dryRun) return 0;
const scratch = path.join(dir, ".tmp");
@@ -215,7 +271,7 @@ export async function main(opts: VoiceSetupOptions = {}): Promise<number> {
}
}
// 4. The files, one at a time.
- for (const spec of setup.files) {
+ for (const spec of [...setup.files, ...picked.groups.flatMap((g) => g.files)]) {
const target = path.join(dir, spec.name);
await mkdir(path.dirname(target), { recursive: true });
if ((await verifyModelFile(target, spec)) === "ok") {
@@ -238,10 +294,14 @@ export async function main(opts: VoiceSetupOptions = {}): Promise<number> {
return 1;
}
const state = voiceInstallState(engine, { home, voiceModelsDir: paths.voiceModelsDir });
- if (!state.installed) {
- log(`voice setup: still missing ${state.missing.join("; ")}`);
+ const stillMissing = [...state.missing, ...state.optional.filter((g) => withIds.includes(g.id)).flatMap((g) => g.missing)];
+ if (stillMissing.length) {
+ log(`voice setup: still missing ${stillMissing.join("; ")}`);
return 1;
}
+ // What is there now, whichever run fetched it.
+ const groupsThere = picked.known.filter((id) => state.optional.find((g) => g.id === id)?.installed);
+ const optionalGroups = pickVoiceGroups(engine, groupsThere).groups;
await writeJsonAtomic(
path.join(dir, "install.json"),
{
@@ -250,10 +310,13 @@ export async function main(opts: VoiceSetupOptions = {}): Promise<number> {
license: engine.license,
...(setup.kind === "python-venv" ? { packages: setup.packages, code: setup.code } : {}),
files: setup.files.map((f) => ({ name: f.name, bytes: f.bytes, sha256: f.sha256, url: f.url })),
+ ...(optionalGroups.length
+ ? { optional: optionalGroups.map((g) => ({ id: g.id, files: g.files.map((f) => ({ name: f.name, bytes: f.bytes, sha256: f.sha256, url: f.url })) })) }
+ : {}),
installedAt: new Date().toISOString(),
},
{ indent: 2 },
);
- log(`${engine.label} installed: ${dir}`);
+ log(`${engine.label} installed: ${dir}${optionalGroups.length ? ` (with ${optionalGroups.map((g) => g.id).join(", ")})` : ""}`);
return 0;
}
diff --git a/common/controller/voiceFile.test.ts b/common/controller/voiceFile.test.ts
@@ -50,7 +50,8 @@ if (kind === "openvoice" || kind === "seed-vc") {
const more = argv.includes("--more") ? JSON.parse(argv[argv.indexOf("--more") + 1]) : [];
for (const m of more) fs.copyFileSync(m.input, m.output);
console.error("voice: " + kind + " converted");
- console.log(JSON.stringify({ op: "convert", engine: kind, sampleRate: 48000, seconds: 1, samples: 48000, engineMs: 5, gainDb: 0 }));
+ const f0 = argv.includes("--pitch") ? { f0: { targetHz: 200, sourceHz: 150, shiftSemitones: 6.98 } } : {};
+ console.log(JSON.stringify({ op: "convert", engine: kind, sampleRate: 48000, seconds: 1, samples: 48000, engineMs: 5, gainDb: 0, ...f0 }));
process.exit(0);
}
const r = spawnSync(process.execPath, [${JSON.stringify(WRAPPER)}, ...argv], { stdio: "inherit" });
@@ -83,7 +84,7 @@ const {
} = await import("./voiceFile");
const { getPaths } = await import("../lib/paths");
const { DEFAULT_VOICE_SETTINGS } = await import("../lib/voiceSettings");
-const { OPENVOICE_FILES, getVoiceEngine, stockTargetPaths, voiceCodeDir } = await import("../lib/voiceApps");
+const { OPENVOICE_FILES, SEEDVC_F0_FILES, SEEDVC_FILES, getVoiceEngine, stockTargetPaths, voiceCodeDir } = await import("../lib/voiceApps");
const { VOICE_CODE_MARKER } = await import("../lib/voiceInstall");
const paths = getPaths();
@@ -122,7 +123,7 @@ async function engineRuns(): Promise<string[][]> {
test("the body keys are umtool's contract", () => {
assert.deepEqual([...VOICE_ENHANCE_BODY_KEYS], ["file", "path", "out", "engine", "params", "parts"]);
- assert.deepEqual([...VOICE_CONVERT_BODY_KEYS], ["file", "path", "out", "engine", "params", "parts", "voice", "target"]);
+ assert.deepEqual([...VOICE_CONVERT_BODY_KEYS], ["file", "path", "out", "engine", "params", "parts", "voice", "target", "pitch", "semitones"]);
});
test("the body's shape is judged before the disk", () => {
@@ -191,6 +192,67 @@ test("an engine is the op's own, and its params are checked", () => {
}
});
+test("a pitch is the engine's to follow: openvoice refuses one, seed-vc takes source and contour", () => {
+ const v = DEFAULT_VOICE_SETTINGS;
+ const ask = (b: Record<string, unknown>, voice = v) => {
+ const p = parseVoiceBody("convert", { file: "/a.wav", out: "/b.wav", ...b });
+ assert.ok(p.ok, !p.ok ? p.error : "");
+ return resolveVoiceRequest("convert", p.ok ? p.value : ({} as never), voice);
+ };
+ const refused = (b: Record<string, unknown>, re: RegExp, voice = v) => {
+ const r = ask(b, voice);
+ assert.ok(!r.ok, JSON.stringify(b));
+ if (!r.ok) {
+ assert.match(r.error, re);
+ // One sentence.
+ assert.equal(r.error.includes("\n"), false);
+ }
+ };
+ // Nothing asked: the target's own pitch, on every engine.
+ for (const engine of ["openvoice", "seed-vc"]) {
+ const r = ask({ engine });
+ assert.ok(r.ok);
+ if (r.ok) assert.deepEqual(r.value.pitch, { pitch: "target", semitones: 0 });
+ }
+ // An enhance has no pitch at all.
+ const en = resolveVoiceRequest("enhance", { file: "/a.wav", out: "/b.wav", engine: "rnnoise" }, v);
+ assert.ok(en.ok && en.value.pitch === undefined);
+ // OpenVoice has one pitch.
+ refused({ engine: "openvoice", pitch: "source" }, /^OpenVoice v2 \(tone-colour converter\) has no pitch control — .* "pitch" and "semitones" are seed-vc's/);
+ refused({ engine: "openvoice", semitones: 2 }, /has no pitch control/);
+ assert.ok(ask({ engine: "openvoice", pitch: "target", semitones: 0 }).ok);
+ // The values.
+ refused({ engine: "seed-vc", pitch: "up" }, /"pitch" is one of target, source, contour \(got "up"\)/);
+ refused({ engine: "seed-vc", pitch: "source", semitones: 13 }, /"semitones" is a number from -12 to 12 \(got 13\)/);
+ refused({ engine: "seed-vc", pitch: "source", semitones: "2" }, /"semitones" is a number from -12 to 12/);
+ // Semitones move a FOLLOWED pitch.
+ refused({ engine: "seed-vc", semitones: 2 }, /"semitones" moves a followed pitch — give "pitch": "source" or "contour"/);
+ refused({ engine: "seed-vc", pitch: "target", semitones: -1 }, /moves a followed pitch/);
+ const src = ask({ engine: "seed-vc", pitch: "source" });
+ assert.ok(src.ok);
+ if (src.ok) assert.deepEqual(src.value.pitch, { pitch: "source", semitones: 0 });
+ const con = ask({ engine: "seed-vc", pitch: "contour", semitones: -1.5 });
+ assert.ok(con.ok);
+ if (con.ok) assert.deepEqual(con.value.pitch, { pitch: "contour", semitones: -1.5 });
+ // settings.voice.convert's defaults: for the engine that can follow, and
+ // never a refusal for the one that cannot.
+ const follow = { ...v, convert: { ...v.convert, pitch: "contour" as const, semitones: 2 } };
+ const d = ask({ engine: "seed-vc" }, follow);
+ assert.ok(d.ok);
+ if (d.ok) assert.deepEqual(d.value.pitch, { pitch: "contour", semitones: 2 });
+ const over = ask({ engine: "seed-vc", pitch: "target" }, follow);
+ assert.ok(over.ok);
+ if (over.ok) assert.deepEqual(over.value.pitch, { pitch: "target", semitones: 0 });
+ const ov = ask({ engine: "openvoice" }, follow);
+ assert.ok(ov.ok);
+ if (ov.ok) assert.deepEqual(ov.value.pitch, { pitch: "target", semitones: 0 });
+ // The argv: nothing new for the target's pitch.
+ const seed = getVoiceEngine("seed-vc")!;
+ const base = { input: "/a.wav", output: "/b.wav", installDir: "/i", params: {}, threads: 4, targetRef: "/r.wav", bins: { ffmpegBin: "ffmpeg", voiceModelsDir: "/m" } };
+ assert.equal(seed.build({ ...base, pitch: { pitch: "target", semitones: 0 } }).includes("--pitch"), false);
+ assert.deepEqual(seed.build({ ...base, pitch: { pitch: "contour", semitones: 2 } }).slice(-4), ["--pitch", "contour", "--semitones", "2"]);
+});
+
// --- the disk checks -----------------------------------------------------------
test("the disk checks: the input, the out, the install", { skip: SKIP }, async () => {
@@ -353,6 +415,68 @@ test("an engine that fails fails the job with its words", { skip: SKIP }, async
assert.match(r.log, /the voice engine exited 3: voice: engine exploded/);
});
+// A seed-vc install, faked to the pinned sizes with sparse files; `f0` adds the
+// optional group a followed pitch runs on.
+async function fakeSeedVcInstall(f0: boolean): Promise<string> {
+ const dir = path.join(HOME, "seed-vc");
+ await mkdir(path.join(dir, "venv", "bin"), { recursive: true });
+ await writeFile(path.join(dir, "venv", "bin", "python"), "");
+ const seed = getVoiceEngine("seed-vc")!;
+ if (seed.setup.kind !== "python-venv") throw new Error("seed-vc is a venv engine");
+ await mkdir(voiceCodeDir(dir), { recursive: true });
+ await writeFile(path.join(voiceCodeDir(dir), VOICE_CODE_MARKER), `${seed.setup.code.commit}\n`);
+ for (const f of [...SEEDVC_FILES, ...(f0 ? SEEDVC_F0_FILES : [])]) {
+ const p = path.join(dir, f.name);
+ await mkdir(path.dirname(p), { recursive: true });
+ const fh = await open(p, "w");
+ await fh.truncate(f.bytes);
+ await fh.close();
+ }
+ return dir;
+}
+
+test("a followed pitch needs seed-vc's f0 model: refused naming the setup command, then run with its own estimate", { skip: SKIP }, async () => {
+ await fakeSeedVcInstall(false);
+ const askTts = async (body: Record<string, unknown>) => {
+ await tone(String(body.out), 2);
+ return { ok: true as const, jobId: "tts-job-2", stream: new ReadableStream<string>(), done: Promise.resolve({ status: "done" as const, jobId: "tts-job-2" }) };
+ };
+ const take = path.join(OUTSIDE, "p-take.wav");
+ await tone(take, 1);
+ const before = (await engineRuns()).length;
+ // An install without the f0 files still converts at the target's pitch…
+ const plain = await runJob("convert", { file: take, out: path.join(OUTSIDE, "p-plain.wav"), engine: "seed-vc", voice: "espeak-ng:en-us" }, { askTts });
+ assert.equal(plain.status, "done", plain.log ?? plain.error);
+ assert.equal(plain.result.pitch, "target");
+ assert.equal("semitones" in plain.result, false);
+ assert.equal("f0" in plain.result, false);
+ assert.match(plain.log!, /estimate 3500 MB/);
+ const plainRun = (await engineRuns()).at(-1)!;
+ assert.equal(plainRun.includes("--pitch"), false);
+ // …and refuses a followed one, in one sentence, before any job.
+ const runs = (await engineRuns()).length;
+ assert.equal(runs, before + 1);
+ const refused = await runJob("convert", { file: take, out: path.join(OUTSIDE, "p-src.wav"), engine: "seed-vc", voice: "espeak-ng:en-us", pitch: "source" }, { askTts });
+ assert.match(
+ refused.error!,
+ /^pitch "source" needs Seed-VC \(v1, 22 kHz speech\)'s f0 model, which is not installed \(.*voice-home\/seed-vc: missing DiT_seed_v2_uvit_whisper_base_f0_44k_bigvgan_pruned_ft_ema_v2\.pth; .*rmvpe\.pt; .*\) — run `archilyzer voice setup --engine seed-vc --with f0`$/,
+ );
+ assert.equal(refused.error!.includes("\n"), false);
+ assert.equal((await engineRuns()).length, runs);
+ // With them: the wrapper is told, the f0 run's estimate is declared, the result says what was done.
+ await fakeSeedVcInstall(true);
+ const r = await runJob("convert", { file: take, out: path.join(OUTSIDE, "p-con.wav"), engine: "seed-vc", voice: "espeak-ng:en-us", pitch: "contour", semitones: 2 }, { askTts });
+ assert.equal(r.status, "done", r.log ?? r.error);
+ const run = (await engineRuns()).at(-1)!;
+ assert.equal(run[run.indexOf("--pitch") + 1], "contour");
+ assert.equal(run[run.indexOf("--semitones") + 1], "2");
+ assert.match(r.log!, /Convert to espeak-ng:en-us \(pitch: contour \+2 st\)/);
+ assert.match(r.log!, new RegExp(`estimate ${getVoiceEngine("seed-vc")!.pitch!.defaultEstimateMB} MB`));
+ assert.equal(r.result.pitch, "contour");
+ assert.equal(r.result.semitones, 2);
+ assert.deepEqual(r.result.f0, { targetHz: 200, sourceHz: 150, shiftSemitones: 6.98 });
+});
+
test("a cancelled run stops the engine's whole process group", async () => {
const slow = path.join(BIN, "slow-engine");
await writeFile(slow, `#!/bin/sh\nsleep 30 &\nwait\n`);
diff --git a/common/controller/voiceFile.ts b/common/controller/voiceFile.ts
@@ -8,7 +8,13 @@
// THE BODY is umtool's contract (umtool/lib/report/postNarrationCli.mjs
// deriveTake): `{file, out, engine?, params?, parts?}`, and for convert
// `voice?` — the stock target (`target` is the same key's other name; `path`
-// is `file`'s). `file` is an absolute path to the recording (any format ffmpeg
+// is `file`'s) — and `pitch?` / `semitones?`: the pitch the conversion lands on
+// (lib/voiceApps.ts VoicePitch: `target`, the stock voice's own; `source`, the
+// read's; `contour`, the read's rises and falls at the stock voice's register;
+// `semitones` moves a followed one; defaults settings.voice.convert). An engine
+// with one pitch (openvoice) refuses another; a followed pitch whose model is
+// not installed (seed-vc's optional `f0` files) is refused naming the setup
+// command. `file` is an absolute path to the recording (any format ffmpeg
// reads, at most VOICE_MAX_SECONDS); `out` an absolute `.wav` path the result
// is written to — never inside the corpus, its directory existing; `engine`
// one of the op's engines (default settings.voice.<op>.engine); `params` the
@@ -37,7 +43,9 @@
// THE RESULT is logged as ONE line starting with VOICE_RESULT_MARKER (the
// marker umtool's askEditorOp reads): `{op, engine, wav, seconds, samples,
// sampleRate, engineMs, durationMs, waitedMs, gainDb, params, parts?,
-// target?, voice?, synthetic, disclosure?}`. `wav` is `out`, 48 kHz mono 16-bit, as
+// target?, voice?, pitch?, semitones?, f0?, synthetic, disclosure?}` (`pitch`
+// on every conversion; `f0` — {targetHz, sourceHz, shiftSemitones}, the medians
+// the tracker heard and the whole move — on a followed one). `wav` is `out`, 48 kHz mono 16-bit, as
// long as the input to the sample.
//
// WHAT IT TOUCHES: reads `file` and each part (anywhere); writes `out`, each
@@ -55,9 +63,11 @@ import type { StorageLocation } from "../lib/storageLocations";
import {
NO_CLONING,
VOICE_REFERENCE_TEXT,
+ describeVoicePitch,
getVoiceEngine,
parseStockTarget,
resolveVoiceParams,
+ resolveVoicePitch,
stockTargetPaths,
voiceConvertDisclosure,
voiceEngineIds,
@@ -65,8 +75,9 @@ import {
type StockTarget,
type VoiceEngine,
type VoiceOp,
+ type VoicePitchChoice,
} from "../lib/voiceApps";
-import { voiceInstallState } from "../lib/voiceInstall";
+import { voiceGroupState, voiceInstallState } from "../lib/voiceInstall";
import { DEFAULT_VOICE_SETTINGS, resolveVoiceHome, type VoiceSettings } from "../lib/voiceSettings";
import { getTtsEngine } from "../lib/ttsApps";
import { ttsInstallState } from "../lib/ttsInstall";
@@ -86,7 +97,7 @@ export const VOICE_RESULT_MARKER = "@@voice-result ";
// The bodies the routes accept; anything else is a 400.
export const VOICE_ENHANCE_BODY_KEYS = ["file", "path", "out", "engine", "params", "parts"] as const;
-export const VOICE_CONVERT_BODY_KEYS = [...VOICE_ENHANCE_BODY_KEYS, "voice", "target"] as const;
+export const VOICE_CONVERT_BODY_KEYS = [...VOICE_ENHANCE_BODY_KEYS, "voice", "target", "pitch", "semitones"] as const;
// The longest recording one op takes (a post read in full runs ~25 minutes).
export const VOICE_MAX_SECONDS = 1800;
@@ -103,6 +114,9 @@ export type VoiceFileBody = {
params?: unknown;
parts?: VoicePart[];
target?: string;
+ // Convert: as given, judged against the engine by resolveVoiceRequest.
+ pitch?: unknown;
+ semitones?: unknown;
};
function absWav(key: string, v: unknown, wav: boolean): Check<string> {
@@ -164,6 +178,8 @@ export function parseVoiceBody(op: VoiceOp, body: Record<string, unknown>): Chec
...(body.params !== undefined ? { params: body.params } : {}),
...(parts ? { parts } : {}),
...(target !== undefined ? { target } : {}),
+ ...(op === "convert" && body.pitch !== undefined ? { pitch: body.pitch } : {}),
+ ...(op === "convert" && body.semitones !== undefined ? { semitones: body.semitones } : {}),
},
};
}
@@ -178,6 +194,8 @@ export type VoiceRequest = {
out: string;
parts: VoicePart[];
target?: StockTarget;
+ // Convert: the pitch it lands on (target = the stock voice's own).
+ pitch?: VoicePitchChoice;
};
// The body plus settings.voice, resolved against the registry. Pure.
@@ -194,14 +212,27 @@ export function resolveVoiceRequest(
const params = resolveVoiceParams(engine, body.params);
if (!params.ok) return params;
let target: StockTarget | undefined;
+ let pitch: VoicePitchChoice | undefined;
if (op === "convert") {
const t = parseStockTarget(body.target ?? voice.convert.target);
if (!t.ok) return t;
target = t.value;
+ const p = resolveVoicePitch(engine, { pitch: body.pitch, semitones: body.semitones }, voice.convert);
+ if (!p.ok) return p;
+ pitch = p.value;
}
return {
ok: true,
- value: { op, engine, params: params.value, file: body.file, out: body.out, parts: body.parts ?? [], ...(target ? { target } : {}) },
+ value: {
+ op,
+ engine,
+ params: params.value,
+ file: body.file,
+ out: body.out,
+ parts: body.parts ?? [],
+ ...(target ? { target } : {}),
+ ...(pitch ? { pitch } : {}),
+ },
};
}
@@ -293,6 +324,18 @@ export async function checkVoiceRequest(req: VoiceRequest, ctx: VoiceFileContext
(req.engine.setup.kind === "bundled" ? req.engine.setup.hint : `run \`archilyzer voice setup --engine ${req.engine.id}\``),
};
}
+ // A followed pitch runs on the engine's optional model.
+ if (req.pitch && req.pitch.pitch !== "target" && req.engine.pitch) {
+ const group = voiceGroupState(req.engine, req.engine.pitch.group, { home: ctx.home });
+ if (group && !group.installed) {
+ return {
+ ok: false,
+ error:
+ `pitch "${req.pitch.pitch}" needs ${req.engine.label}'s ${group.id} model, which is not installed (${install.dir}: missing ${group.missing.join("; ")}) — ` +
+ `run \`archilyzer voice setup --engine ${req.engine.id} --with ${group.id}\``,
+ };
+ }
+ }
if (req.target) {
const tts = ctx.tts ?? DEFAULT_TTS_SETTINGS;
const ref = await stockReferenceState(req.target, ctx.home, tts);
@@ -368,6 +411,8 @@ export type EngineRunResult = {
sampleRate?: number;
engineMs?: number;
gainDb?: number;
+ // A followed pitch: the medians the tracker heard and the whole move applied.
+ f0?: { targetHz: number | null; sourceHz: number | null; shiftSemitones: number };
// The parts, when the run had more files (scripts/voice.mjs --more).
more?: { output: string; seconds: number; samples?: number; gainDb?: number }[];
};
@@ -482,12 +527,17 @@ export type VoiceResult = {
// shape a umtool take records).
target?: string;
voice?: string;
+ // Convert: the pitch it landed on, and for a followed one what was heard.
+ pitch?: VoicePitchChoice["pitch"];
+ semitones?: number;
+ f0?: EngineRunResult["f0"];
synthetic: boolean;
disclosure?: string;
};
function describe(req: VoiceRequest, seconds: number): string {
- const what = req.op === "enhance" ? "Enhance" : `Convert to ${req.target!.id}`;
+ const followed = describeVoicePitch(req.pitch);
+ const what = req.op === "enhance" ? "Enhance" : `Convert to ${req.target!.id}${followed ? ` (pitch: ${followed})` : ""}`;
const parts = req.parts.length ? ` and its ${req.parts.length} part(s)` : "";
return `${what}: ${Math.round(seconds * 10) / 10} s of ${req.file}${parts} with ${req.engine.id}`;
}
@@ -520,7 +570,11 @@ export async function enqueueVoiceFile(op: VoiceOp, body: Record<string, unknown
if (!checked.ok) return checked;
const req = checked.value;
const installDir = voiceInstallDir(home, req.engine);
- const estimateMB = voice.heavyEstimateMB[req.engine.id] ?? req.engine.defaultEstimateMB;
+ // A followed pitch is another model's run, with its own estimate.
+ const follows = req.pitch && req.pitch.pitch !== "target" ? req.engine.pitch : undefined;
+ const estimateMB = follows
+ ? (voice.heavyEstimateMB[follows.estimateKey] ?? follows.defaultEstimateMB)
+ : (voice.heavyEstimateMB[req.engine.id] ?? req.engine.defaultEstimateMB);
const asked = Date.now();
return runManagedFunction({
kind: VOICE_JOB_KIND[op],
@@ -558,6 +612,7 @@ export async function enqueueVoiceFile(op: VoiceOp, body: Record<string, unknown
threads: voice.threads,
...(targetRef ? { targetRef } : {}),
...(targetSe ? { targetSe } : {}),
+ ...(req.pitch ? { pitch: req.pitch } : {}),
bins: { ffmpegBin: opts.paths.ffmpegBin, voiceModelsDir: opts.paths.voiceModelsDir },
});
onLog(`Running ${req.engine.label}${req.parts.length ? ` over the take and its ${req.parts.length} part(s)` : ""} behind the heavy slot (estimate ${estimateMB} MB)…`);
@@ -582,6 +637,8 @@ export async function enqueueVoiceFile(op: VoiceOp, body: Record<string, unknown
params: req.params,
...(parts.length ? { parts } : {}),
...(req.target ? { target: req.target.id, voice: req.target.voice, disclosure: voiceConvertDisclosure(req.engine, req.target) } : {}),
+ ...(req.pitch ? { pitch: req.pitch.pitch, ...(req.pitch.pitch !== "target" ? { semitones: req.pitch.semitones } : {}) } : {}),
+ ...(follows && whole.f0 ? { f0: whole.f0 } : {}),
synthetic: op === "convert",
};
onLog(`${VOICE_RESULT_MARKER}${JSON.stringify(result)}`);
diff --git a/common/lib/voiceApps.ts b/common/lib/voiceApps.ts
@@ -53,8 +53,19 @@ export type VoiceSetup =
importName: string;
code: { repo: string; commit: string };
files: readonly VoiceModelFile[];
+ // Files the engine runs without, in named groups: fetched only when
+ // setup is asked for the group (`--with <id>`), never counted against
+ // "installed" — an install made before a group existed keeps working.
+ optional?: readonly VoiceFileGroup[];
};
+export type VoiceFileGroup = {
+ id: string;
+ // What the group is for, as setup says it.
+ label: string;
+ files: readonly VoiceModelFile[];
+};
+
// A downloaded file, verified by size and sha256 like a TTS model file. `name`
// may hold a subdirectory (`whisper-small/model.safetensors`).
export type VoiceModelFile = TtsModelFile & { executable?: boolean };
@@ -63,6 +74,22 @@ export type VoiceParamSpec =
| { kind: "number"; min: number; max: number; default: number; doc: string }
| { kind: "boolean"; default: boolean; doc: string };
+// THE PITCH A CONVERSION LANDS ON (operator, 11 Nov: both converters threw the
+// read's intonation away — inputs with a median f0 of 128 to 237 Hz all came
+// out at 196-199 Hz, a 152-321 Hz range as 165-240 Hz).
+// target the stock voice's own pitch: the converter is given none of the
+// input's (every engine; what there was before).
+// source the input's f0 as it was read: raise the voice and the output
+// rises with it.
+// contour the input's f0 curve moved as a whole so its median sits on the
+// stock voice's: every rise and fall kept, the register the target's.
+// `semitones` then moves a followed curve (source, contour) up or down.
+export type VoicePitch = "target" | "source" | "contour";
+export const VOICE_PITCH_MODES: readonly VoicePitch[] = ["target", "source", "contour"];
+export const VOICE_SEMITONES_MAX = 12;
+export type VoicePitchChoice = { pitch: VoicePitch; semitones: number };
+export const DEFAULT_VOICE_PITCH: VoicePitchChoice = { pitch: "target", semitones: 0 };
+
export type VoiceBuildInput = {
input: string;
output: string;
@@ -74,6 +101,8 @@ export type VoiceBuildInput = {
// The stock target's reference clip and openvoice's embedding cache (convert).
targetRef?: string;
targetSe?: string;
+ // A followed pitch (an engine with `pitch`); absent = target.
+ pitch?: VoicePitchChoice;
bins: { ffmpegBin: string; voiceModelsDir: string };
};
@@ -93,6 +122,11 @@ export type VoiceEngine = {
// plus swapped — rnnoise 112 MB, deepfilternet 111 MB, openvoice 1625 MB,
// seed-vc 2865 MB; no GPU memory, they are CPU engines) plus a margin.
defaultEstimateMB: number;
+ // A convert engine that can FOLLOW the input's pitch (source, contour): the
+ // optional file group that mode runs on, and the memory ITS run declares
+ // (another, bigger model) — kept in settings.voice.heavyEstimateMB under
+ // `estimateKey`. An engine without it has one pitch: the target's.
+ pitch?: { group: string; estimateKey: string; defaultEstimateMB: number };
// Args to paths.voiceBin (scripts/voice.mjs).
build: (input: VoiceBuildInput) => string[];
};
@@ -232,6 +266,11 @@ const openvoice: VoiceEngine = {
],
};
+// The f0 model's run, declared to the heavy slot: SEEDVC_F0_PEAK measured
+// 2026-11-11 (RSS plus swap of the wrapper, python and ffmpeg, sampled twice a
+// second over a 6.9 s read), plus a margin.
+const SEEDVC_F0_ESTIMATE_MB = 4500;
+
const SEEDVC_HF = "https://huggingface.co/Plachta/Seed-VC/resolve/257283f9f41585055e8f858fba4fd044e5caed6e";
const WHISPER_HF = "https://huggingface.co/openai/whisper-small/resolve/973afd24965f72e36ca33b3055d56a652f456b4d";
const BIGVGAN_HF = "https://huggingface.co/nvidia/bigvgan_v2_22khz_80band_256x/resolve/633ff708ed5b74903e86ff1298cf4a98e921c513";
@@ -288,6 +327,52 @@ export const SEEDVC_FILES: readonly VoiceModelFile[] = [
},
];
+// The f0-conditioned model (upstream's `inference.py --f0-condition`): a 44.1
+// kHz DiT, its 128-band BigVGAN, and RMVPE, the pitch tracker whose curve
+// conditions it. Optional (`voice setup --engine seed-vc --with f0`, 1.49 GB):
+// `pitch: source | contour` runs on these, `target` never touches them.
+const RMVPE_HF = "https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/e6d0c1a17da07c33557852f9dfa2bd44cc75737d";
+const BIGVGAN_44K_HF = "https://huggingface.co/nvidia/bigvgan_v2_44khz_128band_512x/resolve/95a9d1dcb12906c03edd938d77b9333d6ded7dfb";
+
+export const SEEDVC_F0_FILES: readonly VoiceModelFile[] = [
+ {
+ name: "DiT_seed_v2_uvit_whisper_base_f0_44k_bigvgan_pruned_ft_ema_v2.pth",
+ url: `${SEEDVC_HF}/DiT_seed_v2_uvit_whisper_base_f0_44k_bigvgan_pruned_ft_ema_v2.pth`,
+ bytes: 820_865_494,
+ sha256: "42aef93ffe65857c840d270252fa040f7ba04514945ec460f3ac1ac2a96de684",
+ },
+ {
+ name: "config_dit_mel_seed_uvit_whisper_base_f0_44k.yml",
+ url: `${SEEDVC_HF}/config_dit_mel_seed_uvit_whisper_base_f0_44k.yml`,
+ bytes: 2_408,
+ sha256: "ff86f343b08c2def405f075022eeb10dafba23c4eda36d151010f4ca6d7a1a0a",
+ },
+ {
+ name: "rmvpe.pt",
+ url: `${RMVPE_HF}/rmvpe.pt`,
+ bytes: 181_184_272,
+ sha256: "6d62215f4306e3ca278246188607209f09af3dc77ed4232efdd069798c4ec193",
+ },
+ {
+ name: "bigvgan-44k/bigvgan_generator.pt",
+ url: `${BIGVGAN_44K_HF}/bigvgan_generator.pt`,
+ bytes: 489_041_291,
+ sha256: "d9fe7ec6bd0b44ed9d66973d5012d8181c1570b01e5c72df51973e241dccd357",
+ },
+ {
+ name: "bigvgan-44k/config.json",
+ url: `${BIGVGAN_44K_HF}/config.json`,
+ bytes: 1_403,
+ sha256: "65b7f487bfaf15256056a75f6667ef5f640214c981922a111927873705ea4ddb",
+ },
+];
+
+export const SEEDVC_F0_GROUP: VoiceFileGroup = {
+ id: "f0",
+ label: "the f0-conditioned 44.1 kHz model, for a conversion that follows the input's pitch (pitch: source | contour)",
+ files: SEEDVC_F0_FILES,
+};
+
// Seed-VC v1, its 22 kHz speech model (Whisper-small content features, a
// diffusion transformer, BigVGAN v2): zero-shot, the stronger timbre match,
// several times slower than OpenVoice on the CPU. GPL-3.0 code, run as a
@@ -312,6 +397,7 @@ const seedVc: VoiceEngine = {
importName: "transformers",
code: { repo: "https://github.com/Plachtaa/seed-vc", commit: "51383efd921027683c89e5348211d93ff12ac2a8" },
files: SEEDVC_FILES,
+ optional: [SEEDVC_F0_GROUP],
},
params: {
steps: { kind: "number", min: 1, max: 100, default: 10, doc: "diffusion steps: each is one pass of the model over every window, so the time grows with them (upstream: 4-10 fast, 25-30 cleaner; 10 by the 2026-11-03 bake-off)" },
@@ -319,12 +405,14 @@ const seedVc: VoiceEngine = {
refSeconds: { kind: "number", min: 3, max: 25, default: 10, doc: "seconds of the reference the model is prompted with (each window is 30 s less this: less is faster)" },
},
defaultEstimateMB: 3500,
+ pitch: { group: SEEDVC_F0_GROUP.id, estimateKey: "seed-vc-f0", defaultEstimateMB: SEEDVC_F0_ESTIMATE_MB },
build: (i) => [
...common("convert", "seed-vc", i),
"--python", voiceVenvPython(i.installDir),
"--code", voiceCodeDir(i.installDir),
"--install", i.installDir,
"--target-ref", i.targetRef ?? "",
+ ...(i.pitch && i.pitch.pitch !== "target" ? ["--pitch", i.pitch.pitch, "--semitones", String(i.pitch.semitones)] : []),
],
};
@@ -355,6 +443,56 @@ export function voiceInstallDir(home: string, engine: Pick<VoiceEngine, "id">):
type Check<T> = { ok: true; value: T } | { ok: false; error: string };
/**
+ * The pitch a conversion lands on: the request's `pitch` / `semitones` over the
+ * defaults (settings.voice.convert). An engine with one pitch refuses a request
+ * for another (the defaults are not a request: they are for the engines that
+ * can); `semitones` asked of the target's own pitch is refused, since nothing
+ * is followed to move. Pure.
+ */
+export function resolveVoicePitch(
+ engine: Pick<VoiceEngine, "id" | "label" | "pitch">,
+ given: { pitch?: unknown; semitones?: unknown },
+ defaults: VoicePitchChoice = DEFAULT_VOICE_PITCH,
+): Check<VoicePitchChoice> {
+ if (given.pitch !== undefined && !VOICE_PITCH_MODES.includes(given.pitch as VoicePitch)) {
+ return { ok: false, error: `"pitch" is one of ${VOICE_PITCH_MODES.join(", ")} (got ${JSON.stringify(given.pitch)})` };
+ }
+ if (given.semitones !== undefined) {
+ const n = given.semitones;
+ if (typeof n !== "number" || !Number.isFinite(n) || Math.abs(n) > VOICE_SEMITONES_MAX) {
+ return { ok: false, error: `"semitones" is a number from -${VOICE_SEMITONES_MAX} to ${VOICE_SEMITONES_MAX} (got ${JSON.stringify(n)})` };
+ }
+ }
+ const askedPitch = given.pitch as VoicePitch | undefined;
+ const askedSemitones = given.semitones as number | undefined;
+ if (!engine.pitch) {
+ if ((askedPitch && askedPitch !== "target") || askedSemitones) {
+ const can = Object.values(VOICE_ENGINES).filter((e) => e.pitch).map((e) => e.id);
+ return {
+ ok: false,
+ error: `${engine.label} has no pitch control — it lands every read on the target's own pitch; "pitch" and "semitones" are ${can.join(", ")}'s (engine: "${can[0]}")`,
+ };
+ }
+ return { ok: true, value: { pitch: "target", semitones: 0 } };
+ }
+ const pitch = askedPitch ?? defaults.pitch;
+ if (pitch === "target") {
+ if (askedSemitones) {
+ return { ok: false, error: `"semitones" moves a followed pitch — give "pitch": "source" or "contour" with it (pitch is "target": the stock voice's own)` };
+ }
+ return { ok: true, value: { pitch, semitones: 0 } };
+ }
+ return { ok: true, value: { pitch, semitones: askedSemitones ?? defaults.semitones } };
+}
+
+/** How a result, a take or a page says a pitch choice: "contour +2 st", "source", "" for the target's own. */
+export function describeVoicePitch(p: Partial<VoicePitchChoice> | undefined): string {
+ if (!p?.pitch || p.pitch === "target") return "";
+ const n = p.semitones ?? 0;
+ return n ? `${p.pitch} ${n > 0 ? "+" : "−"}${Math.abs(n)} st` : p.pitch;
+}
+
+/**
* An engine's knobs from a body's `params`: each key one the engine has, each
* value of its kind and in its range; the rest from the defaults. Pure.
*/
@@ -445,8 +583,8 @@ export function voiceConvertDisclosure(engine: Pick<VoiceEngine, "label">, targe
}
// A client-safe view (no functions).
-export type VoiceEngineDescriptor = { id: string; op: VoiceOp; label: string; license: string; params: Record<string, VoiceParamSpec> };
+export type VoiceEngineDescriptor = { id: string; op: VoiceOp; label: string; license: string; params: Record<string, VoiceParamSpec>; pitch: boolean };
export function listVoiceEngines(): VoiceEngineDescriptor[] {
- return Object.values(VOICE_ENGINES).map((e) => ({ id: e.id, op: e.op, label: e.label, license: e.license, params: { ...e.params } }));
+ return Object.values(VOICE_ENGINES).map((e) => ({ id: e.id, op: e.op, label: e.label, license: e.license, params: { ...e.params }, pitch: Boolean(e.pitch) }));
}
diff --git a/common/lib/voiceInstall.ts b/common/lib/voiceInstall.ts
@@ -7,18 +7,51 @@
// the pinned checkout's marker, each file at its pinned size (an executable
// one executable); setup's `--check` goes further and imports the package and
// reads the checkout's commit. Read-only: never creates anything.
+//
+// An engine's OPTIONAL file groups (seed-vc's `f0`: the model a followed pitch
+// runs on) are reported beside, never counted: `installed` is the required
+// files alone, so an install made before a group existed is still installed.
import fs from "node:fs";
import path from "node:path";
-import { voiceCodeDir, voiceInstallDir, voiceVenvPython, type VoiceEngine } from "./voiceApps";
+import { voiceCodeDir, voiceInstallDir, voiceVenvPython, type VoiceEngine, type VoiceModelFile } from "./voiceApps";
export type VoiceInstallState = {
engine: string;
dir: string;
installed: boolean;
missing: string[];
+ // Each optional group: there whole, or what of it is missing.
+ optional: VoiceGroupState[];
};
+export type VoiceGroupState = { id: string; label: string; installed: boolean; missing: string[] };
+
+function missingFiles(dir: string, files: readonly VoiceModelFile[]): string[] {
+ const missing: string[] = [];
+ for (const f of files) {
+ const p = path.join(dir, f.name);
+ let st: fs.Stats | null = null;
+ try {
+ st = fs.statSync(p);
+ } catch {
+ st = null;
+ }
+ if (!st) missing.push(f.name);
+ else if (st.size !== f.bytes) missing.push(`${f.name} (${st.size} bytes, expected ${f.bytes})`);
+ else if (f.executable && (st.mode & 0o111) === 0) missing.push(`${f.name} (not executable)`);
+ }
+ return missing;
+}
+
+/** One optional group of an engine's install, or undefined when the engine has none by that id. */
+export function voiceGroupState(engine: VoiceEngine, group: string, opts: { home: string }): VoiceGroupState | undefined {
+ const g = engine.setup.kind === "python-venv" ? engine.setup.optional?.find((x) => x.id === group) : undefined;
+ if (!g) return undefined;
+ const missing = missingFiles(voiceInstallDir(opts.home, engine), g.files);
+ return { id: g.id, label: g.label, installed: missing.length === 0, missing };
+}
+
// The file a finished checkout leaves: the commit it is at.
export const VOICE_CODE_MARKER = ".archilyzer-commit";
@@ -30,7 +63,7 @@ export function voiceInstallState(
if (setup.kind === "bundled") {
const model = path.join(opts.voiceModelsDir, "sh.rnnn");
const ok = fs.existsSync(model);
- return { engine: engine.id, dir: opts.voiceModelsDir, installed: ok, missing: ok ? [] : [`${model} (shipped in the repo)`] };
+ return { engine: engine.id, dir: opts.voiceModelsDir, installed: ok, missing: ok ? [] : [`${model} (shipped in the repo)`], optional: [] };
}
const dir = voiceInstallDir(opts.home, engine);
const missing: string[] = [];
@@ -47,17 +80,7 @@ export function voiceInstallState(
missing.push(at ? `the checkout of ${setup.code.repo} is at ${at.slice(0, 10)}, pinned ${setup.code.commit.slice(0, 10)}` : `the checkout of ${setup.code.repo} (${voiceCodeDir(dir)})`);
}
}
- for (const f of setup.files) {
- const p = path.join(dir, f.name);
- let st: fs.Stats | null = null;
- try {
- st = fs.statSync(p);
- } catch {
- st = null;
- }
- if (!st) missing.push(f.name);
- else if (st.size !== f.bytes) missing.push(`${f.name} (${st.size} bytes, expected ${f.bytes})`);
- else if (f.executable && (st.mode & 0o111) === 0) missing.push(`${f.name} (not executable)`);
- }
- return { engine: engine.id, dir, installed: missing.length === 0, missing };
+ missing.push(...missingFiles(dir, setup.files));
+ const optional = (setup.kind === "python-venv" ? setup.optional ?? [] : []).map((g) => voiceGroupState(engine, g.id, opts)!);
+ return { engine: engine.id, dir, installed: missing.length === 0, missing, optional };
}
diff --git a/common/lib/voiceSettings.test.ts b/common/lib/voiceSettings.test.ts
@@ -1,7 +1,7 @@
import { test } from "node:test";
import assert from "node:assert/strict";
import { DEFAULT_VOICE_SETTINGS, resolveVoiceHome, sanitizeVoice } from "./voiceSettings";
-import { NO_CLONING, VOICE_ENGINES, listVoiceEngines, parseStockTarget, resolveVoiceParams, voiceEngineIds } from "./voiceApps";
+import { NO_CLONING, VOICE_ENGINES, describeVoicePitch, listVoiceEngines, parseStockTarget, resolveVoiceParams, voiceEngineIds } from "./voiceApps";
// Run with: pnpm --filter yt-dlp-transcript-common exec tsx --test lib/voiceSettings.test.ts
@@ -25,7 +25,16 @@ test("settings.voice: defaults, and every field falls back rather than throws",
assert.equal(s.heavyEstimateMB["seed-vc"], 4200);
assert.equal(s.heavyEstimateMB.openvoice, 0);
assert.equal("nope" in s.heavyEstimateMB, false);
- assert.deepEqual(Object.keys(s.heavyEstimateMB).sort(), Object.keys(VOICE_ENGINES).sort());
+ // Every engine, and the f0 run of the one that can follow a pitch.
+ assert.deepEqual(Object.keys(s.heavyEstimateMB).sort(), [...Object.keys(VOICE_ENGINES), "seed-vc-f0"].sort());
+ assert.equal(s.heavyEstimateMB["seed-vc-f0"], VOICE_ENGINES["seed-vc"].pitch!.defaultEstimateMB);
+ assert.equal(sanitizeVoice({ heavyEstimateMB: { "seed-vc-f0": 5000 } }).heavyEstimateMB["seed-vc-f0"], 5000);
+ // The pitch a conversion lands on: the target's own unless said, the semitones clamped.
+ assert.deepEqual([s.convert.pitch, s.convert.semitones], ["target", 0]);
+ const p = sanitizeVoice({ convert: { pitch: "contour", semitones: 40 } }).convert;
+ assert.deepEqual([p.pitch, p.semitones], ["contour", 12]);
+ const q = sanitizeVoice({ convert: { pitch: "higher", semitones: "2" } }).convert;
+ assert.deepEqual([q.pitch, q.semitones], ["target", 0]);
const ok = sanitizeVoice({ home: "~/voice", convert: { engine: "seed-vc", target: "kokoro:bm_george" }, enhance: { engine: "rnnoise" } });
assert.equal(ok.convert.engine, "seed-vc");
assert.equal(ok.convert.target, "kokoro:bm_george");
@@ -62,7 +71,24 @@ test("the registry: two engines per op, every knob has a default in range", () =
}
assert.ok(e.defaultEstimateMB > 0, e.id);
if (e.setup.kind !== "bundled") for (const f of e.setup.files) assert.match(f.sha256, /^[0-9a-f]{64}$/, f.name);
+ // An optional group: pinned by revision, size and sha256 like the rest, and no name of the required set.
+ if (e.setup.kind === "python-venv") {
+ const required = new Set(e.setup.files.map((f) => f.name));
+ for (const g of e.setup.optional ?? []) {
+ for (const f of g.files) {
+ assert.match(f.sha256, /^[0-9a-f]{64}$/, f.name);
+ assert.match(f.url, /\/resolve\/[0-9a-f]{40}\//, f.name);
+ assert.ok(f.bytes > 0 && !required.has(f.name), f.name);
+ }
+ }
+ if (e.pitch) assert.ok(e.setup.optional?.some((g) => g.id === e.pitch!.group), e.id);
+ }
+ assert.equal(Boolean(e.pitch), e.id === "seed-vc", e.id);
}
+ assert.equal(describeVoicePitch({ pitch: "target", semitones: 0 }), "");
+ assert.equal(describeVoicePitch({ pitch: "source", semitones: 0 }), "source");
+ assert.equal(describeVoicePitch({ pitch: "contour", semitones: 2 }), "contour +2 st");
+ assert.equal(describeVoicePitch({ pitch: "source", semitones: -1.5 }), "source −1.5 st");
assert.equal(listVoiceEngines().length, 4);
assert.equal(resolveVoiceParams(VOICE_ENGINES.rnnoise, []).ok, false);
});
diff --git a/common/lib/voiceSettings.ts b/common/lib/voiceSettings.ts
@@ -14,13 +14,17 @@ import {
DEFAULT_VOICE_ENGINE,
DEFAULT_VOICE_TARGET,
VOICE_ENGINES,
+ DEFAULT_VOICE_PITCH,
+ VOICE_PITCH_MODES,
+ VOICE_SEMITONES_MAX,
getVoiceEngine,
parseStockTarget,
type VoiceOp,
+ type VoicePitch,
} from "./voiceApps";
export type VoiceEnhanceSettings = { engine: string };
-export type VoiceConvertSettings = { engine: string; target: string };
+export type VoiceConvertSettings = { engine: string; target: string; pitch: VoicePitch; semitones: number };
export type VoiceSettings = {
home: string;
@@ -31,15 +35,20 @@ export type VoiceSettings = {
heavyEstimateMB: Record<string, number>;
};
+// An engine's own estimate, and — for one that can follow the input's pitch on
+// another model — that run's, under the engine's `pitch.estimateKey`.
export const DEFAULT_VOICE_HEAVY_ESTIMATES: Record<string, number> = Object.fromEntries(
- Object.values(VOICE_ENGINES).map((e) => [e.id, e.defaultEstimateMB]),
+ Object.values(VOICE_ENGINES).flatMap((e) => [
+ [e.id, e.defaultEstimateMB] as const,
+ ...(e.pitch ? [[e.pitch.estimateKey, e.pitch.defaultEstimateMB] as const] : []),
+ ]),
);
export const DEFAULT_VOICE_SETTINGS: VoiceSettings = {
home: "",
threads: 4,
enhance: { engine: DEFAULT_VOICE_ENGINE.enhance },
- convert: { engine: DEFAULT_VOICE_ENGINE.convert, target: DEFAULT_VOICE_TARGET },
+ convert: { engine: DEFAULT_VOICE_ENGINE.convert, target: DEFAULT_VOICE_TARGET, ...DEFAULT_VOICE_PITCH },
heavyEstimateMB: DEFAULT_VOICE_HEAVY_ESTIMATES,
};
@@ -51,11 +60,13 @@ export const VOICE_SETTINGS_FIELD_DOCS: FieldDocs<VoiceSettings> = {
"(`<home>/targets/`). Blank = `~/.local/share/archilyzer/voice`. Absolute, or `~/`-relative.",
threads: "CPU threads a torch engine (openvoice, seed-vc) may use. 1–16.",
enhance: "The enhance op's default engine. See VoiceEnhanceSettings (`voice.enhance` below).",
- convert: "The convert op's default engine and target. See VoiceConvertSettings (`voice.convert` below).",
+ convert: "The convert op's default engine, target and pitch. See VoiceConvertSettings (`voice.convert` below).",
heavyEstimateMB:
"Per engine id: the memory (MB) its job is admitted to the machine's heavy slot with " +
"(`queue-lock --heavy --estimate`) — it runs only when that much is free above the floor. " +
- "The defaults are the 2026-11-03 bake-off's measured peaks plus a margin. An engine left out " +
+ "The defaults are the 2026-11-03 bake-off's measured peaks plus a margin; `seed-vc-f0` is seed-vc's " +
+ "run when it follows the input's pitch (`pitch: source | contour` — another, bigger model; measured " +
+ "2026-11-11). An engine left out " +
"takes its default; 0 declares nothing (the job then runs ALONE in the slot).",
};
@@ -78,6 +89,16 @@ export const VOICE_CONVERT_SETTINGS_FIELD_DOCS: FieldDocs<VoiceConvertSettings>
"`<tts engine>:<stock voice>` (`orpheus:zac`, `orpheus:leah`, `kokoro:am_michael`, …). Never a " +
"file or a recording — no real person's voice is a target. Its reference clip is synthesized " +
"once through the `tts` op and kept under `home`. Anything else falls back to `orpheus:zac`.",
+ pitch:
+ "The pitch a conversion lands on when the request names none — for an engine that can follow the " +
+ "input's (seed-vc, with its optional f0 model: `archilyzer voice setup --engine seed-vc --with f0`; " +
+ "openvoice always lands on the target's). `target`: the stock voice's own pitch — the read's " +
+ "intonation is flattened to it (what there was before). `source`: the pitch the take was read at — " +
+ "raise your voice and the result rises. `contour`: the read's rises and falls, moved as a whole so " +
+ "their median sits on the stock voice's. Anything else falls back to `target`.",
+ semitones:
+ "Semitones a FOLLOWED pitch (`source`, `contour`) is moved by when the request names none: -12 to 12, " +
+ "0 = as followed. Ignored for `target`.",
};
// "" (the default), an absolute path, or a `~/` one; anything else is "".
@@ -109,7 +130,15 @@ export function sanitizeVoice(value: unknown): VoiceSettings {
home: dirSetting(r.home),
threads: Math.min(16, Math.max(1, threads)),
enhance: { engine: engineFor("enhance", en.engine) },
- convert: { engine: engineFor("convert", cv.engine), target: target.ok ? target.value.id : DEFAULT_VOICE_TARGET },
+ convert: {
+ engine: engineFor("convert", cv.engine),
+ target: target.ok ? target.value.id : DEFAULT_VOICE_TARGET,
+ pitch: VOICE_PITCH_MODES.includes(cv.pitch as VoicePitch) ? (cv.pitch as VoicePitch) : DEFAULT_VOICE_PITCH.pitch,
+ semitones:
+ typeof cv.semitones === "number" && Number.isFinite(cv.semitones)
+ ? Math.min(VOICE_SEMITONES_MAX, Math.max(-VOICE_SEMITONES_MAX, Math.round(cv.semitones * 100) / 100))
+ : DEFAULT_VOICE_PITCH.semitones,
+ },
heavyEstimateMB,
};
}
diff --git a/editor/app/api/ops/voice-convert/route.ts b/editor/app/api/ops/voice-convert/route.ts
@@ -7,7 +7,7 @@ import { jobResponse, ops } from "../_lib";
export const dynamic = "force-dynamic";
-// POST { file, out, voice?, engine?, params?, parts? } -> { ok: true, jobId }
+// 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
@@ -22,7 +22,12 @@ export const dynamic = "force-dynamic";
// `engine` is `openvoice` (OpenVoice v2's converter) or `seed-vc` (Seed-VC v1),
// default settings.voice.convert.engine — `archilyzer voice setup --engine
// <id>` installs one; `file`/`path`, `out`, `params` and `parts` as for
-// voice-enhance. umtool's derived takes (`umtool posts narrate … --derive <n>
+// 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 <n>
// --op convert`) are the caller.
//
// The job's log ends with `@@voice-result {json}` — voice-enhance's shape plus
diff --git a/scripts/archilyzer-ops.mjs b/scripts/archilyzer-ops.mjs
@@ -559,7 +559,8 @@ const ACTIONS = [
"tts",
// Run an engine over a speech RECORDING ({file, out, engine?, params?,
// parts?}; convert also takes voice — a stock synthetic voice
- // `<tts engine>:<voice>`, never a recording), as a job on the `voice` queue
+ // `<tts engine>:<voice>`, never a recording — and pitch / semitones, the
+ // pitch the result lands on), as a job on the `voice` queue
// behind the heavy slot. With --wait the result JSON is what stdout carries.
"voice-enhance",
"voice-convert",
@@ -2005,8 +2006,16 @@ export function usage() {
" kokoro:am_michael, ...; settings.voice.convert.target); a file, a path or a",
" recording is REFUSED as a target (no real person's voice) — and \"engine\"",
" (openvoice | seed-vc, each installed by `archilyzer voice setup --engine <id>`).",
+ ' "pitch" is where the result\'s pitch comes from (settings.voice.convert.pitch):',
+ ' "target" — the stock voice\'s own, the read\'s intonation flattened to it;',
+ ' "source" — the pitch the take was read at (raise your voice and it rises);',
+ ' "contour" — the read\'s rises and falls, moved as a whole to the stock voice\'s',
+ ' register. "semitones" (-12 to 12) then moves a followed pitch. source and',
+ " contour are seed-vc's, on its optional f0 model (`archilyzer voice setup",
+ " --engine seed-vc --with f0`; slower, 44.1 kHz); openvoice refuses them.",
" The target's reference is synthesized once through the tts op and kept. The",
- " result adds target, voice, synthetic: true and the disclosure line.",
+ " result adds target, voice, pitch (semitones and f0 — the medians heard and the",
+ " move applied — when followed), synthetic: true and the disclosure line.",
"",
'web-search searches the web (DuckDuckGo\'s HTML page) and answers the',
' results: {"query", "n"?: 6 (at most 20)} -> {results: [{title, url,',
diff --git a/settings.json.example b/settings.json.example
@@ -268,13 +268,16 @@
},
"convert": {
"engine": "openvoice",
- "target": "orpheus:zac"
+ "target": "orpheus:zac",
+ "pitch": "target",
+ "semitones": 0
},
"heavyEstimateMB": {
"deepfilternet": 400,
"rnnoise": 300,
"openvoice": 2000,
- "seed-vc": 3500
+ "seed-vc": 3500,
+ "seed-vc-f0": 4500
}
},
"generation": {