When using a fallback adapter on the session, tts_...
# ask-ai
g
When using a fallback adapter on the session, tts_node is not recognized on the agent level
t
The issue where tts_node is not recognized at the agent level when using a FallbackAdapter at the session level usually means that the agent’s activity context doesn’t have a valid TTS instance bound yet. This often happens due to the FallbackAdapter not being properly initialized or configured. Don’t worry, I’ve put together a clear step-by-step guide to help you diagnose and resolve this: 1. Verify FallbackAdapter Initialization First, please double-check that your FallbackAdapter is correctly created with valid TTS instances. It needs at least one TTS instance, and all instances should have the same number of channels. Here’s an example:
Copy code
from livekit.agents import tts
from livekit.plugins import elevenlabs, groq

tts_fallback = tts.FallbackAdapter([
    elevenlabs.TTS(),
    groq.TTS()
], sample_rate=24000)
2. Ensure Agent Receives TTS from Session Make sure the agent inherits the session’s TTS instance during session.start(). It’s best to avoid overriding the TTS in the agent’s constructor unless it’s really necessary. 3. Check Activity Context Setup Remember that tts_node accesses self._activity.tts, which only gets set after the agent is launched via session.start(). So, please ensure tts_node isn’t called too early. 4. Enable Logging for Fallback Transitions To get more insight, enable debug logging to watch fallback transitions and see if all TTS providers are failing:
Copy code
import logging
logging.basicConfig(level=logging.INFO)
5. Test with Minimal Configuration Try testing with a simple agent that doesn’t override tts_node to help isolate the issue:
Copy code
class TestAgent(Agent):
    pass

session = AgentSession(tts=tts.FallbackAdapter([elevenlabs.TTS(), groq.TTS()]))
await session.start(agent=TestAgent(), room=ctx.room)
If you still run into issues, it’s a good idea to verify each TTS provider individually to make sure they work fine on their own before combining them in the fallback chain. I hope this helps you move forward smoothly! If you have any questions or need further assistance, feel free to reach out—I’m here to help. Sources: examples/voice_agents/structured_output.py | Events and error handling | LiveKit docs | Pipeline nodes and hooks | LiveKit docs | Agents v0.x migration guide - Python | LiveKit docs