Integration guide

Asterisk Text to Speech: Self-Hosted Voice Guide (2026)

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.

2026/11/03 Updated 2026/11/03

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.

A modular cream PBX accepts audio-file cartridges and a coral AudioSocket stream before playing to a handset

What does Asterisk handle versus Fish Audio?

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:

  • Playback for stable prompts written to Asterisk's sound path.
  • AudioSocket or another supported external-media interface for live generated audio.
  • Background/control playback where the caller needs to interrupt a prompt.

Review current Asterisk Playback documentation and AudioSocket protocol.

When should prompts be pre-generated?

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:

  1. approve the text and Fish Audio voice;
  2. generate the final file;
  3. normalize format and sample rate for the target playback path;
  4. check the full file on a phone;
  5. version the prompt and store its script hash;
  6. deploy to the Asterisk sound directory or authenticated media store.

Fixed files remove model latency and recurring generation cost from every call. They also make rollback possible.

When should speech be generated during a call?

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 typeRateFormat
0x108 kHzsigned linear 16-bit little-endian mono
0x1216 kHzsigned linear 16-bit little-endian mono
0x1324 kHzsigned 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.

How should the live adapter work?

The external service needs to:

  • accept the AudioSocket connection;
  • validate the UUID;
  • receive caller audio and DTMF;
  • send caller audio to speech recognition;
  • create a short text response;
  • request Fish Audio speech;
  • resample to the negotiated PCM rate;
  • send correctly framed packets;
  • cancel old audio on interruption or hangup.

Keep Fish Audio keys on the media server. Asterisk dialplan should not contain provider secrets.

How does FreeSWITCH differ?

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.

How should SIP and codec behavior be tested?

Test from actual SIP trunks, not only a local softphone. Check:

  • G.711 and negotiated codec behavior;
  • 8 kHz playback;
  • packet loss and jitter;
  • prompt start and end;
  • DTMF during playback;
  • caller interruption;
  • transfer and hangup during generation.

Record a fixed regression set with names, numbers, prices and two languages. Compare every voice or PBX change against it.

How should cost and reliability be planned?

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:

  1. Fish Audio prepaid credits;
  2. Asterisk or FreeSWITCH hosting;
  3. SIP trunking and numbers;
  4. audio storage and monitoring;
  5. engineering and on-call time.

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.

What should launch monitoring include?

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.

Key takeaways

  • Pre-render fixed Asterisk prompts; use live AudioSocket only for dynamic replies.
  • AudioSocket documents signed 16-bit little-endian mono PCM at several rates.
  • Implement the current packet header, UUID and termination rules.
  • FreeSWITCH uses a similar architecture but a different module contract.
  • Fish Audio credits are separate from PBX, SIP and hosting costs.

Frequently asked questions

Can Asterisk use Fish Audio for text to speech?

Asterisk can play approved files and AudioSocket can carry external PCM. Fish Audio can supply both, but no native Asterisk module is claimed.

Should Asterisk prompts be pre-generated or live?

Pre-generate stable prompts. Use live AudioSocket or an external media service only when the reply must be generated during the call.

What PCM format does Asterisk AudioSocket use?

Asterisk documents signed linear little-endian mono PCM at 8 kHz, 16 kHz and other rates using specific payload types.

How does FreeSWITCH fit?

FreeSWITCH follows the same file-or-stream architecture, but verify its current module and codec contract separately.

How much does the stack cost?

Fish Audio uses prepaid character credits. PBX hosting, SIP, numbers, storage and monitoring are separate costs.

Asterisk Text to Speech: Self-Hosted Voice Guide (2026)