voice: add custom Piper voice training pipeline
Record an LJSpeech dataset from the microphone, fine-tune a Piper voice from the pinned base checkpoint on a GPU host, and verify every take against its prompt with Whisper before training. - semif_agent/voice_train.py: neutral, stdlib-only recording helpers (LJSpeech dataset writer, prompt loading, WAV I/O, mic-check level math, silence-endpointing capture loop) plus transcript-fidelity helpers (normalize_text, word_error_rate, compare_transcript). - scripts/voice-record.py: interactive + hands-free (--speak-prompts / --read-prompts) recording; resumes by prompt id and announces how many of the 720 prompts remain, so a resume is never mistaken for a rerun. - scripts/voice-train.sh: piper1-gpl checkout + venv, warmstart fine-tune of the pinned medium checkpoint, ONNX export. Handles torch>=2.6 weights_only (PosixPath allowlist), the older checkpoint's hyperparameters (--model.warmstart_ckpt, not --ckpt_path), the espeakbridge in-place dev build, and piper's validation/test splits (needed for the default checkpoint callbacks). - scripts/voice-verify.py: transcribe-and-compare fidelity check (empty/mismatch/review/ok), --json report, --from-json + --prune to mark bad takes for re-recording without deleting them. - pins.json: voice block (piper1-gpl ref + medium base checkpoint). - voice_transport.py: WhisperTranscriber beam_size/vad_filter knobs; SoundDeviceAudio.read(timeout=) so a dropped device ends a take instead of hanging. - AGENTS.md: architecture map + roadmap entries; docs/VOICE-TRAIN.md the end-to-end guide; tests/test_voice_record.py the helper tests.
This commit is contained in:
1 parent
aa25693091
commit
b7d405454a
10 files changed
+2778
-6
No files matched your search
@@ -289,6 +289,15 @@ voice_transport.py
|
||||
lazy-imported, keeping the module stdlib-only; the engine
|
||||
interfaces are plain classes so tests inject fakes. Knows
|
||||
nothing about the scheduler or the gateway.
|
||||
voice_train.py
|
||||
neutral recording helpers for training a custom Piper voice
|
||||
(optional, off-bootstrap): LJSpeech dataset writer
|
||||
(`metadata.csv` + `wavs/NNNN.wav`), prompt loading, WAV I/O,
|
||||
level math for the mic check, and the silence-endpointing
|
||||
capture loop. Stdlib-only (numpy lazy in `resample_pcm16`);
|
||||
`scripts/voice-record.py` is the CLI front end and
|
||||
`scripts/voice-train.sh` the GPU fine-tune/export pipeline. See
|
||||
docs/VOICE-TRAIN.md. Knows nothing about the scheduler.
|
||||
```
|
||||
|
||||
## Run / verify
|
||||
@@ -549,6 +558,22 @@ CLI, unit tests (24) + integration tests (2).
|
||||
the venv under `.runtime/venv`, the Piper voice under `.runtime/voice/tts`,
|
||||
the faster-whisper model in the `.runtime/hf` cache). See
|
||||
"### gateway (messenger intake)".
|
||||
- **Custom Piper voice (train your own)** (Oct 2026): the TTS voice is
|
||||
replaceable with one fine-tuned on the user's own recordings. This is an
|
||||
optional, off-bootstrap pipeline (`scripts/voice-record.py` records an
|
||||
LJSpeech dataset; `scripts/voice-train.sh` fine-tunes from the checkpoint
|
||||
pinned in `pins.json` `voice` and exports ONNX on a GPU host;
|
||||
`semif_agent/voice_train.py` holds the neutral recording helpers).
|
||||
Deployment needs **no gateway code change**: `cli._build_gateway_adapter`
|
||||
anchors `tts.voice_dir` to `.runtime/voice/tts`, so a trained `<name>.onnx` +
|
||||
`<name>.onnx.json` dropped there is selected by setting
|
||||
`gateway.voice.tts.voice` to `<name>`. Only a real spoken reply proves it.
|
||||
The recorder has three modes: interactive (default), `--speak-prompts`
|
||||
(TTS reads each line) and `--read-prompts` (prints each line + beeps, no
|
||||
speech). Two field gotchas: a mic that re-enumerates (usually on a USB hub)
|
||||
drops the stream — reads take a `--read-timeout` so a take ends instead of
|
||||
hanging, and prefer a direct port; and prompt/reply audio needs the ALSA
|
||||
output unmuted (PortAudio has no volume control). See `docs/VOICE-TRAIN.md`.
|
||||
- **Bridge services (SimpleX first)** (Sep 2026): messaging *UX* — invite links,
|
||||
reading incoming messages, composing sends — is decoupled from the command
|
||||
gateway. `semif_agent.bridges` is a folder of standalone third-party API
|
||||
@@ -1220,7 +1245,10 @@ CLI, unit tests (24) + integration tests (2).
|
||||
`simplex.connect_link`. `tests/test_voice_gateway.py` drives the voice loop
|
||||
with injected fake engines (wake gating, endpointing, half-duplex,
|
||||
follow-up window, `speak` truncation/failure, adapter + CLI wiring) — no
|
||||
hardware, network, or heavy packages. The live `websockets` transport against
|
||||
hardware, network, or heavy packages. `tests/test_voice_record.py` covers the
|
||||
recording helpers (`semif_agent/voice_train.py`) — prompt loading, WAV I/O,
|
||||
level math, the silence-endpointing loop, and the LJSpeech dataset writer —
|
||||
with a scripted fake audio source. The live `websockets` transport against
|
||||
a real daemon, the live LXMF transport against a real Reticulum network, and
|
||||
the live voice pipeline against a real microphone are live-integration
|
||||
concerns.
|
||||
|
||||
Reference in new issue
Block a user