AWS Polly Text to Speech (tts)
Overview​
| Property | Details |
|---|---|
| Description | Convert text to natural-sounding speech using AWS Polly's neural and standard TTS engines |
| Provider Route on LiteLLM | aws_polly/ |
| Supported Operations | /audio/speech |
| Link to Provider Doc | AWS Polly SynthesizeSpeech ↗ |
Quick Start​
LiteLLM SDK​
SDK Usage
import litellm
from pathlib import Path
import os
# Set environment variables
os.environ["AWS_ACCESS_KEY_ID"] = ""
os.environ["AWS_SECRET_ACCESS_KEY"] = ""
os.environ["AWS_REGION_NAME"] = "us-east-1"
# AWS Polly call
speech_file_path = Path(__file__).parent / "speech.mp3"
response = litellm.speech(
model="aws_polly/neural",
voice="Joanna",
input="the quick brown fox jumped over the lazy dogs",
)
response.stream_to_file(speech_file_path)
LiteLLM PROXY​
proxy_config.yaml
model_list:
- model_name: polly-neural
litellm_params:
model: aws_polly/neural
aws_access_key_id: "os.environ/AWS_ACCESS_KEY_ID"
aws_secret_access_key: "os.environ/AWS_SECRET_ACCESS_KEY"
aws_region_name: "us-east-1"
Polly Engines​
AWS Polly supports different speech synthesis engines. Specify the engine in the model name:
| Model | Engine | Cost (per 1M chars) | Description |
|---|---|---|---|
aws_polly/standard | Standard | $4.00 | Original Polly voices, faster and lowest cost |
aws_polly/neural | Neural | $16.00 | More natural, human-like speech (recommended) |
aws_polly/generative | Generative | $30.00 | Most expressive, highest quality (limited voices) |
aws_polly/long-form | Long-form | $100.00 | Optimized for long content like articles |