what's the best way to test tts failures
# ask-ai
r
what's the best way to test tts failures
t
Thanks for reaching out, John. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To test TTS (text-to-speech) failures in LiveKit, use the following recommended methods: • Simulate errors with `FakeTTS`: Use the
FakeTTS
class to trigger specific failure scenarios, such as timeouts, exceptions, or no audio generation. For example:
Copy code
fake_tts = FakeTTS(fake_timeout=0.5)  # Simulate timeout
fake_tts = FakeTTS(fake_exception=RuntimeError("test error"))  # Simulate exception
fake_tts = FakeTTS(fake_audio_duration=0.0)  # Simulate no audio
• Test network failures with Toxiproxy: Use Toxiproxy to simulate network-level issues like timeouts or dropped connections.
Copy code
p = toxiproxy.create(proxy_upstream, proxy_name, listen=PROXY_LISTEN, enabled=True)
p.add_toxic(type="timeout", attributes={"timeout": 0})
• Verify error propagation and fallback: Write tests to ensure errors are correctly raised and fallback adapters are triggered when the primary TTS service fails. • Test retry and recovery: Configure retry logic and verify that the system retries on failure and recovers when the TTS service becomes available again. • JavaScript/TypeScript support: Use the
@livekit/agents-plugins-test
package for similar TTS failure testing in JS/TS projects. These approaches allow you to comprehensively test TTS failure handling, fallback, and recovery in your LiveKit applications. Sources: livekit-agents/livekit/agents/tts/tts.py | plugins/resemble/src/tts.test.ts
r
what is FakeTTS
t
Hey there! Let me introduce you to FakeTTS - a super handy mock TTS interface that's perfect for testing. Think of it like a friendly testing buddy that helps you simulate Text-to-Speech behavior without any complicated setup. The cool thing is, you can totally customize FakeTTS to match exactly what you need. Want to play around with different scenarios? No problem! You can: • Create custom audio duration simulations • Test how your system handles network timeouts • Experiment with raising specific exceptions or errors • Set up predefined responses for different input texts It's like having a testing playground where you can safely explore all kinds of TTS scenarios. FakeTTS generates silent audio data, so you can focus on testing your workflow without getting distracted by actual speech generation. Fun fact: This tool is a go-to in LiveKit's test suite for checking out all those tricky TTS functionalities and error scenarios. Pretty neat, right? Sources: tests/test_agent_session.py