boundless-painting-47811
07/28/2025, 10:20 PMtall-airline-16756
07/28/2025, 10:20 PMtall-airline-16756
07/28/2025, 10:22 PMupdate_options() Method: Most TTS providers allow updating their configuration during runtime. For example, with ElevenLabs TTS, you can dynamically change the language: `if self.tts is not None:
self.tts.update_options(language="es") # Switch to Spanish`This method supports various options depending on the TTS provider, such as language, voice, speed, and more.
• Using Participant Attributes for Dynamic Voice Changes: You can listen to participant attribute changes and update the TTS configuration accordingly. For example: `@ctx.room.on("participant_attributes_changed")
def on_participant_attributes_changed(changed_attributes: dict[str, str], participant: rtc.Participant):
if "voice" in changed_attributes:
voice_id = participant.attributes.get("voice")
# Update TTS configuration based on the new voice ID`This is useful for user-initiated voice changes in interactive applications.
• Switching Between Different TTS Providers: You can create agents with different TTS configurations and switch between them dynamically. For example: class CartesiaAgent(Agent):
def __init__(self):
super().__init__(
tts=cartesia.TTS(voice="voice_id_here")
)
async def switch_to_elevenlabs(self):
return ElevenLabsAgent()
• Overriding TTS in Agent Constructor: You can override the TTS configuration when creating agents: class AssistantManager(Agent):
def __init__(self):
super().__init__(
tts=cartesia.TTS(voice="voice_id_here")
)
The most flexible approach is using the update_options() method, as it allows you to change TTS settings without recreating the entire agent or TTS instance. Let me know if you need further details on any of these methods.
Sources: livekit-plugins/livekit-plugins-hume/livekit/plugins/hume/tts.py | multi-agent/long_or_short_agent.py | agent/main.py | Workflows | LiveKit Docs