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
@@ -226,10 +226,14 @@ class WhisperTranscriber(Transcriber):
|
||||
device: str = "cpu",
|
||||
compute_type: str = "int8",
|
||||
language: str = "en",
|
||||
beam_size: int = 1,
|
||||
vad_filter: bool = True,
|
||||
):
|
||||
from faster_whisper import WhisperModel
|
||||
|
||||
self.language = str(language or "en") or None
|
||||
self.beam_size = int(beam_size)
|
||||
self.vad_filter = bool(vad_filter)
|
||||
self._model = WhisperModel(str(model or "base.en"), device=str(device or "cpu"),
|
||||
compute_type=str(compute_type or "int8"))
|
||||
|
||||
@@ -240,8 +244,8 @@ class WhisperTranscriber(Transcriber):
|
||||
segments, _info = self._model.transcribe(
|
||||
audio,
|
||||
language=self.language,
|
||||
beam_size=1,
|
||||
vad_filter=True,
|
||||
beam_size=self.beam_size,
|
||||
vad_filter=self.vad_filter,
|
||||
)
|
||||
return " ".join(segment.text.strip() for segment in segments).strip()
|
||||
|
||||
@@ -435,8 +439,19 @@ class SoundDeviceAudio(AudioIO):
|
||||
except queue.Full:
|
||||
pass # a slow consumer (STT) drops stale frames; the mic is real-time
|
||||
|
||||
def read(self) -> bytes | None:
|
||||
return self._frames.get()
|
||||
def read(self, timeout: float | None = None) -> bytes | None:
|
||||
"""Block for the next frame (or up to `timeout` seconds).
|
||||
|
||||
Returns `None` once the input is closed, or on a `timeout` with no
|
||||
frame — a caller that passes a timeout can detect a stalled stream
|
||||
instead of blocking forever.
|
||||
"""
|
||||
if timeout is None:
|
||||
return self._frames.get()
|
||||
try:
|
||||
return self._frames.get(timeout=timeout)
|
||||
except queue.Empty:
|
||||
return None
|
||||
|
||||
def open_output(self, sample_rate: int, device: str = "") -> None:
|
||||
pass # a raw stream is opened per utterance in `write`
|
||||
|
||||
Reference in new issue
Block a user