The Nature of Voice Agent Latency Issues
When a voice AI agent is generating a response, the user hears nothing for 5 seconds. The first article on the AWS machine learning blog points out that this 'Time to First Byte' delay arises from the structural limitations of existing text-to-speech (TTS) integration methods. While a single sentence response can be synthesized in 600 milliseconds, waiting for the entire response to be completed and synthesizing it all at once increases the perceived delay for the user to 5 seconds. This is because LLMs stream on a token basis, while TTS still operates in batch mode.
Kokoro-82M: Real-World Deployment Architecture of a Lightweight Model
Both articles use Kokoro-82M (82 million parameters) as the core model. It is a non-autoregressive model trained with adversarial learning, built on a StyleTTS2 derivative with an ISTFTNet decoder, generating the entire utterance in a single pass. Since there is no token generation loop, latency metrics per token cannot be used; instead, ConcurrentRequestsPerModel becomes the sole metric for overload assessment. Deployment is done via a custom container on a ml.g5.xlarge single GPU instance, declaring bidirectional streaming capabilities with the Docker label `com.amazonaws.sagemaker.capabilities.bidirectional-streaming=true`.
| Item | Details |
|---|---|
| Model | Kokoro-82M (82M parameters) |
| Instance | ml.g5.xlarge (Single GPU) |
| Container Port | 8080 (HTTP/2 + WebSocket) |
| Endpoint Type | SageMaker AI Real-Time Endpoint |
| Auto-Scaling Metric | ConcurrentRequestsPerModel (Maximum, 10-second window) |
Implementation of Streaming Synthesis: Bidirectional WebSocket and Sentence-Level Pipeline
The first article implements a sentence-level streaming pipeline. As soon as the agent generates a sentence, it streams it to the TTS endpoint, immediately sending the synthesized audio chunks to the browser. The container exposes two paths.
- `POST /invocations`: Complete streaming response for a single input
- `WS /invocations-bidirectional-stream`: Bidirectional streaming of multiple messages over a single connection
On the client side, a Starlette-based ASGI server maintains the WebSocket connection and calls SageMaker AI's `invoke_endpoint_with_bidirectional_stream` API. This structure advances the audio playback point of the first sentence from the completion of the entire response to the point of sentence generation.
This solution bridges the gap by streaming synthesis simultaneously with generation. Each time the agent generates a sentence, it is streamed to the hosted Kokoro-82M TTS model immediately, allowing audio playback to start before the agent completes the entire response.
The Science of Auto-Scaling: From Guesswork to Measurement-Based Thresholds
The second article quantifies the cost of guessing auto-scaling target values. Conservative guesses hide idle GPU costs, while aggressive guesses conceal the risk of SLO violations during traffic spikes. To address this, all thresholds are derived from just two measured values.
- Q_max: The maximum number of concurrent requests a single instance can handle before violating SLO
- T_total: The end-to-end time taken to complete scale-out (endpoint provisioning + container startup + model loading)
From these two values, scale-out threshold, scale-in threshold, and cooldown are arithmetically derived. The measured results showed that the ratio of CloudWatch `Maximum` statistics to client measured averages was exactly 1, allowing for direct application without unit conversion.
| Q_max | 12 |
| T_total_sec | 180 |
| Scale-out_threshold | 8 |
| Scale-in_threshold | 3 |
| Cooldown_sec | 300 |
Redefining Operational Metrics and Cost Structure
A change that runs through both articles is the shift from 'token-centric' to 'connection and concurrency-centric' metrics. LLM serving auto-scales based on tokens per second, but non-autoregressive TTS like Kokoro-82M has connection hold times per request that can last several seconds and lacks a token loop. Therefore, using the `ConcurrentRequestsPerModel` metric natively issued by SageMaker AI eliminates the risk of failure in custom metric configuration. In terms of cost, handling real-time traffic with a single ml.g5.xlarge instance is expected to reduce TCO by 60-70% compared to multiple large GPU clusters, while measurement-based auto-scaling prevents excessive provisioning. However, the sample container is pinned to an older version of PyTorch with the PYSEC-2026-2286 vulnerability, making it essential to upgrade to torch 2.10.0 or higher before production.
Checklist for Development Teams to Implement Immediately
- Streaming-First Design: LLM token stream → Sentence boundary detection → Build TTS streaming pipeline
- Adopt Bidirectional WebSocket: Handle multiple turns over a single connection, eliminating reconnection overhead
- Auto-Scaling Measurement Routine: Include Q_max/T_total measurement scripts in CI/CD, validate before deployment
- Metric Unit Validation: Measure the ratio of CloudWatch Maximum vs client average, then convert thresholds
- Container Security Patch: Remove base image and PyTorch version pinning and automate vulnerability scanning