Creates a new FallbackTTSProxy wrapping the given provider chain.
Ordered list of TTS providers to try.
EventEmitter on which provider_fallback events are published.
const proxy = new FallbackTTSProxy(
[elevenlabsProvider, openaiTtsProvider],
resolver,
);
Attempt synthesis using each provider in the chain in order.
Emits a provider_fallback event (typed as ProviderFallbackEvent)
whenever a non-final provider throws. Re-throws the last provider's error
when the entire chain is exhausted.
The text to synthesize into speech.
Optional options: SpeechSynthesisOptionsOptional synthesis settings (voice, speed, format, etc.).
The synthesis result from the first provider that succeeds.
'No providers in fallback chain' when the chain is empty.
The last provider's error when all providers in the chain fail.
const result = await proxy.synthesize('Hello world', { voice: 'nova' });
Returns the voice list from the first provider in the chain that supports
listAvailableVoices().
Iterates through the chain looking for any provider that implements this optional method. Returns an empty array when no provider supports voice listing. This is a best-effort approach — if the primary provider fails during synthesis and a fallback provider handles it, the returned voice list may not match the provider that actually produced the audio.
A promise resolving to an array of available voices, or an empty array if no provider in the chain supports voice listing.
const voices = await proxy.listAvailableVoices();
// voices from the first provider that implements the method
Readonly idUnique identifier derived from the first provider in the chain.
Falls back to 'fallback-tts' for empty chains.
Readonly displayHuman-readable name showing the full chain for debugging and logging.
Format: "Fallback TTS (provider1 -> provider2 -> ...)".
Readonly supportsWhether the proxy supports streaming. Only reflects the first provider's
capability — see FallbackSTTProxy.supportsStreaming for rationale.
A TextToSpeechProvider that wraps an ordered chain of TTS providers and implements automatic failover.
Retry Chain Logic
Identical to FallbackSTTProxy: providers are tried left-to-right, the first successful synthesis result is returned, and
provider_fallbackevents are emitted on each intermediate failure.Voice Listing
Voice listing is delegated to the first provider in the chain that exposes a
listAvailableVoices()method. If no provider supports this, an empty array is returned. This is a best-effort approach — the voice list may not reflect the provider that actually handles synthesis if the primary fails.See
ProviderFallbackEvent for the event payload shape See
SpeechProviderResolver.resolveTTS()for how this proxy is created.Example