Full implementation of the elevenlabs API in python
Project description
elevenlabslib
Full python implementation of the elevenlabs API.
Installation
Just run pip install elevenlabslib
, it's on pypi.
Usage
Here is a very simple usage sample.
- Retrieves a voice based on the name
- Plays back (using pydub) 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 *
import pydub
import pydub.playback
import io
#Playback function
def play(bytesData):
sound = pydub.AudioSegment.from_file_using_temporary_files(io.BytesIO(bytesData))
pydub.playback.play(sound)
return
user = ElevenLabsUser("[API_KEY]")
voice = user.get_voices_by_name("Rachel")[0] #This is a list because multiple voices can have the same name
play(voice.get_preview_bytes())
for sample in voice.get_samples():
play(sample.get_audio_bytes())
play(voice.generate_audio_bytes("Test."))
for historyItem in user.get_history_items():
if historyItem.text == "Test.":
#The first items are the newest, so we can stop as soon as we find one.
historyItem.delete()
break
For a far more comprehensive example, check example.py
on the github repo.
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
elevenlabslib-0.1.8.tar.gz
(7.6 kB
view hashes)
Built Distribution
Close
Hashes for elevenlabslib-0.1.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2be9aa910b29ec6a86996dbe16a23a8f38b206b18001b54229513177b728d99e |
|
MD5 | a80504504e0a78a6702311f6e6bb5c5d |
|
BLAKE2b-256 | 8b3eaf8cace36727b08da5affd0598a6cb40e51b1e8f9bc44759377620015eb4 |