tts = ElevenLabsTTS()
ElevenLabs
ElevenLabs is a leading voice AI platform that offers advanced Text-to-Speech (TTS) capabilities with highly realistic and expressive voices.
It supports multiple languages and voices, making it ideal for real-time conversational agents, narrated content, accessibility tools, and voice-enabled applications.
The ElevenLabs plugin for the Stream Python AI SDK allows you to add the TTS functionality to your project.
Initialisation
The ElevenLabs plugin for Stream exists in the form of the ElevenLabsTTS
class:
Parameters
These are the parameters available in the ElevenLabsTTS plugin for you to customise:
Name | Type | Default | Description |
---|---|---|---|
api_key | str or None | None | Your ElevenLabs API key. If not provided, the plugin will look for the ELEVENLABS_API_KEY environment variable. |
voice_id | str | "VR6AewLTigWG4xSOukaG" | The ID of the voice to use for TTS. You can use any voice from your ElevenLabs account. |
model_id | str | "eleven_multilingual_v2" | The ID of the ElevenLabs TTS model to use. Controls the language and tone model for synthesis. |
Functionality
Set output track
The set_output_track()
method sets the audio output track for the synthesized speech.
tts.set_output_track(track)
Send text to convert to speech
The send()
method sends the text passed in for the service to synthesize.
The resulting audio is then played through the configured output track.
tts.send("Demo text you want AI voice to say")
Example
Check out our Elevenlabs example to see a practical implementation of the plugin and get inspiration for your own projects.