Files
gogo-telefon/scripts/generate_fallback_audio.py
Senad Uka fd45ff84dc M6 + M0: hardening, deploy docs, PoC scripts
- Pipeline-down fallback: dialplan plays gogo-fallback after a failed
  AudioSocket (§15) + script to synthesize the Bosnian prompt via TTS
- Voice heartbeat file → /health/voice endpoint + live status in admin panel
- Retention job also purges stale call registrations; chat sessions metered;
  100%-usage super-admin alert email (GOGO_ADMIN_ALERT_EMAIL)
- .env.example, docs/DEPLOY.md (compose stack, GPU node, backups pg_dump,
  update procedure, security notes)
- §16 Definition of Done as an automated test: softphone-style call → fake
  partner availability → request pushed → webhook confirm → console SMS
- M0 PoC scripts: STT accuracy harness (CER/WER + spoken-digit check; dry-run
  verified with espeak-ng samples + faster-whisper small on CPU — phone number
  extracted exactly), TTS bake-off (Azure vs ElevenLabs, latency+cost), and
  end-to-end latency smoke test speaking real AudioSocket to the live pipeline

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-11 11:27:05 +02:00

37 lines
1.1 KiB
Python

"""Generate the Asterisk fallback prompt 'gogo-fallback' (§15) — played when the
voice pipeline is unreachable. Uses the configured TTS provider.
Run: python scripts/generate_fallback_audio.py [asterisk-sounds-dir]
Then place gogo-fallback.wav into Asterisk's sounds dir (or mount it in compose).
"""
from __future__ import annotations
import asyncio
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from gogo.voice.audio import pcm_to_wav # noqa: E402
from gogo.voice.tts import make_tts # noqa: E402
TEXT = (
"Poštovani, trenutno nismo u mogućnosti primiti vaš poziv. "
"Molimo pozovite kasnije, ili posjetite našu web stranicu. Hvala i prijatno!"
)
async def main() -> None:
out_dir = Path(sys.argv[1] if len(sys.argv) > 1 else "./asterisk/sounds")
out_dir.mkdir(parents=True, exist_ok=True)
tts, voice = make_tts()
pcm = await tts.synthesize(TEXT, voice)
path = out_dir / "gogo-fallback.wav"
path.write_bytes(pcm_to_wav(pcm))
print(f"wrote {path} ({len(pcm) // 16} ms)")
if __name__ == "__main__":
asyncio.run(main())