Skip to content

PollyTTSConfig

Configuration for the PollyTTS provider.

Defined in: src/providers/tts/polly/PollyTTS.ts:98

Configuration for the PollyTTS provider.

Remarks

Provide either credentials + region (for direct AWS access) or proxyUrl (for a server-side proxy that SigV4-signs upstream requests). At least one must be set. If both are provided, proxyUrl takes precedence and no credentials are used client-side.

For browsers, prefer proxyUrl, or pass an async credentials factory that fetches temporary credentials (STS/Cognito) from your backend — never embed long-lived AWS keys in client code.

Example

// Server-side with static credentials
const config: PollyTTSConfig = {
  credentials: {
    accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
    secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
  },
  region: 'us-east-1',
  voiceId: 'Joanna',
  engine: 'neural',
};

// Browser with temporary credentials from your backend
const browserConfig: PollyTTSConfig = {
  credentials: async () => (await fetch('/api/aws-credentials')).json(),
  region: 'us-east-1',
  voiceId: 'Joanna',
};

// Via proxy server (recommended for production browsers)
const proxyConfig: PollyTTSConfig = {
  proxyUrl: 'http://localhost:3001/api/proxy/polly',
  voiceId: 'Joanna',
};

See

Extends

Properties

PropertyTypeDefault valueDescriptionOverridesInherited fromDefined in
apiKey?string | () => Promise<string>undefinedAPI key or authentication token for the provider. Remarks Can be a static string or an async factory function that returns a fresh token on each call. Use a factory for short-lived tokens (e.g. Deepgram JWTs) so each WebSocket connection gets a valid credential. For client-side usage, consider using a proxy server to keep API keys secure. The SDK provides Express, Next.js, and Node adapters for this purpose.-TTSProviderConfig.apiKeysrc/core/types/providers.ts:71
authType?"token" | "bearer"Provider-specific (typically 'token' for Deepgram, ignored for REST providers)Authentication type for providers that support multiple auth mechanisms. Remarks Controls how the apiKey is sent to the provider: - 'token' — WebSocket subprotocol ['token', apiKey] or header Authorization: Token <key>. This is the default for Deepgram providers. - 'bearer' — WebSocket subprotocol ['bearer', token] or header Authorization: Bearer <token>. Use this for OAuth tokens or providers that expect Bearer auth. REST/SDK providers (Anthropic, OpenAI) handle auth through their SDK constructors and ignore this field.-TTSProviderConfig.authTypesrc/core/types/providers.ts:115
credentials?AwsCredentialsProviderundefinedAWS credentials, static or as an async factory. Remarks Required in direct mode (no proxyUrl). Pass a factory to fetch fresh temporary credentials (STS/Cognito) on each request — the browser-safe pattern, mirroring the SDK’s async apiKey factories.--src/providers/tts/polly/PollyTTS.ts:107
debug?booleanfalseWhether to enable debug logging for this provider. Remarks When true, the provider emits detailed internal logs. This is separate from the SDK-level LoggingConfig.-TTSProviderConfig.debugsrc/core/types/providers.ts:126
endpoint?stringundefinedCustom endpoint URL to override the provider’s default API endpoint. Remarks Useful for self-hosted instances, proxy servers, or development environments.-TTSProviderConfig.endpointsrc/core/types/providers.ts:79
engine?PollyEngine'neural'The synthesis engine. See PollyEngine--src/providers/tts/polly/PollyTTS.ts:132
languageCode?stringundefinedOptional language code for bilingual voices (e.g. 'en-IN' vs 'hi-IN' for Aditi). Most voices don’t need this.--src/providers/tts/polly/PollyTTS.ts:164
lexiconNames?string[]undefinedPronunciation lexicon names (max 5) to apply during synthesis. See PutLexicon--src/providers/tts/polly/PollyTTS.ts:171
maxRetries?number3Maximum number of retries for failed API requests.--src/providers/tts/polly/PollyTTS.ts:178
model?stringundefinedModel to use for text-to-speech synthesis. Remarks Provider-specific model identifier (e.g., 'aura-2' for Deepgram).-TTSProviderConfig.modelsrc/core/types/providers.ts:1165
outputFormat?PollyOutputFormat'mp3'The audio output format. See PollyOutputFormatTTSProviderConfig.outputFormat-src/providers/tts/polly/PollyTTS.ts:140
pitch?numberundefinedPitch adjustment in semitones. Remarks Values from -20 to +20 semitones. Not all providers support pitch adjustment.-TTSProviderConfig.pitchsrc/core/types/providers.ts:1182
proxyUrl?stringundefinedURL of a CompositeVoice proxy server endpoint for this provider. Remarks When set, requests are routed through the proxy which injects the real API key server-side. This keeps API keys out of the browser. For WebSocket providers the HTTP URL is automatically converted to ws(s)://. At least one of apiKey or proxyUrl must be set for providers that require authentication (all except NativeSTT, NativeTTS, and WebLLM). Example proxyUrl: 'http://localhost:3000/api/proxy/deepgram'-TTSProviderConfig.proxyUrlsrc/core/types/providers.ts:97
rate?numberundefinedSpeech rate multiplier. Remarks Values from 0.25 (quarter speed) to 4.0 (quadruple speed), where 1.0 is normal speed. Not all providers support rate adjustment.-TTSProviderConfig.ratesrc/core/types/providers.ts:1174
region?stringundefinedAWS region hosting the Polly endpoint (e.g. 'us-east-1'). Remarks Required in direct mode; ignored in proxy mode (the proxy holds the region).--src/providers/tts/polly/PollyTTS.ts:115
sampleRate?numberundefinedAudio sample rate in Hz. Remarks Valid values depend on outputFormat: 8000–48000 for mp3 / ogg_vorbis, 8000 or 16000 for pcm, 48000 for ogg_opus. When omitted, Polly uses its engine-specific default (24000 for neural/generative/long-form, 22050 for standard).TTSProviderConfig.sampleRate-src/providers/tts/polly/PollyTTS.ts:151
textType?"text" | "ssml"'text'Whether the input is plain text or SSML.--src/providers/tts/polly/PollyTTS.ts:158
timeout?numberundefinedRequest timeout in milliseconds. Remarks Applies to HTTP requests (REST providers) and connection establishment (WebSocket providers). Set to 0 for no timeout.-TTSProviderConfig.timeoutsrc/core/types/providers.ts:135
voice?stringundefinedVoice ID or name to use for synthesis. Remarks Provider-specific voice identifier. For example, Deepgram uses identifiers like 'aura-asteria-en', while ElevenLabs uses voice IDs.-TTSProviderConfig.voicesrc/core/types/providers.ts:1157
voiceIdstringundefinedVoice ID to use for synthesis (e.g. 'Joanna', 'Matthew', 'Amy'). Remarks Required. List available voices with Polly’s DescribeVoices API, and check which engines each voice supports.--src/providers/tts/polly/PollyTTS.ts:124

© 2026 CompositeVoice. All rights reserved.

Font size
Contrast
Motion
Transparency