Skip to main content

No project description provided

Project description

ElevenLabs Python Library

LOGO

fern shield Discord Twitter PyPI - Python Version Downloads

The official Python API for ElevenLabs text-to-speech software. Eleven brings the most compelling, rich and lifelike voices to creators and developers in just a few lines of code.

📖 API & Docs

Check out the HTTP API documentation.

⚙️ Install

pip install elevenlabs

🗣️ Usage

Open in Spaces Open In Colab

Main Models

  1. Eleven Multilingual v2 (eleven_multilingual_v2)

    • Excels in stability, language diversity, and accent accuracy
    • Supports 29 languages
    • Recommended for most use cases
  2. Eleven Turbo v2.5 (eleven_turbo_v2_5)

    • High quality, lowest latency
    • Ideal for developer use cases where speed is crucial
    • Supports 32 languages

For more detailed information about these models and others, visit the ElevenLabs Models documentation.

from elevenlabs import play
from elevenlabs.client import ElevenLabs

client = ElevenLabs(
  api_key="YOUR_API_KEY", # Defaults to ELEVEN_API_KEY
)

audio = client.generate(
  text="Hello! 你好! Hola! नमस्ते! Bonjour! こんにちは! مرحبا! 안녕하세요! Ciao! Cześć! Привіт! வணக்கம்!",
  voice="Brian",
  model="eleven_multilingual_v2"
)
play(audio)
Play

🎧 Try it out! Want to hear our voices in action? Visit the ElevenLabs Voice Lab to experiment with different voices, languages, and settings.

🗣️ Voices

List all your available voices with voices().

from elevenlabs.client import ElevenLabs

client = ElevenLabs(
  api_key="YOUR_API_KEY", # Defaults to ELEVEN_API_KEY
)

response = client.voices.get_all()
audio = client.generate(text="Hello there!", voice=response.voices[0])
print(response.voices)

For information about the structure of the voices output, please refer to the official ElevenLabs API documentation for Get Voices.

Build a voice object with custom settings to personalize the voice style, or call client.voices.get_settings("your-voice-id") to get the default settings for the voice.

from elevenlabs import Voice, VoiceSettings, play
from elevenlabs.client import ElevenLabs

client = ElevenLabs(
  api_key="YOUR_API_KEY", # Defaults to ELEVEN_API_KEY
)

audio = client.generate(
    text="Hello! My name is Brian.",
    voice=Voice(
        voice_id='nPczCjzI2devNBz1zQrb',
        settings=VoiceSettings(stability=0.71, similarity_boost=0.5, style=0.0, use_speaker_boost=True)
    )
)

play(audio)

Clone Voice

Clone your voice in an instant. Note that voice cloning requires an API key, see below.

from elevenlabs.client import ElevenLabs
from elevenlabs import play

client = ElevenLabs(
  api_key="YOUR_API_KEY", # Defaults to ELEVEN_API_KEY
)

voice = client.clone(
    name="Alex",
    description="An old American male voice with a slight hoarseness in his throat. Perfect for news", # Optional
    files=["./sample_0.mp3", "./sample_1.mp3", "./sample_2.mp3"],
)

audio = client.generate(text="Hi! I'm a cloned voice!", voice=voice)

play(audio)

🚿 Streaming

Stream audio in real-time, as it's being generated.

from elevenlabs.client import ElevenLabs
from elevenlabs import stream

client = ElevenLabs(
  api_key="YOUR_API_KEY", # Defaults to ELEVEN_API_KEY
)

audio_stream = client.generate(
  text="This is a... streaming voice!!",
  stream=True
)

stream(audio_stream)

Note that generate is a helper function. If you'd like to access the raw method, simply use client.text_to_speech.convert_as_stream.

Input streaming

Stream text chunks into audio as it's being generated, with <1s latency. Note: if chunks don't end with space or punctuation (" ", ".", "?", "!"), the stream will wait for more text.

from elevenlabs.client import ElevenLabs
from elevenlabs import stream

client = ElevenLabs(
  api_key="YOUR_API_KEY", # Defaults to ELEVEN_API_KEY
)

def text_stream():
    yield "Hi there, I'm Eleven "
    yield "I'm a text to speech API "

audio_stream = client.generate(
    text=text_stream(),
    voice="Brian",
    model="eleven_multilingual_v2",
    stream=True
)

stream(audio_stream)

Note that generate is a helper function. If you'd like to access the raw method, simply use client.text_to_speech.convert_realtime.

Async Client

Use AsyncElevenLabs if you want to make API calls asynchronously.

import asyncio

from elevenlabs.client import AsyncElevenLabs

eleven = AsyncElevenLabs(
  api_key="MY_API_KEY" # Defaults to ELEVEN_API_KEY
)

async def print_models() -> None:
    models = await eleven.models.get_all()
    print(models)

asyncio.run(print_models())

Languages Supported

We support 32 languages and 100+ accents. Explore all languages.

Contributing

While we value open-source contributions to this SDK, this library is generated programmatically. Additions made directly to this library would have to be moved over to our generation code, otherwise they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!

On the other hand, contributions to the README are always very welcome!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

elevenlabs-1.12.1.tar.gz (76.0 kB view details)

Uploaded Source

Built Distribution

elevenlabs-1.12.1-py3-none-any.whl (150.5 kB view details)

Uploaded Python 3

File details

Details for the file elevenlabs-1.12.1.tar.gz.

File metadata

  • Download URL: elevenlabs-1.12.1.tar.gz
  • Upload date:
  • Size: 76.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.7.17 Linux/5.15.0-1073-azure

File hashes

Hashes for elevenlabs-1.12.1.tar.gz
Algorithm Hash digest
SHA256 7c03526b87e14e39e25fe84dbaaa84e0a4f467b6d3bf859503ce3e3a9125d07b
MD5 2f101b98daf2d3c3fbeb5f0a3f15c428
BLAKE2b-256 a73e580937a8b9b06fbf34e9f013796a0a1845aa0feb55ea109fb941ec7db11f

See more details on using hashes here.

File details

Details for the file elevenlabs-1.12.1-py3-none-any.whl.

File metadata

  • Download URL: elevenlabs-1.12.1-py3-none-any.whl
  • Upload date:
  • Size: 150.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.7.17 Linux/5.15.0-1073-azure

File hashes

Hashes for elevenlabs-1.12.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ea36fb437fd19cb7c37ed2bb690f18c2fe00b88b8619fdac882a9db9f8676aba
MD5 d751040a18ed7b31e19534165809815f
BLAKE2b-256 6115de3dc7963b63408231b9b05454e8b894a6eedfe2a6c5970307f1f3d1e27b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page