SynVoice.io
#asterisk #pbx #ivr #telephony #integration

Asterisk PBX + TTS Integration Guide (2026)

SV
SynVoice Editorial Team
October 16, 2026
4 min read 61 views
Asterisk PBX plus TTS integration: methods, dialplan patterns, voice quality upgrades, and production tips for open-source telephony in 2026.

Asterisk powers countless open-source phone systems, and text-to-speech gives those systems a voice without recording every prompt. IVR menus, voicemail greetings, queue announcements, and notifications all become dynamic when Asterisk can speak text on demand. Integrating modern AI voices with Asterisk dramatically improves caller experience over the robotic defaults.

This guide covers Asterisk PBX plus TTS integration in 2026: the integration methods, dialplan patterns, voice quality upgrades, and production considerations.

TL;DR: Asterisk integrates TTS three ways: pre-generated audio files for static prompts (simplest), AGI scripts calling a TTS API for dynamic content like names and balances (1-2s latency), and real-time streaming for conversational AI. Most production systems combine pre-generation with AGI synthesis. Design for telephony constraints — 8kHz audio, prompts under 20 seconds, aggressive caching by content hash — and build redundancy: fallback audio, monitored latency, and quarterly failover drills.

Key Takeaways

  • Asterisk integrates TTS via AGI scripts, external APIs, or pre-generated audio files.
  • Modern AI voices massively outperform Asterisk's default robotic prompts.
  • Cache generated audio aggressively; phone prompts repeat constantly.
  • Design for telephony: 8kHz audio, concise scripts, clear enunciation.
  • SynVoice generates the premium prompts your Asterisk system deserves.
  • Pre-generation plus AGI synthesis covers 95% of production needs.

Definition: AGI (Asterisk Gateway Interface) is Asterisk's mechanism for handing call control to an external script. An AGI script can query databases, call TTS APIs, and decide what audio to play — it is the standard way to add dynamic behavior to a dialplan.

Definition: An IVR (Interactive Voice Response) menu is the "press 1 for sales" phone tree callers navigate. IVR prompts are the highest-value TTS target in Asterisk because they play thousands of times daily and define the caller's first impression of the business.

Integration Methods

Three approaches fit different needs. Pre-generated audio files are simplest: synthesize prompts with a TTS provider, save as WAV or GSM, and play via the Playback or Background dialplan applications. This suits static IVR menus and greetings with zero runtime dependencies. AGI-based dynamic synthesis: an AGI script calls a TTS API when the call needs dynamic content (names, balances, dates), saves the audio, and plays it. This enables fully dynamic voice applications with 1-2 seconds of added latency. Real-time streaming via EAGI or external media: for conversational applications, stream audio with minimal latency.

Most deployments combine methods: pre-generated files for static prompts, AGI synthesis for dynamic segments. Choose based on how dynamic your content is.

Which method fits your content?

  • Static prompts (main menu, business hours, voicemail greeting): pre-generate. Zero runtime cost, zero latency, zero failure modes.
  • Semi-dynamic (appointment reminders with names/dates, balance inquiries): AGI synthesis with content-hash caching. First caller pays the synthesis latency; every caller after gets the cached file.
  • Fully dynamic (conversational agents, real-time responses): streaming. Highest complexity — only justified when the conversation cannot be pre-computed.

Dialplan Patterns

Effective dialplan design separates concerns. Use macros or subroutines for common prompt patterns so voice logic stays maintainable. Implement a prompt cache check before synthesis: look up the audio file by content hash, generate only on miss. Structure IVR menus with Background for interruptible prompts and WaitExten for input collection. Handle synthesis failures gracefully: fall back to pre-recorded or default-voice prompts rather than dead air. Log synthesis latency per call to monitor performance. Version your prompt files so updates deploy cleanly. Keep dialplan readable: voice application logic grows complex fast, and future-you will thank present-you for clear structure.

The cache-first AGI pattern

The single most important dialplan pattern for TTS cost and latency:

  1. Compute a hash of the prompt text (plus voice ID and language).
  2. Check the cache directory for the hashed filename.
  3. On hit: play the file immediately — no API call, no latency.
  4. On miss: call the TTS API, save to the hashed filename, then play.
  5. On API failure: play the fallback prompt and log the miss.

IVR prompts repeat thousands of times daily, so a warm cache means the TTS API is barely touched in steady state. Size the cache directory generously and never expire entries aggressively — disk is cheaper than synthesis.

Integration Approach Comparison

MethodLatencyComplexityBest For
Pre-generated filesNoneLowStatic IVR, greetings
AGI dynamic synthesis1-2 secondsMediumDynamic content
Real-time streaming<500msHighConversational AI
Default Asterisk voicesNoneNoneTesting only

Pre-generation plus AGI synthesis covers 95% of production needs.

How Do You Write Prompts for Telephony?

Phone audio is unforgiving: 8kHz bandwidth, compression artifacts, distracted callers, no rewind. Script accordingly:

  • Front-load key information. "Your balance is $120" before the pleasantries, not after.
  • Keep prompts under 20 seconds. Longer prompts get talked over or abandoned.
  • Speak numbers digit by digit for account numbers and confirmation codes; naturally for amounts.
  • One question per prompt. "Press 1 for sales, 2 for support" — never three options in one breath.
  • State the repeat option. "Press star to hear this again" respects callers who missed it.
  • Generate at a measured pace. Slightly slower than conversational; telephony compression smears fast speech.

