/** * AWS Polly server-side TTS provider * @module @pie-players/tts-server-polly */ import { BaseTTSProvider, type GetVoicesOptions, type ServerProviderCapabilities, type SynthesizeRequest, type SynthesizeResponse, type TTSServerConfig, type Voice } from "@pie-players/tts-server-core"; /** * AWS Polly provider configuration. * * This extends the base TTSServerConfig with Polly-specific settings. * All fields marked with @extension are AWS-specific and not portable. */ export interface PollyProviderConfig extends TTSServerConfig { /** * AWS region (e.g., 'us-east-1', 'us-west-2', 'eu-west-1') * * @extension AWS-specific (region concept) * @required */ region: string; /** * AWS credentials for API authentication * * @extension AWS-specific * @note In production, prefer IAM roles over hardcoded credentials * @see https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/setting-credentials.html */ credentials?: { accessKeyId: string; secretAccessKey: string; sessionToken?: string; }; /** * Polly engine type: 'neural' (higher quality) or 'standard' (lower cost) * * @extension AWS Polly-specific * @default 'neural' * @note Neural: $16/1M chars, Standard: $4/1M chars */ engine?: "neural" | "standard"; /** * Default voice ID if not specified in synthesis requests * * @standard Voice selection is standard, but voice names are provider-specific * @default 'Joanna' * @see https://docs.aws.amazon.com/polly/latest/dg/voicelist.html */ defaultVoice?: string; } export declare class PollyServerProvider extends BaseTTSProvider { readonly providerId = "aws-polly"; readonly providerName = "AWS Polly"; readonly version = "1.0.0"; private client; private engine; private defaultVoice; private resolveOutputFormat; private resolveSpeechMarkTypes; /** * Initialize the AWS Polly provider. * * This is FAST and lightweight - only validates config and creates the Polly client. * Does NOT fetch voices or make test API calls. * * @param config - Polly configuration with region and credentials * @performance Completes in ~10-50ms */ initialize(config: PollyProviderConfig): Promise; /** * Synthesize speech with AWS Polly */ synthesize(request: SynthesizeRequest): Promise; /** * Synthesize audio stream */ private synthesizeAudio; /** * Synthesize speech marks */ private synthesizeSpeechMarks; /** * Get available voices from AWS Polly */ getVoices(options?: GetVoicesOptions): Promise; /** * Get AWS Polly capabilities. * * Clearly documents what features are W3C-standard vs AWS-specific. */ getCapabilities(): ServerProviderCapabilities; /** * Map an AWS SDK error to a TTSError, matching the granularity * GoogleCloudTTSProvider gives its own vendor errors: a bare * `PROVIDER_ERROR` for everything hides cases callers (Host A maps * `RATE_LIMIT_EXCEEDED` / `AUTHENTICATION_ERROR` / `INVALID_REQUEST` / * `TEXT_TOO_LONG` onto HTTP status codes) already know how to handle. */ private mapPollyErrorToTTSError; /** * Clean up AWS Polly client */ destroy(): Promise; }