Skip to content

Commit db6fa79

Browse files
committed
Merge branch 'main' into api-options
2 parents 9afd295 + 8a529ce commit db6fa79

File tree

196 files changed

+18471
-3027
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

196 files changed

+18471
-3027
lines changed

.github/workflows/ci.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ name: ci
33
on: [push]
44
jobs:
55
compile:
6-
runs-on: ubuntu-20.04
6+
runs-on: ubuntu-24.04
77
steps:
88
- name: Checkout repo
99
uses: actions/checkout@v3
1010
- name: Set up python
1111
uses: actions/setup-python@v4
1212
with:
13-
python-version: 3.7
13+
python-version: 3.8
1414
- name: Bootstrap poetry
1515
run: |
1616
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
@@ -19,14 +19,14 @@ jobs:
1919
- name: Compile
2020
run: poetry run mypy .
2121
test:
22-
runs-on: ubuntu-20.04
22+
runs-on: ubuntu-24.04
2323
steps:
2424
- name: Checkout repo
2525
uses: actions/checkout@v3
2626
- name: Set up python
2727
uses: actions/setup-python@v4
2828
with:
29-
python-version: 3.7
29+
python-version: 3.8
3030
- name: Bootstrap poetry
3131
run: |
3232
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
@@ -36,19 +36,19 @@ jobs:
3636
- name: Test
3737
run: poetry run pytest .
3838
env:
39-
ELEVEN_API_KEY: ${{ secrets.TEST_API_KEY }}
39+
ELEVENLABS_API_KEY: ${{ secrets.ELEVENLABS_API_KEY }}
4040

4141
publish:
4242
needs: [compile, test]
4343
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
44-
runs-on: ubuntu-20.04
44+
runs-on: ubuntu-24.04
4545
steps:
4646
- name: Checkout repo
4747
uses: actions/checkout@v3
4848
- name: Set up python
4949
uses: actions/setup-python@v4
5050
with:
51-
python-version: 3.7
51+
python-version: 3.8
5252
- name: Bootstrap poetry
5353
run: |
5454
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1

.github/workflows/tests.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Test SDK
33
on: [push]
44
jobs:
55
compile:
6-
runs-on: ubuntu-20.04
6+
runs-on: ubuntu-24.04
77
steps:
88
- name: Checkout repo
99
uses: actions/checkout@v3
@@ -19,7 +19,7 @@ jobs:
1919
- name: Compile
2020
run: poetry run mypy .
2121
test:
22-
runs-on: ubuntu-20.04
22+
runs-on: ubuntu-24.04
2323
steps:
2424
- name: Checkout repo
2525
uses: actions/checkout@v3
@@ -38,6 +38,6 @@ jobs:
3838

