Skip to main content

AWS 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

ParameterTypeDefaultDescription
aws_access_key_idstrNoneAWS Access Key (defaults to env var).
api_keystrNoneAWS Secret Key (defaults to env var).
voice_idstr"Joanna"Polly voice ID (e.g., "Kajal").
paramsInputParamsInputParams()Engine and prosody settings.

InputParams

ParameterTypeDefaultDescription
enginestr"neural"TTS engine (standard or neural).
ratestrNoneSpeech rate adjustment.
volumestrNoneVolume 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 neural engine (default) produces much higher quality, more natural speech than the standard engine.
  • Resampling: AWS Polly usually outputs at 16kHz for PCM; Piopiy handles any necessary resampling to match your application's sample rate.