What is the recommended way to switch TTS of an ag...
# agents
m
What is the recommended way to switch TTS of an agent during runtime? I tried directly setting
self._tts
. It kinda works. But TTS metrics are no longer emitted. Unfortunately I can't find a way to decide the TTS before instantiating the
Agent()
. For context, I am building a telephony AI agent. I need to make an API call with the agent's phone number to get the TTS to use. I cannot get the agent phone number from
room.local_participant
before connecting to the room. I need to instantiate the
Agent()
to connect to the room using
session.start()
. Kinda a chicken & egg problem. Hence I am looking for ways to change TTS plugin of the instanciated Agent during runtime.
p
What if you create multiple agents, each one of them with their own tts setting. Then, you place a starting agent to get the phone number and transition to the agent mapped to the phone number. Would that solve your problem?
I mean, one agent decides which tts to use, and transition to a new agent with the tts you mapped from the phone number.
m
Interesting idea. I thought the only way to update the agent is through handing off from a tool call. But I just noticied in the session.update_agent(). Does updating the agent affect the agent participant identity? Or is it constant for a given session?
p
It does not affect it. But you can if you want, before transitioning
m
I started the session with a empty Agent, got the agent phone number, got the TTS to use and used
update_agent()
to set the correct agent. Thanks @proud-lawyer-39815 for the idea!
👍 1