AzureTTSConfig
Configuration for the AzureTTS provider.
Defined in: src/providers/tts/azure/AzureTTS.ts:109
Configuration for the AzureTTS provider.
Remarks
Provide either apiKey (for direct API access) or proxyUrl (for a server-side proxy). At least one must be set. If both are provided, proxyUrl takes precedence and the key is not sent from the client.
In direct mode, region is required (it selects the https://<region>.tts.speech.microsoft.com endpoint) unless a custom endpoint is configured. In proxy mode the region lives server-side in the proxy configuration (azureSpeechRegion).
Authentication in direct mode defaults to the Ocp-Apim-Subscription-Key header with your Speech resource key. To use a short-lived bearer token instead (recommended for browsers), pass an async apiKey factory that fetches a token from your server (which calls Azure’s POST https://<region>.api.cognitive.microsoft.com/sts/v1.0/issueToken) — factories are sent as Authorization: Bearer automatically. Set authType explicitly to override either default.
Example
// Direct API access with a resource key
const config: AzureTTSConfig = {
apiKey: 'your-speech-resource-key',
region: 'eastus',
voiceName: 'en-US-AriaNeural',
outputFormat: 'audio-24khz-48kbitrate-mono-mp3',
};
// Via proxy server (recommended for production)
const proxyConfig: AzureTTSConfig = {
proxyUrl: 'http://localhost:3001/api/proxy/azure-tts',
voiceName: 'en-US-AriaNeural',
};
See
AzureTTSOutputFormat - Available audio format options.
Extends
Properties
| Property | Type | Default value | Description | Overrides | Inherited from | Defined in |
|---|---|---|---|---|---|---|
apiKey? | string | () => Promise<string> | undefined | API 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.apiKey | src/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.authType | src/core/types/providers.ts:115 |
debug? | boolean | false | Whether 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.debug | src/core/types/providers.ts:126 |
endpoint? | string | undefined | Custom endpoint URL to override the provider’s default API endpoint. Remarks Useful for self-hosted instances, proxy servers, or development environments. | - | TTSProviderConfig.endpoint | src/core/types/providers.ts:79 |
language? | string | undefined | Language for the SSML xml:lang attribute (BCP 47, e.g. 'en-US'). Remarks When omitted, the locale is derived from voiceName (the first two segments, e.g. en-US-AriaNeural -> en-US). | - | - | src/providers/tts/azure/AzureTTS.ts:144 |
maxRetries? | number | 3 | Maximum number of retries for failed API requests. | - | - | src/providers/tts/azure/AzureTTS.ts:192 |
model? | string | undefined | Model to use for text-to-speech synthesis. Remarks Provider-specific model identifier (e.g., 'aura-2' for Deepgram). | - | TTSProviderConfig.model | src/core/types/providers.ts:1165 |
outputFormat? | AzureTTSOutputFormat | 'audio-24khz-48kbitrate-mono-mp3' | The audio output format sent via the X-Microsoft-OutputFormat header. See AzureTTSOutputFormat | TTSProviderConfig.outputFormat | - | src/providers/tts/azure/AzureTTS.ts:135 |
pitch? | number | undefined | Pitch adjustment in semitones applied via <prosody pitch>. Remarks 2 renders as +2st, -3 as -3st. | TTSProviderConfig.pitch | - | src/providers/tts/azure/AzureTTS.ts:175 |
proxyUrl? | string | undefined | URL 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.proxyUrl | src/core/types/providers.ts:97 |
rate? | number | undefined | Speech rate multiplier applied via <prosody rate>. Remarks 1.0 is normal speed; 1.5 renders as +50.00%, 0.8 as -20.00%. | TTSProviderConfig.rate | - | src/providers/tts/azure/AzureTTS.ts:167 |
region? | string | undefined | Azure region of your Speech resource (e.g. 'eastus', 'westeurope'). Remarks Required in direct mode (ignored when proxyUrl or endpoint is set). Selects the https://<region>.tts.speech.microsoft.com endpoint. | - | - | src/providers/tts/azure/AzureTTS.ts:127 |
sampleRate? | number | undefined | Sample rate for the output audio in Hz. Remarks Common values are 16000, 24000, and 48000. Must match the format capabilities of the chosen voice and model. | - | TTSProviderConfig.sampleRate | src/core/types/providers.ts:1199 |
style? | string | undefined | Speaking style applied via <mstts:express-as> (e.g. 'cheerful'). Remarks Only some neural voices support styles — check the voice’s StyleList in the voices-list response. | - | - | src/providers/tts/azure/AzureTTS.ts:153 |
styleDegree? | number | undefined | Intensity of the speaking style, from 0.01 to 2 (default 1). Only used when style is set. | - | - | src/providers/tts/azure/AzureTTS.ts:159 |
timeout? | number | undefined | Request timeout in milliseconds. Remarks Applies to HTTP requests (REST providers) and connection establishment (WebSocket providers). Set to 0 for no timeout. | - | TTSProviderConfig.timeout | src/core/types/providers.ts:135 |
userAgent? | string | undefined | Value for the User-Agent request header (application name). Remarks The Azure REST docs list this header as required; browsers set their own User-Agent automatically (and ignore this option), so it only takes effect in server-side runtimes. | - | - | src/providers/tts/azure/AzureTTS.ts:185 |
voice? | string | undefined | Voice 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.voice | src/core/types/providers.ts:1157 |
voiceName | string | undefined | The neural voice to use for synthesis (e.g. 'en-US-AriaNeural'). Remarks Required. List available voices via Azure’s GET /tts/cognitiveservices/voices/list endpoint or the “Language and voice support” documentation. | - | - | src/providers/tts/azure/AzureTTS.ts:118 |