broad-lamp-30178
09/09/2025, 4:45 PMtall-airline-16756
09/09/2025, 4:45 PMtall-airline-16756
09/09/2025, 4:46 PMpip install "livekit-agents[elevenlabs]~=1.2"
Alternatively, if you prefer, you can install it directly from PyPI with:
pip install livekit-plugins-elevenlabs
2. Authentication:
Next, you’ll need to get your ElevenLabs API key. You can grab it from ElevenLabs API settings. Once you have it, set it as an environment variable like this:
ELEVEN_API_KEY=<your-api-key>
To make things easier, you might want to save it in a .env file.
3. Integration:
Now, you can use ElevenLabs TTS inside an AgentSession in your LiveKit app. Here’s a quick example to get you started:
from livekit.plugins import elevenlabs
session = AgentSession(
tts=elevenlabs.TTS(
voice_id="ODq5zmih8GrVes37Dizd",
model="eleven_multilingual_v2"
)
# ... other parameters such as llm, stt, etc.
)
4. Example Implementation:
To give you a clearer picture, here’s a basic example of connecting to a room and using ElevenLabs TTS to say a phrase:
async def entrypoint(job: JobContext):
tts_11labs = elevenlabs.TTS(voice_id="ODq5zmih8GrVes37Dizd", model="eleven_multilingual_v2")
source = rtc.AudioSource(tts_11labs.sample_rate, tts_11labs.num_channels)
track = rtc.LocalAudioTrack.create_audio_track("agent-mic", source)
options = rtc.TrackPublishOptions()
options.source = rtc.TrackSource.SOURCE_MICROPHONE
await job.connect()
publication = await job.room.local_participant.publish_track(track, options)
await publication.wait_for_subscription()
logger.info('Saying "Bonjour, comment allez-vous?"')
async for output in tts_11labs.synthesize("Bonjour, comment allez-vous?"):
await source.capture_frame(output.frame)
If you’d like to explore more, including advanced setup options, be sure to check out the ElevenLabs TTS integration guide. And please don’t hesitate to reach out if you have any questions or need a hand—I’m here to help!
Sources: ElevenLabs TTS integration guide | LiveKit Docs | livekit-plugins/livekit-plugins-elevenlabs/livekit/plugins/elevenlabs/__ini... | Working with plugins | LiveKit Docs