Amazon Polly TTS integration guide

How to use the Amazon Polly TTS plugin for LiveKit Agents.

Overview

Amazon Polly is an AI voice generator that provides high-quality, natural-sounding human voices in multiple languages. With LiveKit's Amazon Polly integration and the Agents framework, you can build voice AI applications that sound realistic.

Quick reference

This section includes a basic usage example and some reference material. For links to more detailed documentation, see Additional resources.

Installation

Install the plugin from PyPI:

pip install "livekit-agents[aws]~=1.0rc"

Authentication

The Amazon Polly plugin requires an AWS API key.

Set the following environment variables in your .env file:

AWS_ACCESS_KEY_ID=<aws-access-key-id>
AWS_SECRET_ACCESS_KEY=<aws-secret-access-key>
AWS_DEFAULT_REGION=<aws-deployment-region>

Usage

Use an Amazon Polly TTS within an AgentSession or as a standalone speech generator. For example, you can use this TTS in the Voice AI quickstart.

from livekit.plugins import aws
session = AgentSession(
tts=aws.TTS(
voice="Ruth",
speech_engine="generative",
language="en-US",
),
# ... llm, stt, etc.
)

Parameters

This section describes some of the parameters. See the plugin reference for a complete list of all available parameters.

voiceTTSModelsOptionalDefault: Ruth

Voice to use for the synthesis. For a full list, see Available voices.

languageTTS_LANGUAGE | stringOptional

Language code for the Synthesize Speech request. This is only necessary if using a bilingual voice, such as Aditi, which can be used for either Indian English (en-IN) or Hindi (hi-IN). To learn more, see Languages in Amazon Polly.

speech_engineTTS_SPEECH_ENGINEOptionalDefault: generative

The voice engine to use for the synthesis. Valid values are standard, neural, long-form, and generative. To learn more, see Amazon Polly voice engines.

Controlling speech and pronunciation

Amazon Polly supports Speech Synthesis Markup Language (SSML) for customizing generated speech. To learn more, see Generating speech from SSML docs and Supported SSML tags.

Additional resources

The following resources provide more information about using Amazon Polly with LiveKit Agents.

Voice AI quickstart

Get started with LiveKit Agents and Amazon Polly.