25 lines
803 B
Python
25 lines
803 B
Python
#!/usr/bin/env python3
|
|
"""Collector self-test: synthesize a phrase with Piper, transcribe it back with
|
|
faster-whisper. Proves the STT/TTS audio pipeline end-to-end (no phone needed)."""
|
|
import sys
|
|
sys.path.insert(0, "/opt/collector")
|
|
from app import STT, TTS, CFG
|
|
|
|
stt = STT(CFG["stt"])
|
|
tts = TTS(CFG["tts"])
|
|
|
|
print("loading STT (first run downloads whisper model)...")
|
|
stt.load()
|
|
print("loading TTS...")
|
|
tts.load()
|
|
|
|
phrase = "This is the collector self test. If you can hear this, the voice pipeline works."
|
|
pcm16k = tts.synthesize_16k(phrase)
|
|
print("TTS_OK bytes=%d" % len(pcm16k))
|
|
|
|
text = stt.transcribe(pcm16k)
|
|
print("STT_OK transcript=%r" % text)
|
|
|
|
ok = "collector" in text.lower() or "voice" in text.lower() or "hear" in text.lower()
|
|
print("SELFTEST", "PASS" if ok else "PARTIAL", file=sys.stderr)
|