3939
- name: Test
4040
env:
41-
ELEVEN_API_KEY: ${{ secrets.TEST_API_KEY }}
41+
ELEVENLABS_API_KEY: ${{ secrets.ELEVENLABS_API_KEY }}
4242
run: |
43-
poetry run pytest .
43+
poetry run pytest .

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ dist/
33
__pycache__/
44
poetry.toml
55
.ruff_cache/
6-
.DS_Store

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 Elevenlabs.
3+
Copyright (c) 2025 Elevenlabs.
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+28-49
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,21 @@ pip install elevenlabs
4141
For more detailed information about these models and others, visit the [ElevenLabs Models documentation](https://elevenlabs.io/docs/speech-synthesis/models).
4242

4343
```py
44-
from elevenlabs import play
44+
from dotenv import load_dotenv
4545
from elevenlabs.client import ElevenLabs
46+
from elevenlabs import play
4647

47-
client = ElevenLabs(
48-
api_key="YOUR_API_KEY", # Defaults to ELEVEN_API_KEY or ELEVENLABS_API_KEY
49-
)
48+
load_dotenv()
5049

51-
audio = client.generate(
52-
text="Hello! 你好! Hola! नमस्ते! Bonjour! こんにちは! مرحبا! 안녕하세요! Ciao! Cześć! Привіт! வணக்கம்!",
53-
voice="Brian",
54-
model="eleven_multilingual_v2"
50+
client = ElevenLabs()
51+
52+
audio = client.text_to_speech.convert(
53+
text="The first move is what sets everything in motion.",
54+
voice_id="JBFqnCBsd6RMkjVDRZzb",
55+
model_id="eleven_multilingual_v2",
56+
output_format="mp3_44100_128",
5557
)
58+
5659
play(audio)
5760
```
5861

@@ -70,11 +73,10 @@ List all your available voices with `voices()`.
7073
from elevenlabs.client import ElevenLabs
7174

7275
client = ElevenLabs(
73-
api_key="YOUR_API_KEY", # Defaults to ELEVEN_API_KEY or ELEVENLABS_API_KEY
76+
api_key="YOUR_API_KEY",
7477
)
7578

7679
response = client.voices.get_all()
77-
audio = client.generate(text="Hello there!", voice=response.voices[0])
7880
print(response.voices)
7981
```
8082

@@ -83,25 +85,6 @@ For information about the structure of the voices output, please refer to the [o
8385
Build a voice object with custom settings to personalize the voice style, or call
8486
`client.voices.get_settings("your-voice-id")` to get the default settings for the voice.
8587

86-
```py
87-
from elevenlabs import Voice, VoiceSettings, play
88-
from elevenlabs.client import ElevenLabs
89-
90-
client = ElevenLabs(
91-
api_key="YOUR_API_KEY", # Defaults to ELEVEN_API_KEY or ELEVENLABS_API_KEY
92-
)
93-
94-
audio = client.generate(
95-
text="Hello! My name is Brian.",
96-
voice=Voice(
97-
voice_id='nPczCjzI2devNBz1zQrb',
98-
settings=VoiceSettings(stability=0.71, similarity_boost=0.5, style=0.0, use_speaker_boost=True)
99-
)
100-
)
101-
102-
play(audio)
103-
```
104-
10588
</details>
10689

10790
## Clone Voice
@@ -113,42 +96,41 @@ from elevenlabs.client import ElevenLabs
11396
from elevenlabs import play
11497

11598
client = ElevenLabs(
116-
api_key="YOUR_API_KEY", # Defaults to ELEVEN_API_KEY or ELEVENLABS_API_KEY
99+
api_key="YOUR_API_KEY", # Defaults ELEVENLABS_API_KEY
117100
)
118101

119102
voice = client.clone(
120103
name="Alex",
121104
description="An old American male voice with a slight hoarseness in his throat. Perfect for news", # Optional
122105
files=["./sample_0.mp3", "./sample_1.mp3", "./sample_2.mp3"],
123106
)
124-
125-
audio = client.generate(text="Hi! I'm a cloned voice!", voice=voice)
126-
127-
play(audio)
128107
```
129108

130109
## 🚿 Streaming
131110

132111
Stream audio in real-time, as it's being generated.
133112

134113
```py
135-
from elevenlabs.client import ElevenLabs
136114
from elevenlabs import stream
115+
from elevenlabs.client import ElevenLabs
137116

138-
client = ElevenLabs(
139-
api_key="YOUR_API_KEY", # Defaults to ELEVEN_API_KEY or ELEVENLABS_API_KEY
140-
)
117+
client = ElevenLabs()
141118

142-
audio_stream = client.generate(
143-
text="This is a... streaming voice!!",
144-
stream=True
119+
audio_stream = client.text_to_speech.convert_as_stream(
120+
text="This is a test",
121+
voice_id="JBFqnCBsd6RMkjVDRZzb",
122+
model_id="eleven_multilingual_v2"
145123
)
146124

125+
# option 1: play the streamed audio locally
147126
stream(audio_stream)
148-
```
149127

150-
Note that `generate` is a helper function. If you'd like to access
151-
the raw method, simply use `client.text_to_speech.convert_as_stream`.
128+
# option 2: process the audio bytes manually
129+
for chunk in audio_stream:
130+
if isinstance(chunk, bytes):
131+
print(chunk)
132+
133+
```
152134

153135
### Input streaming
154136

@@ -159,7 +141,7 @@ from elevenlabs.client import ElevenLabs
159141
from elevenlabs import stream
160142

161143
client = ElevenLabs(
162-
api_key="YOUR_API_KEY", # Defaults to ELEVEN_API_KEY or ELEVENLABS_API_KEY
144+
api_key="YOUR_API_KEY", # Defaults to ELEVENLABS_API_KEY
163145
)
164146

165147
def text_stream():
@@ -176,9 +158,6 @@ audio_stream = client.generate(
176158
stream(audio_stream)
177159
```
178160

179-
Note that `generate` is a helper function. If you'd like to access
180-
the raw method, simply use `client.text_to_speech.convert_realtime`.
181-
182161
## Async Client
183162

184163
Use `AsyncElevenLabs` if you want to make API calls asynchronously.
@@ -189,7 +168,7 @@ import asyncio
189168
from elevenlabs.client import AsyncElevenLabs
190169

191170
eleven = AsyncElevenLabs(
192-
api_key="MY_API_KEY" # Defaults to ELEVEN_API_KEY or ELEVENLABS_API_KEY
171+
api_key="MY_API_KEY" # Defaults to ELEVENLABS_API_KEY
193172
)
194173

195174
async def print_models() -> None:

0 commit comments

Comments
 (0)