Build Asterisk or FreeSWITCH text to speech with pre-rendered prompts, cached files or live audio streams generated by Fish Audio and tested on SIP.
Asterisk text to speech is best implemented as approved pre-rendered files for stable prompts, with AudioSocket or another external media path reserved for replies that must be generated during the call. Fish Audio supplies the voice; Asterisk supplies dialplan, SIP and playback.
There is no native Fish Audio Asterisk module claimed here. The integration is a file pipeline or an adapter around Asterisk's documented audio interfaces.
Asterisk owns SIP channels, dialplan, queues, transfers, playback and call recording. Fish Audio owns voice generation. The integration boundary is a file or an audio stream.
Use:
Review current Asterisk Playback documentation and AudioSocket protocol.
Pre-generate every prompt that does not depend on live information. This includes greetings, menus, after-hours messages, disclosure text, hold messages and common errors.
The workflow:
Fixed files remove model latency and recurring generation cost from every call. They also make rollback possible.
Use live generation only when the text is unknown until the agent answers, such as account-specific replies, dynamic prices or conversation responses.
Asterisk AudioSocket is a simple TCP protocol for sending and receiving real-time audio and DTMF. It documents signed linear mono PCM types, including:
| Payload type | Rate | Format |
|---|---|---|
0x10 | 8 kHz | signed linear 16-bit little-endian mono |
0x12 | 16 kHz | signed linear 16-bit little-endian mono |
0x13 | 24 kHz | signed linear 16-bit little-endian mono |
The stream starts with a UUID message and terminates on type 0x00 or socket closure. Implement against the current protocol, including packet header and length rules.
The external service needs to:
Keep Fish Audio keys on the media server. Asterisk dialplan should not contain provider secrets.
FreeSWITCH follows the same decision: pre-generated audio or an external media connection. Verify the current FreeSWITCH module, supported codec, framing and playback configuration.
Do not paste Asterisk AudioSocket commands into FreeSWITCH and assume compatibility. The architecture is similar; the module contracts are not identical.
For a mixed estate, keep prompt generation and voice approvals provider-neutral. Store the source script, voice ID, file hash and target PBX alongside the asset.
Test from actual SIP trunks, not only a local softphone. Check:
Record a fixed regression set with names, numbers, prices and two languages. Compare every voice or PBX change against it.
Fixed prompts use Fish Audio credits once and can be cached indefinitely. Dynamic replies consume characters per turn and may consume more when interrupted or retried.
The total cost includes:
Use TTS API pricing for generation estimates. The voice-agent TTS fallback guide covers a controlled switch to pre-recorded prompts when live synthesis fails.
Track AudioSocket connection failures, first-audio p95, packet framing errors, generation timeouts, interruption rate, fallback rate and calls abandoned during the first second.
Keep a prompt/version registry and a call-level correlation ID. Do not log full call audio unless the retention and consent policy explicitly allows it.
Asterisk can play approved files and AudioSocket can carry external PCM. Fish Audio can supply both, but no native Asterisk module is claimed.
Pre-generate stable prompts. Use live AudioSocket or an external media service only when the reply must be generated during the call.
Asterisk documents signed linear little-endian mono PCM at 8 kHz, 16 kHz and other rates using specific payload types.
FreeSWITCH follows the same file-or-stream architecture, but verify its current module and codec contract separately.
Fish Audio uses prepaid character credits. PBX hosting, SIP, numbers, storage and monitoring are separate costs.