jolly-apartment-95291
07/24/2025, 4:09 AMtall-airline-16756
07/24/2025, 4:09 AMtall-airline-16756
07/24/2025, 4:10 AMupdate_options method. For example, with Cartesia TTS:
tts.update_options(
model="sonic-2",
language="en",
voice="new_voice_id",
speed=1.2,
emotion=["happy"]
)
Other providers like Google TTS and Neuphonic offer similar functionality for updating voice settings, speaking rate, and other parameters during runtime.
2. Switching Between Different TTS Providers
If you need to switch between completely different TTS providers (e.g., from OpenAI to Cartesia), you can implement this using function tools that return new Agent instances. Here's an example:
class RimeAgent(Agent):
def __init__(self):
super().__init__(
tts=rime.TTS(sample_rate=44100, model="mistv2", speaker="abbie"),
# other configurations...
)
@function_tool
async def switch_to_cartesia(self):
"""Switch to Cartesia TTS voice"""
return CartesiaAgent()
class CartesiaAgent(Agent):
def __init__(self):
super().__init__(
tts=cartesia.TTS(
sample_rate=44100,
model="sonic-preview",
voice="87bc56aa-ab01-4baa-9071-77d497064686"
),
# other configurations...
)
Each agent class uses a different TTS provider, and you can switch providers by returning new agent instances. When a switch occurs, the on_enter method is called to announce the change to the user.
This approach allows for complete flexibility, enabling you to change not just voice characteristics but the entire TTS engine and its capabilities.
Sources: livekit-plugins/livekit-plugins-playai/livekit/plugins/playai/tts.py | pipeline-tts/tts_comparison.py