Complete python wrapper for the elevenlabs API
Project description
elevenlabslib
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file elevenlabslib-0.31.3.tar.gz
.
File metadata
- Download URL: elevenlabslib-0.31.3.tar.gz
- Upload date:
- Size: 53.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ddc5097e5efadf193351c8136042e14646836f1cc6e527f1345e3ec327db886 |
|
MD5 | 569f24bf526b09de559ddd28e4a2ad5b |
|
BLAKE2b-256 | 6e08498760cc363e43262c3b9522e5442091e68ddd1793ae50b8199e76c8805c |
File details
Details for the file elevenlabslib-0.31.3-py3-none-any.whl
.
File metadata
- Download URL: elevenlabslib-0.31.3-py3-none-any.whl
- Upload date:
- Size: 57.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ed820823ebd311f3eda2945dca5e216606659f4d1c2f44c9f070f896e79b9a7 |
|
MD5 | 208c5662414e5060d27cca13370279a8 |
|
BLAKE2b-256 | 4eef090d9360cb373f5d6dd7f23f7e3b7474f2069a2fc16792fdecc44ac144e1 |