AWS Polly
The AWSPollyTTSService uses Amazon Polly to turn text into lifelike speech. It features both standard and neural engines, offering a wide selection of across dozens of languages.
Installation
To use AWS Polly, install the required dependencies:
pip install "piopiy-ai[aws]"
Prerequisites
- An AWS account with Polly permissions (Get yours here).
- AWS Access Key and Secret Key.
- Configure your environment:
export AWS_ACCESS_KEY_ID="your_access_key"
export AWS_SECRET_ACCESS_KEY="your_secret_key"
export AWS_REGION="us-east-1"
Configuration
AWSPollyTTSService Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
aws_access_key_id | str | None | AWS Access Key (defaults to env var). |
api_key | str | None | AWS Secret Key (defaults to env var). |
voice_id | str | "Joanna" | Polly voice ID (e.g., "Kajal"). |
params | InputParams | InputParams() | Engine and prosody settings. |
InputParams
| Parameter | Type | Default | Description |
|---|---|---|---|
engine | str | "neural" | TTS engine (standard or neural). |
rate | str | None | Speech rate adjustment. |
volume | str | None | Volume adjustment. |
Usage
Basic Setup
import os
from piopiy.services.aws.tts import AWSPollyTTSService
tts = AWSPollyTTSService(
voice_id="Joanna",
region="us-east-1"
)
Notes
- Neural Engine: The
neuralengine (default) produces much higher quality, more natural speech than thestandardengine. - Resampling: AWS Polly usually outputs at 16kHz for PCM; Piopiy handles any necessary resampling to match your application's sample rate.