From the source
Amazon's guide shows how to stream each sentence from an AI agent to a hosted Kokoro-82M text-to-speech model on SageMaker AI, so audio starts before the full answer is written.
- The problem it addresses is the silence a caller hears while a text-to-speech integration waits for a long, multi-paragraph response to finish generating.
- Kokoro-82M has 82 million parameters, small enough to run cheaply on a single mid-tier GPU instance, which the guide says keeps latency and inference cost low for a voice agent handling real traffic.
- The model runs in a custom container on a SageMaker AI real-time endpoint on an ml.g5.xlarge instance, exposing a POST route for one complete input and a WebSocket route that holds one connection open across many messages.
- The walkthrough deploys the endpoint and the Amazon Bedrock AgentCore runtime hosting a Strands agent through two CLI tools, each wrapping its own AWS CDK stacks, and the endpoint must be deployed first.
- It also covers two client-side fixes: SageMaker AI delivers every part of a message as a binary WebSocket frame, so a handler calling receive_text() fails on every request, and the session must stay open between messages.
- The sample container pins an older PyTorch with a known advisory, PYSEC-2026-2286, fixed in torch 2.10.0, which the guide says should be reviewed and upgraded before any non-proof-of-value use.