Skip to main content

elevenlabslib

Buy Me a Coffee at ko-fi.com PyPI - Downloads PyPI GitHub last commit

Python wrapper for the full elevenlabs API.

NOTE: There's now an official wrapper, but this project will continue to be maintained.

The main reason is the different approach to playback. By doing playback purely within python instead of piping to an external process, there are a couple of important extra things that can be done, such as:

  • Playback on a specific output device
  • Running functions exactly when the playback begins and ends
  • Controlling the playback from within python

Documentation now available at https://elevenlabslib.readthedocs.io/en/latest/

Installation

Just run pip install elevenlabslib, it's on pypi.

Note: On Linux, you may need to install portaudio. On debian and derivatives, it's sudo apt-get install libportaudio2, and possibly also sudo apt-get install python3-pyaudio.

IMPORTANT: The library requires libsndfile v1.1.0 or newer, as that is when mp3 support was introduced. This won't be an issue on Windows, but may be relevant on other platforms. Check the soundfile repo for more information.

Usage

For a far more comprehensive example, check example.py or the docs.

Here is a very simple usage sample.

  • Retrieves a voice based on the name
  • Plays back (using the included playback functions that use sounddevice) all its samples (and the preview)
  • Generates and plays back a new audio
  • Deletes the newly created audio from the user history
from elevenlabslib import *

user = User("API_KEY")
voice = user.get_voices_by_name_v2("Rachel")[0]  # This is a list because multiple voices can have the same name

voice.generate_play_audio_v2("Test.", playbackOptions=PlaybackOptions(runInBackground=False))

for historyItem in user.get_history_items_paginated():
    if historyItem.text == "Test.":
        # The first items are the newest, so we can stop as soon as we find one.
        historyItem.delete()
        break

Metadata

Release files for elevenlabslib 0.32.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for elevenlabslib 0.32.1
File Size Uploaded
elevenlabslib-0.32.1.tar.gz 57.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for elevenlabslib 0.32.1
File Interpreter ABI Platform
elevenlabslib-0.32.1-py3-none-any.whl Python 3 none any Details

Total release size: 118.2 kB

Release files / elevenlabslib-0.32.1.tar.gz

Download URL elevenlabslib-0.32.1.tar.gz
Size 57.0 kB
Tags Source
SHA-256 checksum
How to use checksums
fb950fe4ef68ac6375bfb497ad7d1548c5812a75eed4dd96214d567ab94e3f33
BLAKE2b-256 checksum
How to use checksums
4bfd3968de71a0faa3acd7f4bd2150bac41e2034dc972eeb375c7e61b8d71601
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / elevenlabslib-0.32.1-py3-none-any.whl

Download URL elevenlabslib-0.32.1-py3-none-any.whl
Size 61.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
01b58215e12717100fc6de7d2c4e15bdcdde23abb627db81cd445cba1778abad
BLAKE2b-256 checksum
How to use checksums
cedf26b537f352894840f141f67cbbb802c26ca2e305881f83ba9b3fcd28db9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release history Release notifications | RSS feed

This release

0.32.1 This release

2 release files

0.31.2

2 release files

0.31.1

2 release files

0.31.0

2 release files

0.30.1

2 release files

0.30.0

2 release files

0.22.6

2 release files

0.22.5

2 release files

0.22.4

2 release files

0.22.2

2 release files

0.22.0

2 release files

0.21.1

2 release files

0.21.0

2 release files

0.20.0

2 release files

0.19.0

2 release files

0.18.2

2 release files

0.18.1

2 release files

0.18.0

2 release files

0.17.1

2 release files

0.17.0

2 release files

0.16.2

2 release files

0.15.2

2 release files

0.15.1

2 release files

0.15.0

2 release files

0.14.2

2 release files

0.13.3

2 release files

0.13.2

2 release files

0.13.1

2 release files

0.13.0

2 release files

0.12.3

2 release files

0.12.2

2 release files

0.12.1

2 release files

0.12.0

2 release files

0.11.2

2 release files

0.11.1

2 release files

0.11.0

2 release files

0.9.4

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page