"""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())