iam using eleven labs for tts for agent and i impl...
# ask-ai
n
iam using eleven labs for tts for agent and i implemntred the Handing off control to another agent and added anther agent named sakr can i make the ather agend voice id deffrent form man agent
t
Thanks for reaching out, Mohamed. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Yes, you can assign a different voice ID for another agent in the Eleven Labs TTS integration. When creating a TTS instance, you can specify a unique voice ID for each agent. Here are two ways to do this: 1. Using the
voice_id
parameter:
Copy code
tts = elevenlabs.TTS(
    voice_id="ODq5zmih8GrVes37Dizd",
    model="eleven_multilingual_v2"
)
2. Using the
voice
parameter with a Voice object:
Copy code
eleven_tts = elevenlabs.tts.TTS(
    model="eleven_turbo_v2_5",
    voice=elevenlabs.tts.Voice(
        id="EXAVITQu4vr4xnSDxMaL",
        name="Bella",
        category="premade",
        settings=elevenlabs.tts.VoiceSettings(
            stability=0.71,
            similarity_boost=0.5,
            style=0.0,
            use_speaker_boost=True
        ),
    ),
    language="en"
)
You can also retrieve a list of available voices using
await tts_11labs.list_voices()
to help you select the appropriate voice for each agent. Sources: ElevenLabs integration guide | LiveKit Docs | Tree View: | dse-workbench | ElevenLabs TTS integration guide | LiveKit Docs
n
i want to change the voice in the middle of the call when Handing off control to another agent
t
To change the voice dynamically during a call when handing off control to another agent, you can configure each agent with its own Eleven Labs TTS instance and specific voice settings. When the handoff occurs, the new agent's TTS configuration will take over, using the assigned voice for subsequent speech synthesis. Here’s an example implementation:
Copy code
from livekit.agents import Agent
from livekit.plugins import elevenlabs

class AgentWithVoice1(Agent):
    def __init__(self):
        super().__init__(instructions="You are an agent with voice 1.")
        # Initialize with first voice
        self.tts = elevenlabs.TTS(
            voice_id="VOICE_ID_1", 
            model="eleven_multilingual_v2"
        )

class AgentWithVoice2(Agent):
    def __init__(self):
        super().__init__(instructions="You are an agent with voice 2.")
        # Initialize with second voice
        self.tts = elevenlabs.TTS(
            voice_id="ODq5zmih8GrVes37Dizd",  # Example voice ID
            model="eleven_multilingual_v2"
        )
To implement the handoff:
Copy code
@function_tool()
async def handoff_to_agent2(self):
    """Use this tool to hand off to agent with voice 2."""
    # Return the new agent, which will use a different voice
    return AgentWithVoice2()
When the handoff occurs, the new agent's voice settings will be applied automatically. Let me know if you need further assistance! Sources: Tree View: | dse-workbench | Workflows | LiveKit Docs