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 SDK for ElevenLabs. ElevenLabs 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

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 Flash v2.5 (eleven_flash_v2_5)

    • Ultra-low latency
    • Supports 32 languages
    • Faster model, 50% lower price per character
  3. Eleven Turbo v2.5 (eleven_turbo_v2_5)

    • Good balance of quality and 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 dotenv import load_dotenv
from elevenlabs.client import ElevenLabs
from elevenlabs import play

load_dotenv()

client = ElevenLabs()

audio = client.text_to_speech.convert(
    text="The first move is what sets everything in motion.",
    voice_id="JBFqnCBsd6RMkjVDRZzb",
    model_id="eleven_multilingual_v2",
    output_format="mp3_44100_128",
)

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",
)

response = client.voices.search()
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.

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",
)

voice = client.voices.ivc.create(
    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"],
)

Streaming

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

from elevenlabs import stream
from elevenlabs.client import ElevenLabs

client = ElevenLabs()

audio_stream = client.text_to_speech.stream(
    text="This is a test",
    voice_id="JBFqnCBsd6RMkjVDRZzb",
    model_id="eleven_multilingual_v2"
)

# option 1: play the streamed audio locally
stream(audio_stream)

# option 2: process the audio bytes manually
for chunk in audio_stream:
    if isinstance(chunk, bytes):
        print(chunk)

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"
)

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

asyncio.run(print_models())

Languages Supported

Explore all models & 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


Release history Release notifications | RSS feed

This version

2.7.1

Download files

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

Source Distribution

elevenlabs-2.7.1.tar.gz (267.8 kB view details)

Uploaded Source

Built Distribution

elevenlabs-2.7.1-py3-none-any.whl (760.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: elevenlabs-2.7.1.tar.gz
  • Upload date:
  • Size: 267.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.8.18 Linux/6.11.0-1015-azure

File hashes

Hashes for elevenlabs-2.7.1.tar.gz
Algorithm Hash digest
SHA256 7136cd3e8056fe123ea8736b876aff8023c430aad7fd2c9405cbca60eb675504
MD5 8f40fc0e3814176a6748b1536af48ff7
BLAKE2b-256 0b74e800044ceb5186946718c934202b426b57d4f42d81c13e17156ed4e79dcc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: elevenlabs-2.7.1-py3-none-any.whl
  • Upload date:
  • Size: 760.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.8.18 Linux/6.11.0-1015-azure

File hashes

Hashes for elevenlabs-2.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 076f61f0945c721aa3fa2a63f26029515e8e2464bc64f247b56ae1042a25737a
MD5 6508fd12c8d1e08b6d6220cd1745212e
BLAKE2b-256 1210980751c753d9b7a72b4bb1c06cba8c55d4c2bb9b394c23f48869017c9eb1

See more details on using hashes here.

Supported by

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