Tutorial56:53
Running real-time applications on Modal: Low-Latency Voice Agents
Building real-time, low-latency Voice AI applications requires dealing with infrastructure limits, strict latency budgets, and unpredictable user traffic.
In this webinar, Modal forward deployed engineer Ben breaks down how to architect and deploy production-ready voice AI apps on Modal's AI infrastructure. From speech-to-text (STT) and text-to-speech (TTS) pipelines to handling voice agents, this breakdown covers the engineering patterns required to optimize for speed, quality, and compute costs.
If you are building conversational voice bots, self-hosting open-source speech models, or scaling real-time GPU workloads, this talk breaks down the infrastructure challenges and the engineering solutions that work in production.
*The Core Idea*
Voice AI applications are sensitive to latency and experience fluctuating user demand. Relying solely on rigid, over-provisioned GPU hardware or multi-tenant proprietary APIs can lead to high costs, poor service quality, or severe P99 latency spikes.
- Decouple the pipeline: Deploy your speech-to-text, LLM, and text-to-speech layers as independent serverless functions that auto-scale separately based on their specific concurrency limits.
- Utilize GPU process snapshotting: Capture state checkpoints to speed up model startup times.
- Interleave audio and compute workflows: Use streaming patterns, low-cost warm CPU nodes, and asynchronous audio execution to mask cold starts completely.
The result:
- *Massive Cost Reductions:* High-throughput batch transcription pipelines that run at a fraction of the cost of proprietary alternatives.
- *Sub-Second Round Trips:* Responsive real-time voice agents optimized to minimize the time-to-first-speech.
- *True Serverless Scaling:* Infrastructure that scales up instantly to handle peak usage bursts and tears down to zero when idle.
*What You'll Learn*
*The Core Components of Voice AI Pipelines*
- How Speech to Text (STT) and Text to Speech (TTS) form the foundation of any voice system.
- The role of Voice Activity Detection (VAD) and Diarization (speaker identification) in production audio processing.
- Why conversational interfaces require distinct turn-taking models to differentiate between a brief user pause and a completed thought.
*Optimizing Batch Audio Workloads*
- How to build multi-level batching pipelines that scale horizontally across cloud GPUs simultaneously.
- Why processing audio in a parallel forward pass out-competes traditional API structures.
*Continuous Batching Limitations for Speech*
- Why popular continuous batching architectures (like vLLM and SGLang) work natively for LLMs but do not yet cleanly exist as general-purpose engines for voice models.
*How Modal Minimizes Latency & Cold Starts*
- *GPU Process Snapshots:* Drops native model initialization and engine setup times (which normally range from 25 to 90 seconds) down to under 10 seconds.
- *Warm CPU Buffering:* Keeping lightweight CPU nodes (like the frontend server and bot runner) continuously warm for pennies an hour ensures instant initial contact.
- *Canned Intro Execution:* Instantly playing a localized, pre-recorded introduction audio file right upon connection to cleanly mask background model container startup times.
- *First-Sentence Streaming:* Pulling the very first generated sentence from a streaming LLM output and sending it straight to the TTS engine immediately, allowing audio playback to start while subsequent sentences are still being processed down-line.
*Key Performance Insights*
- *Sort Batches by Audio Duration:* When batching audio on a GPU, the inference call will not complete until its longest element finishes. Sorting files by duration ensures uniform lanes, eliminating dead time and maximizing throughput.
- *Isolated Scaling Parameters:* Because STT, LLMs, and TTS systems have vastly different concurrent throughput capacities, running them as individual microservices keeps bottlenecks isolated and prevents systemic failure.
*Architecture Highlights*
- *FastAPI Frontends:* Lightweight HTTP/WebRTC handshaking servers that dynamically spin up single-use, dedicated conversation containers on demand.
- *Modular Agent Ecosystems:* Seamlessly working alongside leading real-time orchestration frameworks like PipeCat and LiveKit.
- *Self-Hosted Model Tech Stack:* Strategies for utilizing engines like vLLM, SGLang, Triton, or Nemotron for self-hosting open-source variants.
- *Self-Hosted Proprietary Deployments:* Step-by-step validation for hosting enterprise solutions (such as DeepGram) natively within your own dedicated serverless cluster.