elevenlabs


Nameelevenlabs JSON
Version 1.50.2 PyPI version JSON
download
home_pageNone
SummaryNone
upload_time2024-12-15 00:01:32
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/25/80/f3ca3f93ca1b8ba9472ca8c8d4970b7bd93df86dbf6e52234dc21bb1a17a/elevenlabs-1.50.2.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.50.2",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7bcb662d44ebdc9f40f4d242a6c748d331da85a14a7b96a345f731836524c324",
                "md5": "abeefea73ead29e21a2bf6acc7d1aa08",
                "sha256": "5af32a365317c3183eb64d3458eb412f761729a2bcdda59c4ec225f0a44f6f7d"
            },
            "downloads": -1,
            "filename": "elevenlabs-1.50.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "abeefea73ead29e21a2bf6acc7d1aa08",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 227153,
            "upload_time": "2024-12-15T00:01:28",
            "upload_time_iso_8601": "2024-12-15T00:01:28.934019Z",
            "url": "https://files.pythonhosted.org/packages/7b/cb/662d44ebdc9f40f4d242a6c748d331da85a14a7b96a345f731836524c324/elevenlabs-1.50.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2580f3ca3f93ca1b8ba9472ca8c8d4970b7bd93df86dbf6e52234dc21bb1a17a",
                "md5": "b9b05b5be2adba154c92f4d9ec104c97",
                "sha256": "899c7fc19ae6cfd7b270cb9e5191d6c70506d7ab46e136dd700b93e927591cda"
            },
            "downloads": -1,
            "filename": "elevenlabs-1.50.2.tar.gz",
            "has_sig": false,
            "md5_digest": "b9b05b5be2adba154c92f4d9ec104c97",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 100529,
            "upload_time": "2024-12-15T00:01:32",
            "upload_time_iso_8601": "2024-12-15T00:01:32.019457Z",
            "url": "https://files.pythonhosted.org/packages/25/80/f3ca3f93ca1b8ba9472ca8c8d4970b7bd93df86dbf6e52234dc21bb1a17a/elevenlabs-1.50.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-15 00:01:32",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "elevenlabs"
}
        
Elapsed time: 0.39754s