Test every prompt by calling in from a real mobile phone on a cellular connection — not from your desk VoIP phone. If it is unclear on a crackly mobile call, it is unclear for your customers.

Production Considerations

Telephony has hard constraints. Audio must suit 8kHz channels: generate at higher quality and let the pipeline downsample, but test the final phone audio since compression changes perception. Script concisely: callers cannot rewind, so front-load key information and keep prompts under 20 seconds. Cache everything: IVR prompts repeat thousands of times daily, making caching the highest-ROI optimization. Monitor synthesis API latency and costs; set alerts for spikes. Secure your AGI endpoints: they execute on call arrival and must not be exploitable. Plan for provider outages with local fallback audio. Document your prompt inventory; Asterisk systems accumulate hundreds of prompts that need periodic review and updating.

Design for high availability from the start. Telephony systems cannot go down during business hours, so build redundancy: multiple Asterisk servers with failover, TTS caching that survives provider outages, and local fallback audio for every critical prompt. Test failover regularly; untested redundancy is just hope. Monitor call completion rates as your primary health metric; drops indicate problems faster than server metrics. Keep configuration in version control and automate deployments to avoid snowflake servers. Document your dialplan thoroughly; the person debugging at 2 AM might be future-you. Production telephony rewards boring reliability over clever features every single time.

Schedule quarterly disaster-recovery drills simulating provider outages and failover events. Keep a runbook of common failure modes and their fixes where every on-call engineer can find it in seconds. Teams that rehearse recover in minutes while others debug for hours.

The production readiness checklist

  1. All static prompts pre-generated in 8kHz 16-bit WAV (or GSM).
  2. AGI cache-first pattern implemented with content-hash filenames.
  3. Fallback audio configured for every synthesis failure path.
  4. Synthesis latency logged per call with alerting on spikes.
  5. AGI endpoints secured and input-validated.
  6. Prompt inventory documented with owners and review dates.
  7. Config in version control; deployments automated.
  8. Failover tested; quarterly DR drill scheduled.

What should you monitor in production?

Four metrics tell you nearly everything about TTS health in Asterisk. Synthesis latency per call — alert when p95 exceeds your budget, since slow synthesis means callers waiting in silence. Cache hit rate — a sudden drop means prompt churn or a cache bug, both worth investigating. API error rate and cost — spikes indicate either an outage or a runaway dialplan generating unique prompts. Call completion rate — the ultimate health metric; drops here indicate caller-facing problems faster than any server metric. Dashboard all four, alert on all four, and review them weekly until the patterns are boring.

Give your PBX a professional voice. Try SynVoice free and generate telephony-ready prompts today.

Frequently Asked Questions

How do I add text to speech to Asterisk?

Three ways: pre-generate audio files and play them via Playback or Background dialplan applications, use AGI scripts to call TTS APIs dynamically during calls, or stream audio for real-time applications. Pre-generation suits static prompts; AGI synthesis handles dynamic content like names and account balances.

What audio format does Asterisk need?

Asterisk plays WAV, GSM, and other formats natively; 8kHz 16-bit WAV (or GSM for smaller files) is the telephony standard. Generate at high quality with your TTS provider and convert to telephony formats in your pipeline, then test the final result on a real mobile call.

Can Asterisk use modern AI voices?

Absolutely. Generate prompts with any modern TTS provider and integrate via files or AGI scripts. The quality difference over Asterisk's default robotic voices is dramatic and immediately noticeable to callers — it is often the single biggest caller-experience upgrade available.

How do I handle dynamic content like account balances?

Use AGI to synthesize the dynamic segment on call arrival, cache the result by content hash so repeat requests cost nothing, and play the cached file. Split prompts into static and dynamic parts to minimize synthesis, and always implement fallback audio for API failures.

Is TTS reliable enough for production phone systems?

Yes, with proper architecture: aggressive caching, fallback audio for every critical prompt, latency monitoring with alerts, and tested failover modes. Many production Asterisk systems serve thousands of daily calls with TTS-driven prompts reliably for years. The teams that succeed treat voice prompts as production infrastructure, not accessories.

How do I keep TTS costs down in a high-volume call center?

Cache-first AGI design means each unique prompt is synthesized once and replayed thousands of times — steady-state API usage approaches zero for static and semi-dynamic content. Pre-generate everything static, hash-cache everything dynamic, and monitor for cache misses that indicate prompt churn.

What is the biggest mistake in Asterisk TTS integrations?

Skipping the fallback path. Teams build the happy path — API up, audio plays — and discover during the first provider outage that callers hear dead air. Every synthesis call needs a local fallback prompt, tested regularly. The second mistake is untested failover: redundancy you have never drilled is just hope.

Should I use streaming or AGI synthesis for dynamic prompts?

AGI synthesis for nearly everything. The 1-2 second latency is acceptable for balance inquiries, appointment details, and queue announcements — and the architecture is far simpler. Reserve real-time streaming for genuinely conversational applications where sub-500ms response is required, since the complexity cost is high.

Give your PBX a professional voice. Try SynVoice free and generate telephony-ready prompts today.

Share this guide
Share on X
Free Trial Available

Create Studio-Quality AI Voiceovers

Convert text to natural speech with 5,000 free credits. Access 38,000+ ElevenLabs & neural voices instantly.