elevenlabs


Nameelevenlabs JSON
Version 1.12.1 PyPI version JSON
download
home_pageNone
SummaryNone
upload_time2024-10-30 17:37:42
maintainerNone
docs_urlNone
authorNone
requires_python<4.0,>=3.8
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ElevenLabs Python Library

![LOGO](https://github.com/elevenlabs/elevenlabs-python/assets/12028621/21267d89-5e82-4e7e-9c81-caf30b237683)

[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-SDK%20generated%20by%20Fern-brightgreen)](https://buildwithfern.com/?utm_source=fern-elevenlabs/elevenlabs-python/readme)
[![Discord](https://badgen.net/badge/black/ElevenLabs/icon?icon=discord&label)](https://discord.gg/elevenlabs)
[![Twitter](https://badgen.net/badge/black/elevenlabsio/icon?icon=twitter&label)](https://twitter.com/elevenlabsio)
[![PyPI - Python Version](https://img.shields.io/pypi/v/elevenlabs?style=flat&colorA=black&colorB=black)](https://pypi.org/project/elevenlabs/)
[![Downloads](https://static.pepy.tech/personalized-badge/elevenlabs?period=total&units=international_system&left_color=black&right_color=black&left_text=Downloads)](https://pepy.tech/project/elevenlabs)

The official Python API for [ElevenLabs](https://elevenlabs.io/) [text-to-speech software.](https://elevenlabs.io/text-to-speech) 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](https://elevenlabs.io/docs/api-reference).

## ⚙️ Install

```bash
pip install elevenlabs
```

## 🗣️ Usage

[![Open in Spaces](https://img.shields.io/badge/🤗-Open%20in%20Spaces-blue.svg)](https://huggingface.co/spaces/elevenlabs/tts)
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/gist/flavioschneider/49468d728a816c6538fd2f56b3b50b96/elevenlabs-python.ipynb)

### 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](https://elevenlabs.io/docs/speech-synthesis/models).

```py
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)
```

<details> <summary> Play </summary>

🎧 **Try it out!** Want to hear our voices in action? Visit the [ElevenLabs Voice Lab](https://elevenlabs.io/voice-lab) to experiment with different voices, languages, and settings.

</details>

## 🗣️ Voices

List all your available voices with `voices()`.

```py
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](https://elevenlabs.io/docs/api-reference/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.

```py
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)
```

</details>

## Clone Voice

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

```py
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.

```py
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.

```py
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.

```python
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](https://elevenlabs.io/languages).

<img src="https://github.com/elevenlabs/elevenlabs-js/blob/main/assets/languages.png" width="900">

## 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!

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "elevenlabs",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/a7/3e/580937a8b9b06fbf34e9f013796a0a1845aa0feb55ea109fb941ec7db11f/elevenlabs-1.12.1.tar.gz",
    "platform": null,
    "description": "# ElevenLabs Python Library\n\n![LOGO](https://github.com/elevenlabs/elevenlabs-python/assets/12028621/21267d89-5e82-4e7e-9c81-caf30b237683)\n\n[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-SDK%20generated%20by%20Fern-brightgreen)](https://buildwithfern.com/?utm_source=fern-elevenlabs/elevenlabs-python/readme)\n[![Discord](https://badgen.net/badge/black/ElevenLabs/icon?icon=discord&label)](https://discord.gg/elevenlabs)\n[![Twitter](https://badgen.net/badge/black/elevenlabsio/icon?icon=twitter&label)](https://twitter.com/elevenlabsio)\n[![PyPI - Python Version](https://img.shields.io/pypi/v/elevenlabs?style=flat&colorA=black&colorB=black)](https://pypi.org/project/elevenlabs/)\n[![Downloads](https://static.pepy.tech/personalized-badge/elevenlabs?period=total&units=international_system&left_color=black&right_color=black&left_text=Downloads)](https://pepy.tech/project/elevenlabs)\n\nThe official Python API for [ElevenLabs](https://elevenlabs.io/) [text-to-speech software.](https://elevenlabs.io/text-to-speech) Eleven brings the most compelling, rich and lifelike voices to creators and developers in just a few lines of code.\n\n## \ud83d\udcd6 API & Docs\n\nCheck out the [HTTP API documentation](https://elevenlabs.io/docs/api-reference).\n\n## \u2699\ufe0f Install\n\n```bash\npip install elevenlabs\n```\n\n## \ud83d\udde3\ufe0f Usage\n\n[![Open in Spaces](https://img.shields.io/badge/\ud83e\udd17-Open%20in%20Spaces-blue.svg)](https://huggingface.co/spaces/elevenlabs/tts)\n[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/gist/flavioschneider/49468d728a816c6538fd2f56b3b50b96/elevenlabs-python.ipynb)\n\n### Main Models\n\n1. **Eleven Multilingual v2** (`eleven_multilingual_v2`)\n\n   - Excels in stability, language diversity, and accent accuracy\n   - Supports 29 languages\n   - Recommended for most use cases\n\n2. **Eleven Turbo v2.5** (`eleven_turbo_v2_5`)\n   - High quality, lowest latency\n   - Ideal for developer use cases where speed is crucial\n   - Supports 32 languages\n\nFor more detailed information about these models and others, visit the [ElevenLabs Models documentation](https://elevenlabs.io/docs/speech-synthesis/models).\n\n```py\nfrom elevenlabs import play\nfrom elevenlabs.client import ElevenLabs\n\nclient = ElevenLabs(\n  api_key=\"YOUR_API_KEY\", # Defaults to ELEVEN_API_KEY\n)\n\naudio = client.generate(\n  text=\"Hello! \u4f60\u597d! Hola! \u0928\u092e\u0938\u094d\u0924\u0947! Bonjour! \u3053\u3093\u306b\u3061\u306f! \u0645\u0631\u062d\u0628\u0627! \uc548\ub155\ud558\uc138\uc694! Ciao! Cze\u015b\u0107! \u041f\u0440\u0438\u0432\u0456\u0442! \u0bb5\u0ba3\u0b95\u0bcd\u0b95\u0bae\u0bcd!\",\n  voice=\"Brian\",\n  model=\"eleven_multilingual_v2\"\n)\nplay(audio)\n```\n\n<details> <summary> Play </summary>\n\n\ud83c\udfa7 **Try it out!** Want to hear our voices in action? Visit the [ElevenLabs Voice Lab](https://elevenlabs.io/voice-lab) to experiment with different voices, languages, and settings.\n\n</details>\n\n## \ud83d\udde3\ufe0f Voices\n\nList all your available voices with `voices()`.\n\n```py\nfrom elevenlabs.client import ElevenLabs\n\nclient = ElevenLabs(\n  api_key=\"YOUR_API_KEY\", # Defaults to ELEVEN_API_KEY\n)\n\nresponse = client.voices.get_all()\naudio = client.generate(text=\"Hello there!\", voice=response.voices[0])\nprint(response.voices)\n```\n\nFor information about the structure of the voices output, please refer to the [official ElevenLabs API documentation for Get Voices](https://elevenlabs.io/docs/api-reference/get-voices).\n\nBuild a voice object with custom settings to personalize the voice style, or call\n`client.voices.get_settings(\"your-voice-id\")` to get the default settings for the voice.\n\n```py\nfrom elevenlabs import Voice, VoiceSettings, play\nfrom elevenlabs.client import ElevenLabs\n\nclient = ElevenLabs(\n  api_key=\"YOUR_API_KEY\", # Defaults to ELEVEN_API_KEY\n)\n\naudio = client.generate(\n    text=\"Hello! My name is Brian.\",\n    voice=Voice(\n        voice_id='nPczCjzI2devNBz1zQrb',\n        settings=VoiceSettings(stability=0.71, similarity_boost=0.5, style=0.0, use_speaker_boost=True)\n    )\n)\n\nplay(audio)\n```\n\n</details>\n\n## Clone Voice\n\nClone your voice in an instant. Note that voice cloning requires an API key, see below.\n\n```py\nfrom elevenlabs.client import ElevenLabs\nfrom elevenlabs import play\n\nclient = ElevenLabs(\n  api_key=\"YOUR_API_KEY\", # Defaults to ELEVEN_API_KEY\n)\n\nvoice = client.clone(\n    name=\"Alex\",\n    description=\"An old American male voice with a slight hoarseness in his throat. Perfect for news\", # Optional\n    files=[\"./sample_0.mp3\", \"./sample_1.mp3\", \"./sample_2.mp3\"],\n)\n\naudio = client.generate(text=\"Hi! I'm a cloned voice!\", voice=voice)\n\nplay(audio)\n```\n\n## \ud83d\udebf Streaming\n\nStream audio in real-time, as it's being generated.\n\n```py\nfrom elevenlabs.client import ElevenLabs\nfrom elevenlabs import stream\n\nclient = ElevenLabs(\n  api_key=\"YOUR_API_KEY\", # Defaults to ELEVEN_API_KEY\n)\n\naudio_stream = client.generate(\n  text=\"This is a... streaming voice!!\",\n  stream=True\n)\n\nstream(audio_stream)\n```\n\nNote that `generate` is a helper function. If you'd like to access\nthe raw method, simply use `client.text_to_speech.convert_as_stream`.\n\n### Input streaming\n\nStream 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.\n\n```py\nfrom elevenlabs.client import ElevenLabs\nfrom elevenlabs import stream\n\nclient = ElevenLabs(\n  api_key=\"YOUR_API_KEY\", # Defaults to ELEVEN_API_KEY\n)\n\ndef text_stream():\n    yield \"Hi there, I'm Eleven \"\n    yield \"I'm a text to speech API \"\n\naudio_stream = client.generate(\n    text=text_stream(),\n    voice=\"Brian\",\n    model=\"eleven_multilingual_v2\",\n    stream=True\n)\n\nstream(audio_stream)\n```\n\nNote that `generate` is a helper function. If you'd like to access\nthe raw method, simply use `client.text_to_speech.convert_realtime`.\n\n## Async Client\n\nUse `AsyncElevenLabs` if you want to make API calls asynchronously.\n\n```python\nimport asyncio\n\nfrom elevenlabs.client import AsyncElevenLabs\n\neleven = AsyncElevenLabs(\n  api_key=\"MY_API_KEY\" # Defaults to ELEVEN_API_KEY\n)\n\nasync def print_models() -> None:\n    models = await eleven.models.get_all()\n    print(models)\n\nasyncio.run(print_models())\n```\n\n## Languages Supported\n\nWe support 32 languages and 100+ accents. Explore [all languages](https://elevenlabs.io/languages).\n\n<img src=\"https://github.com/elevenlabs/elevenlabs-js/blob/main/assets/languages.png\" width=\"900\">\n\n## Contributing\n\nWhile 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!\n\nOn the other hand, contributions to the README are always very welcome!\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": null,
    "version": "1.12.1",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6115de3dc7963b63408231b9b05454e8b894a6eedfe2a6c5970307f1f3d1e27b",
                "md5": "d751040a18ed7b31e19534165809815f",
                "sha256": "ea36fb437fd19cb7c37ed2bb690f18c2fe00b88b8619fdac882a9db9f8676aba"
            },
            "downloads": -1,
            "filename": "elevenlabs-1.12.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d751040a18ed7b31e19534165809815f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 150529,
            "upload_time": "2024-10-30T17:37:41",
            "upload_time_iso_8601": "2024-10-30T17:37:41.141390Z",
            "url": "https://files.pythonhosted.org/packages/61/15/de3dc7963b63408231b9b05454e8b894a6eedfe2a6c5970307f1f3d1e27b/elevenlabs-1.12.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a73e580937a8b9b06fbf34e9f013796a0a1845aa0feb55ea109fb941ec7db11f",
                "md5": "2f101b98daf2d3c3fbeb5f0a3f15c428",
                "sha256": "7c03526b87e14e39e25fe84dbaaa84e0a4f467b6d3bf859503ce3e3a9125d07b"
            },
            "downloads": -1,
            "filename": "elevenlabs-1.12.1.tar.gz",
            "has_sig": false,
            "md5_digest": "2f101b98daf2d3c3fbeb5f0a3f15c428",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 75978,
            "upload_time": "2024-10-30T17:37:42",
            "upload_time_iso_8601": "2024-10-30T17:37:42.343887Z",
            "url": "https://files.pythonhosted.org/packages/a7/3e/580937a8b9b06fbf34e9f013796a0a1845aa0feb55ea109fb941ec7db11f/elevenlabs-1.12.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-30 17:37:42",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "elevenlabs"
}
        
Elapsed time: 1.46063s