Skip to content
Agents tracked: 467 Releases (7d): 716 Agent status: all upSince last limit reset: Claude 37d · Codex 1d Updated Oct 29, 2026
Recipe

Stream low-latency agent speech with Kokoro TTS on Amazon SageMaker AI

An AWS blog post shows how to send each sentence from an AI voice agent to a hosted Kokoro-82M text-to-speech model as soon as it is generated. Audio playback can then begin before the full response is finished, and the authors report lower time to first audio.

The problem

Voice agents often wait for the whole response to be generated before text-to-speech starts. A reply that takes about five seconds to finish leaves the customer in silence even when the first sentence was ready quickly. Returning the audio to a browser adds a second problem, because the common Server-Sent Events pipeline is built for text rather than binary audio.

Steps

  1. Deploy the Kokoro-82M container to a SageMaker AI real-time endpoint on an ml.g5.xlarge GPU instance, using the CDK-based speech-infra CLI, then deploy the Strands agent to Bedrock AgentCore runtime with agent-infra.
  2. Make the WebSocket handler accept both text and binary frames, since SageMaker AI delivers client messages as binary.
  3. Keep the bidirectional session open after each synthesis_complete frame and close it only when the client sends an explicit close message.
  4. Use a sentence chunker that is fed text fragments as they arrive and emits complete sentences, with a final flush for any leftover text.
  5. Pick a transport for returning audio: base64 audio inside SSE events if you already run SSE, or raw binary audio mixed with JSON control frames on the bidirectional session.
  6. Compare bidi and batch modes with the agent-infra demo command against your own endpoint.

From the official docs

uv run speech-infra deploy kokoro-82m
uv run agent-infra deploy --bedrock-model-id <your-bedrock-model-id>
uv run agent-infra demo --endpoint-url <your-endpoint-url> --prompt "<your prompt>"

Results

  • As reported by AWS, sending only the first sentence cut mean time to first audio byte from 329.3 ms to 156.7 ms, a 52.4 percent relative improvement at the TTS transport level (five trials each).
  • As reported by AWS, end-to-end time to first audio in bidi mode was 2.4 times faster than batch mode against a local container and 3.5 times faster on the deployed AgentCore runtime.
  • As reported by AWS, base64 encoding inflates audio payloads by close to 33%, and SSE chunk boundaries may not align with MP3 frames, so a consumer needs to buffer and reassemble.

As reported by the source (AWS Machine Learning Blog post); AgentGid did not measure these figures.

Takeaway. Start synthesis on the first complete sentence and reuse one persistent bidirectional session, so playback begins while the model is still generating.
AgentGid's take

This suits a team already on AWS with engineers comfortable with CDK, WebSockets and audio streaming. It needs a GPU endpoint (ml.g5.xlarge) plus AgentCore deployment, and the timing gains are AWS-reported, so measure against your own endpoint. Strands Agents is free (OSS), but the hosting isn't; if you'd rather not be tied to AWS, LangGraph (Free, OSS) is a more popular option.

The agent used here

Similar use cases