wanted to implement a fallback for stt and tts fai...
# ask-ai
g
wanted to implement a fallback for stt and tts failures
t
Thanks for reaching out, ashutosh. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m responding to your request about implementing fallbacks for STT and TTS failures. Short answer: you can use built‑in fallback for STT and implement a small custom node for TTS fallback. Below are concise steps and examples. 1) STT fallback (built‑in) • Configure a primary model with a
fallback
array. The SDK will try the next model if the primary fails.
Copy code
import { inference } from '@livekit/agent-sdk';

const stt = new inference.STT({
  model: 'deepgram/nova-3',
  fallback: ['assemblyai/universal-streaming'],
});
2) TTS fallback (custom) • There’s no automatic
fallback
array for TTS. Override the TTS node to catch errors and call a secondary provider or return a pre-recorded clip.
Copy code
import { TTSNode } from '@livekit/agent-sdk';

class MyTTSNode extends TTSNode {
  async synthesize(text: string) {
    try {
      return await super.synthesize(text); // primary
    } catch (e) {
      console.warn('Primary TTS failed, falling back:', e);
      return await fallbackProvider.synthesize(text); // secondary
      // or: return await this.loadAudio('fallback.mp3');
    }
  }
}
3) UX and error handling recommendations • For STT low-confidence/empty results: prompt the user to repeat before passing input downstream. • For TTS failures: switch to a simpler provider or play a short pre-recorded message to avoid dead air. 4) Observability & testing • Use Agent Observability to track per-stage errors and configure retries. • Test by forcing failures (invalid key/network block) to verify fallback behavior. If you want, tell me: • which language/SDK you’re using (Node/Python/etc.), • which STT/TTS providers you plan to use, and I’ll give a tailored code sample and testing checklist. Sources: Sequential Pipeline Architecture for Voice Agents | LiveKit | Building Performant Voice Agents in India | LiveKit | Build Your First AI Voice Agent in Python: Complete Tutorial | LiveKit | Pipeline nodes and hooks | LiveKit Documentation, with interactive elements
g
but we are not using , inference
t
Thanks — I hear you’re not using the
inference
package. To give the right fallback guidance, could you share a few quick details about your current setup? • Which SDK/language are you using (Node, Python, other)? • How do you call STT/TTS today — direct HTTP calls, custom agent nodes, or a different library? • Which STT and TTS providers are you using (Deepgram, AssemblyAI, OpenAI, vendor X, or in‑house)? With that I’ll give a targeted pattern (code example and test checklist) for implementing reliable STT/TTS fallbacks in your exact setup. , with interactive elements
g
yess using Deepgram
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!
g
i am using deepgrams stt model