Skip to main content

ElevenLabs TTS

The ElevenLabs TTS provider enables your agent to use ElevenLabs' high-quality text-to-speech models for generating natural, expressive voice output with advanced voice cloning capabilities.

Installation​

Install the ElevenLabs-enabled VideoSDK Agents package:

pip install "videosdk-plugins-elevenlabs"

Importing​

from videosdk.plugins.elevenlabs import ElevenLabsTTS, VoiceSettings

Example Usage​

from videosdk.plugins.elevenlabs import ElevenLabsTTS, VoiceSettings
from videosdk.agents import CascadingPipeline

# Configure voice settings
voice_settings = VoiceSettings(
stability=0.71,
similarity_boost=0.5,
style=0.0,
use_speaker_boost=True
)

# Initialize the ElevenLabs TTS model
tts = ElevenLabsTTS(
# When ELEVENLABS_API_KEY is set in .env - DON'T pass api_key parameter
api_key="your-elevenlabs-api-key",
model="eleven_flash_v2_5",
voice="your-voice-id",
speed=1.0,
response_format="pcm_24000",
voice_settings=voice_settings,
enable_streaming=True
)

# Add tts to cascading pipeline
pipeline = CascadingPipeline(tts=tts)
note

When using .env file for credentials, don't pass them as arguments to model instances or context objects. The SDK automatically reads environment variables, so omit api_key, videosdk_auth, and other credential parameters from your code.

Configuration Options​

  • model: The ElevenLabs model to use (e.g., "eleven_flash_v2_5", "eleven_multilingual_v2")
  • voice: (str) Voice ID to use for audio output (get from ElevenLabs dashboard)
  • speed: (float) Speed of the generated audio (default: 1.0)
  • api_key: Your ElevenLabs API key (can also be set via environment variable)
  • response_format: (str) Audio format for output (default: "pcm_24000")
  • voice_settings: (VoiceSettings) Advanced voice configuration options:
    • stability: (float) Voice stability (0.0 to 1.0, default: 0.71)
    • similarity_boost: (float) Voice similarity enhancement (0.0 to 1.0, default: 0.5)
    • style: (float) Voice style exaggeration (0.0 to 1.0, default: 0.0)
    • use_speaker_boost: (bool) Enable speaker boost for clarity (default: True)
  • base_url: (str) Custom base URL for ElevenLabs API (optional)
  • enable_streaming: (bool) Enable real-time audio streaming (default: False)

Got a Question? Ask us on discord