chub-dev 0.1.0 → 0.1.2-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -0
- package/bin/chub-mcp +2 -0
- package/dist/airtable/docs/database/javascript/DOC.md +1437 -0
- package/dist/airtable/docs/database/python/DOC.md +1735 -0
- package/dist/amplitude/docs/analytics/javascript/DOC.md +1282 -0
- package/dist/amplitude/docs/analytics/python/DOC.md +1199 -0
- package/dist/anthropic/docs/claude-api/javascript/DOC.md +503 -0
- package/dist/anthropic/docs/claude-api/python/DOC.md +389 -0
- package/dist/asana/docs/tasks/DOC.md +1396 -0
- package/dist/assemblyai/docs/transcription/DOC.md +1043 -0
- package/dist/atlassian/docs/confluence/javascript/DOC.md +1347 -0
- package/dist/atlassian/docs/confluence/python/DOC.md +1604 -0
- package/dist/auth0/docs/identity/javascript/DOC.md +968 -0
- package/dist/auth0/docs/identity/python/DOC.md +1199 -0
- package/dist/aws/docs/s3/javascript/DOC.md +1773 -0
- package/dist/aws/docs/s3/python/DOC.md +1807 -0
- package/dist/binance/docs/trading/javascript/DOC.md +1315 -0
- package/dist/binance/docs/trading/python/DOC.md +1454 -0
- package/dist/braintree/docs/gateway/javascript/DOC.md +1278 -0
- package/dist/braintree/docs/gateway/python/DOC.md +1179 -0
- package/dist/chromadb/docs/embeddings-db/javascript/DOC.md +1263 -0
- package/dist/chromadb/docs/embeddings-db/python/DOC.md +1707 -0
- package/dist/clerk/docs/auth/javascript/DOC.md +1220 -0
- package/dist/clerk/docs/auth/python/DOC.md +274 -0
- package/dist/cloudflare/docs/workers/javascript/DOC.md +918 -0
- package/dist/cloudflare/docs/workers/python/DOC.md +994 -0
- package/dist/cockroachdb/docs/distributed-db/DOC.md +1500 -0
- package/dist/cohere/docs/llm/DOC.md +1335 -0
- package/dist/datadog/docs/monitoring/javascript/DOC.md +1740 -0
- package/dist/datadog/docs/monitoring/python/DOC.md +1815 -0
- package/dist/deepgram/docs/speech/javascript/DOC.md +885 -0
- package/dist/deepgram/docs/speech/python/DOC.md +685 -0
- package/dist/deepl/docs/translation/javascript/DOC.md +887 -0
- package/dist/deepl/docs/translation/python/DOC.md +944 -0
- package/dist/deepseek/docs/llm/DOC.md +1220 -0
- package/dist/directus/docs/headless-cms/javascript/DOC.md +1128 -0
- package/dist/directus/docs/headless-cms/python/DOC.md +1276 -0
- package/dist/discord/docs/bot/javascript/DOC.md +1090 -0
- package/dist/discord/docs/bot/python/DOC.md +1130 -0
- package/dist/elasticsearch/docs/search/DOC.md +1634 -0
- package/dist/elevenlabs/docs/text-to-speech/javascript/DOC.md +336 -0
- package/dist/elevenlabs/docs/text-to-speech/python/DOC.md +552 -0
- package/dist/firebase/docs/auth/DOC.md +1015 -0
- package/dist/gemini/docs/genai/javascript/DOC.md +691 -0
- package/dist/gemini/docs/genai/python/DOC.md +555 -0
- package/dist/github/docs/octokit/DOC.md +1560 -0
- package/dist/google/docs/bigquery/javascript/DOC.md +1688 -0
- package/dist/google/docs/bigquery/python/DOC.md +1503 -0
- package/dist/hubspot/docs/crm/javascript/DOC.md +1805 -0
- package/dist/hubspot/docs/crm/python/DOC.md +2033 -0
- package/dist/huggingface/docs/transformers/DOC.md +948 -0
- package/dist/intercom/docs/messaging/javascript/DOC.md +1844 -0
- package/dist/intercom/docs/messaging/python/DOC.md +1797 -0
- package/dist/jira/docs/issues/javascript/DOC.md +1420 -0
- package/dist/jira/docs/issues/python/DOC.md +1492 -0
- package/dist/kafka/docs/streaming/javascript/DOC.md +1671 -0
- package/dist/kafka/docs/streaming/python/DOC.md +1464 -0
- package/dist/landingai-ade/docs/api/DOC.md +620 -0
- package/dist/landingai-ade/docs/sdk/python/DOC.md +489 -0
- package/dist/landingai-ade/docs/sdk/typescript/DOC.md +542 -0
- package/dist/landingai-ade/skills/SKILL.md +489 -0
- package/dist/launchdarkly/docs/feature-flags/javascript/DOC.md +1191 -0
- package/dist/launchdarkly/docs/feature-flags/python/DOC.md +1671 -0
- package/dist/linear/docs/tracker/DOC.md +1554 -0
- package/dist/livekit/docs/realtime/javascript/DOC.md +303 -0
- package/dist/livekit/docs/realtime/python/DOC.md +163 -0
- package/dist/mailchimp/docs/marketing/DOC.md +1420 -0
- package/dist/meilisearch/docs/search/DOC.md +1241 -0
- package/dist/microsoft/docs/onedrive/javascript/DOC.md +1421 -0
- package/dist/microsoft/docs/onedrive/python/DOC.md +1549 -0
- package/dist/mongodb/docs/atlas/DOC.md +2041 -0
- package/dist/notion/docs/workspace-api/javascript/DOC.md +1435 -0
- package/dist/notion/docs/workspace-api/python/DOC.md +1400 -0
- package/dist/okta/docs/identity/javascript/DOC.md +1171 -0
- package/dist/okta/docs/identity/python/DOC.md +1401 -0
- package/dist/openai/docs/chat/javascript/DOC.md +407 -0
- package/dist/openai/docs/chat/python/DOC.md +568 -0
- package/dist/paypal/docs/checkout/DOC.md +278 -0
- package/dist/pinecone/docs/sdk/javascript/DOC.md +984 -0
- package/dist/pinecone/docs/sdk/python/DOC.md +1395 -0
- package/dist/plaid/docs/banking/javascript/DOC.md +1163 -0
- package/dist/plaid/docs/banking/python/DOC.md +1203 -0
- package/dist/playwright-community/skills/login-flows/SKILL.md +108 -0
- package/dist/postmark/docs/transactional-email/DOC.md +1168 -0
- package/dist/prisma/docs/orm/javascript/DOC.md +1419 -0
- package/dist/prisma/docs/orm/python/DOC.md +1317 -0
- package/dist/qdrant/docs/vector-search/javascript/DOC.md +1221 -0
- package/dist/qdrant/docs/vector-search/python/DOC.md +1653 -0
- package/dist/rabbitmq/docs/message-queue/javascript/DOC.md +1193 -0
- package/dist/rabbitmq/docs/message-queue/python/DOC.md +1243 -0
- package/dist/razorpay/docs/payments/javascript/DOC.md +1219 -0
- package/dist/razorpay/docs/payments/python/DOC.md +1330 -0
- package/dist/redis/docs/key-value/javascript/DOC.md +1851 -0
- package/dist/redis/docs/key-value/python/DOC.md +2054 -0
- package/dist/registry.json +2817 -0
- package/dist/replicate/docs/model-hosting/DOC.md +1318 -0
- package/dist/resend/docs/email/DOC.md +1271 -0
- package/dist/salesforce/docs/crm/javascript/DOC.md +1241 -0
- package/dist/salesforce/docs/crm/python/DOC.md +1183 -0
- package/dist/search-index.json +1 -0
- package/dist/sendgrid/docs/email-api/javascript/DOC.md +371 -0
- package/dist/sendgrid/docs/email-api/python/DOC.md +656 -0
- package/dist/sentry/docs/error-tracking/javascript/DOC.md +1073 -0
- package/dist/sentry/docs/error-tracking/python/DOC.md +1309 -0
- package/dist/shopify/docs/storefront/DOC.md +457 -0
- package/dist/slack/docs/workspace/javascript/DOC.md +933 -0
- package/dist/slack/docs/workspace/python/DOC.md +271 -0
- package/dist/square/docs/payments/javascript/DOC.md +1855 -0
- package/dist/square/docs/payments/python/DOC.md +1728 -0
- package/dist/stripe/docs/api/DOC.md +1727 -0
- package/dist/stripe/docs/payments/DOC.md +1726 -0
- package/dist/stytch/docs/auth/javascript/DOC.md +1813 -0
- package/dist/stytch/docs/auth/python/DOC.md +1962 -0
- package/dist/supabase/docs/client/DOC.md +1606 -0
- package/dist/twilio/docs/messaging/python/DOC.md +469 -0
- package/dist/twilio/docs/messaging/typescript/DOC.md +946 -0
- package/dist/vercel/docs/platform/DOC.md +1940 -0
- package/dist/weaviate/docs/vector-db/javascript/DOC.md +1268 -0
- package/dist/weaviate/docs/vector-db/python/DOC.md +1388 -0
- package/dist/zendesk/docs/support/javascript/DOC.md +2150 -0
- package/dist/zendesk/docs/support/python/DOC.md +2297 -0
- package/package.json +22 -6
- package/skills/get-api-docs/SKILL.md +84 -0
- package/src/commands/annotate.js +83 -0
- package/src/commands/build.js +12 -1
- package/src/commands/feedback.js +150 -0
- package/src/commands/get.js +83 -42
- package/src/commands/search.js +7 -0
- package/src/index.js +43 -17
- package/src/lib/analytics.js +90 -0
- package/src/lib/annotations.js +57 -0
- package/src/lib/bm25.js +170 -0
- package/src/lib/cache.js +69 -6
- package/src/lib/config.js +8 -3
- package/src/lib/identity.js +99 -0
- package/src/lib/registry.js +103 -20
- package/src/lib/telemetry.js +86 -0
- package/src/mcp/server.js +177 -0
- package/src/mcp/tools.js +251 -0
|
@@ -0,0 +1,552 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: text-to-speech
|
|
3
|
+
description: "ElevenLabs Python SDK for text-to-speech synthesis, voice cloning, audio generation, and real-time streaming"
|
|
4
|
+
metadata:
|
|
5
|
+
languages: "python"
|
|
6
|
+
versions: "2.18.0"
|
|
7
|
+
updated-on: "2026-03-02"
|
|
8
|
+
source: maintainer
|
|
9
|
+
tags: "elevenlabs,text-to-speech,tts,audio,voice"
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# ElevenLabs Python SDK Coding Guidelines
|
|
13
|
+
|
|
14
|
+
You are an ElevenLabs API coding expert. Help me with writing code using the ElevenLabs Python SDK and API.
|
|
15
|
+
|
|
16
|
+
Please follow the following guidelines when generating code.
|
|
17
|
+
|
|
18
|
+
You can find the official SDK documentation and code samples here:
|
|
19
|
+
https://elevenlabs.io/docs/api-reference
|
|
20
|
+
|
|
21
|
+
## Golden Rule: Use the Correct and Current SDK
|
|
22
|
+
|
|
23
|
+
Always use the official ElevenLabs Python SDK for all ElevenLabs API interactions. This is the standard and recommended library for accessing ElevenLabs services.
|
|
24
|
+
|
|
25
|
+
- **Library Name:** ElevenLabs Python SDK
|
|
26
|
+
- **Python Package:** `elevenlabs`
|
|
27
|
+
|
|
28
|
+
**Installation:**
|
|
29
|
+
|
|
30
|
+
- **Correct:** `pip install elevenlabs`
|
|
31
|
+
|
|
32
|
+
**APIs and Usage:**
|
|
33
|
+
|
|
34
|
+
- **Correct:** `from elevenlabs.client import ElevenLabs`
|
|
35
|
+
- **Correct:** `from elevenlabs.client import AsyncElevenLabs`
|
|
36
|
+
- **Correct:** `from elevenlabs import play, save, stream`
|
|
37
|
+
|
|
38
|
+
## Initialization and API Key
|
|
39
|
+
|
|
40
|
+
The `elevenlabs` library requires creating a client object for all API calls.
|
|
41
|
+
|
|
42
|
+
- Always use `client = ElevenLabs()` to create a client object.
|
|
43
|
+
- Set `ELEVENLABS_API_KEY` environment variable, which will be picked up automatically.
|
|
44
|
+
- Alternatively, pass the API key directly: `client = ElevenLabs(api_key="YOUR_API_KEY")`
|
|
45
|
+
|
|
46
|
+
## Main Models
|
|
47
|
+
|
|
48
|
+
By default, use the following models when using the ElevenLabs SDK:
|
|
49
|
+
|
|
50
|
+
- **General Text-to-Speech (Recommended):** `eleven_multilingual_v2`
|
|
51
|
+
- Excels in stability, language diversity, and accent accuracy
|
|
52
|
+
- Supports 29 languages
|
|
53
|
+
- Recommended for most use cases
|
|
54
|
+
|
|
55
|
+
- **Ultra-Low Latency:** `eleven_flash_v2_5`
|
|
56
|
+
- Supports 32 languages
|
|
57
|
+
- Faster model, 50% lower price per character
|
|
58
|
+
|
|
59
|
+
- **Balanced Quality and Speed:** `eleven_turbo_v2_5`
|
|
60
|
+
- Good balance of quality and latency
|
|
61
|
+
- Ideal for developer use cases where speed is crucial
|
|
62
|
+
- Supports 32 languages
|
|
63
|
+
|
|
64
|
+
## Basic Text-to-Speech Conversion
|
|
65
|
+
|
|
66
|
+
Here's how to convert text to speech using a voice of your choice:
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
from elevenlabs.client import ElevenLabs
|
|
70
|
+
from elevenlabs import play
|
|
71
|
+
|
|
72
|
+
client = ElevenLabs()
|
|
73
|
+
|
|
74
|
+
audio = client.text_to_speech.convert(
|
|
75
|
+
text="The first move is what sets everything in motion.",
|
|
76
|
+
voice_id="JBFqnCBsd6RMkjVDRZzb",
|
|
77
|
+
model_id="eleven_multilingual_v2",
|
|
78
|
+
output_format="mp3_44100_128",
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
play(audio)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The `convert` method returns an iterator of bytes that represents the generated audio file.
|
|
85
|
+
|
|
86
|
+
## Audio Output Formats
|
|
87
|
+
|
|
88
|
+
The SDK supports various audio formats specified as `codec_sample_rate_bitrate`:
|
|
89
|
+
|
|
90
|
+
- **MP3 formats:** `mp3_22050_32`, `mp3_44100_32`, `mp3_44100_64`, `mp3_44100_96`, `mp3_44100_128`, `mp3_44100_192`
|
|
91
|
+
- **PCM formats:** `pcm_8000`, `pcm_16000`, `pcm_22050`, `pcm_24000`, `pcm_44100`, `pcm_48000`
|
|
92
|
+
- **Other formats:** `ulaw_8000`, `alaw_8000`, `opus_48000_32`, `opus_48000_64`, etc.
|
|
93
|
+
|
|
94
|
+
**Note:** MP3 with 192kbps bitrate requires Creator tier or above. PCM with 44.1kHz sample rate requires Pro tier or above.
|
|
95
|
+
|
|
96
|
+
## Audio Handling
|
|
97
|
+
|
|
98
|
+
The SDK provides three main functions for handling generated audio:
|
|
99
|
+
|
|
100
|
+
### Play Audio
|
|
101
|
+
```python
|
|
102
|
+
from elevenlabs import play
|
|
103
|
+
|
|
104
|
+
# Play audio directly
|
|
105
|
+
play(audio)
|
|
106
|
+
|
|
107
|
+
# Play in Jupyter notebook
|
|
108
|
+
play(audio, notebook=True)
|
|
109
|
+
|
|
110
|
+
# Use alternative audio backend
|
|
111
|
+
play(audio, use_ffmpeg=False)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Save Audio
|
|
115
|
+
```python
|
|
116
|
+
from elevenlabs import save
|
|
117
|
+
|
|
118
|
+
save(audio, "output.mp3")
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Stream Audio
|
|
122
|
+
```python
|
|
123
|
+
from elevenlabs import stream
|
|
124
|
+
|
|
125
|
+
# For streamed audio
|
|
126
|
+
stream(audio_stream)
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Voice Management
|
|
130
|
+
|
|
131
|
+
### List Available Voices
|
|
132
|
+
```python
|
|
133
|
+
client = ElevenLabs(api_key="YOUR_API_KEY")
|
|
134
|
+
|
|
135
|
+
# Get all voices
|
|
136
|
+
response = client.voices.get_all()
|
|
137
|
+
print(response.voices)
|
|
138
|
+
|
|
139
|
+
# Search voices with pagination
|
|
140
|
+
response = client.voices.search()
|
|
141
|
+
print(response.voices)
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Voice Cloning
|
|
145
|
+
|
|
146
|
+
Clone a voice using audio samples:
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
client = ElevenLabs(api_key="YOUR_API_KEY")
|
|
150
|
+
|
|
151
|
+
voice = client.voices.ivc.create(
|
|
152
|
+
name="Alex",
|
|
153
|
+
description="An old American male voice with a slight hoarseness in his throat. Perfect for news",
|
|
154
|
+
files=["./sample_0.mp3", "./sample_1.mp3", "./sample_2.mp3"],
|
|
155
|
+
)
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
The `create` method accepts multiple audio file paths and optional parameters like `remove_background_noise` and `description`.
|
|
159
|
+
|
|
160
|
+
## Streaming Audio
|
|
161
|
+
|
|
162
|
+
Stream audio in real-time as it's being generated:
|
|
163
|
+
|
|
164
|
+
```python
|
|
165
|
+
from elevenlabs import stream
|
|
166
|
+
from elevenlabs.client import ElevenLabs
|
|
167
|
+
|
|
168
|
+
client = ElevenLabs()
|
|
169
|
+
|
|
170
|
+
audio_stream = client.text_to_speech.stream(
|
|
171
|
+
text="This is a test",
|
|
172
|
+
voice_id="JBFqnCBsd6RMkjVDRZzb",
|
|
173
|
+
model_id="eleven_multilingual_v2"
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
# Option 1: Play the streamed audio locally
|
|
177
|
+
stream(audio_stream)
|
|
178
|
+
|
|
179
|
+
# Option 2: Process the audio bytes manually
|
|
180
|
+
for chunk in audio_stream:
|
|
181
|
+
if isinstance(chunk, bytes):
|
|
182
|
+
print(chunk)
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
The `stream` method returns an iterator of bytes for real-time audio processing.
|
|
186
|
+
|
|
187
|
+
## Async Client
|
|
188
|
+
|
|
189
|
+
Use `AsyncElevenLabs` for asynchronous API calls:
|
|
190
|
+
|
|
191
|
+
```python
|
|
192
|
+
import asyncio
|
|
193
|
+
from elevenlabs.client import AsyncElevenLabs
|
|
194
|
+
|
|
195
|
+
client = AsyncElevenLabs(api_key="YOUR_API_KEY")
|
|
196
|
+
|
|
197
|
+
async def generate_speech():
|
|
198
|
+
audio = await client.text_to_speech.convert(
|
|
199
|
+
text="Hello, world!",
|
|
200
|
+
voice_id="JBFqnCBsd6RMkjVDRZzb",
|
|
201
|
+
model_id="eleven_multilingual_v2"
|
|
202
|
+
)
|
|
203
|
+
return audio
|
|
204
|
+
|
|
205
|
+
asyncio.run(generate_speech())
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Advanced Features
|
|
209
|
+
|
|
210
|
+
### Text-to-Speech with Timestamps
|
|
211
|
+
```python
|
|
212
|
+
response = client.text_to_speech.convert_with_timestamps(
|
|
213
|
+
voice_id="21m00Tcm4TlvDq8ikWAM",
|
|
214
|
+
text="This is a test for the API of ElevenLabs.",
|
|
215
|
+
)
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Voice Settings Customization
|
|
219
|
+
You can override voice settings for individual requests by passing a `VoiceSettings` object:
|
|
220
|
+
|
|
221
|
+
### Latency Optimization
|
|
222
|
+
Control streaming latency with the `optimize_streaming_latency` parameter (0-4, where 4 is maximum optimization):
|
|
223
|
+
|
|
224
|
+
## Error Handling
|
|
225
|
+
|
|
226
|
+
The SDK provides specific error types for different API responses:
|
|
227
|
+
|
|
228
|
+
## Useful Links
|
|
229
|
+
|
|
230
|
+
- **Documentation:** https://elevenlabs.io/docs/api-reference
|
|
231
|
+
- **Models:** https://elevenlabs.io/docs/models
|
|
232
|
+
- **GitHub Repository:** https://github.com/elevenlabs/elevenlabs-python
|
|
233
|
+
- **API Pricing:** https://elevenlabs.io/pricing
|
|
234
|
+
|
|
235
|
+
## Notes
|
|
236
|
+
|
|
237
|
+
- The SDK automatically handles API authentication when the `ELEVENLABS_API_KEY` environment variable is set
|
|
238
|
+
- Voice cloning requires an API key and appropriate subscription tier
|
|
239
|
+
- Some output formats and features require specific subscription tiers
|
|
240
|
+
- The SDK supports both synchronous and asynchronous operations
|
|
241
|
+
- Audio files are returned as byte iterators for efficient memory usage
|
|
242
|
+
|
|
243
|
+
### Citations
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
pip install elevenlabs
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
1. **Eleven Multilingual v2** (`eleven_multilingual_v2`)
|
|
250
|
+
|
|
251
|
+
- Excels in stability, language diversity, and accent accuracy
|
|
252
|
+
- Supports 29 languages
|
|
253
|
+
- Recommended for most use cases
|
|
254
|
+
|
|
255
|
+
2. **Eleven Flash v2.5** (`eleven_flash_v2_5`)
|
|
256
|
+
|
|
257
|
+
- Ultra-low latency
|
|
258
|
+
- Supports 32 languages
|
|
259
|
+
- Faster model, 50% lower price per character
|
|
260
|
+
|
|
261
|
+
2. **Eleven Turbo v2.5** (`eleven_turbo_v2_5`)
|
|
262
|
+
|
|
263
|
+
- Good balance of quality and latency
|
|
264
|
+
- Ideal for developer use cases where speed is crucial
|
|
265
|
+
- Supports 32 languages
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
```python
|
|
269
|
+
from dotenv import load_dotenv
|
|
270
|
+
from elevenlabs.client import ElevenLabs
|
|
271
|
+
from elevenlabs import play
|
|
272
|
+
|
|
273
|
+
load_dotenv()
|
|
274
|
+
|
|
275
|
+
client = ElevenLabs()
|
|
276
|
+
|
|
277
|
+
audio = client.text_to_speech.convert(
|
|
278
|
+
text="The first move is what sets everything in motion.",
|
|
279
|
+
voice_id="JBFqnCBsd6RMkjVDRZzb",
|
|
280
|
+
model_id="eleven_multilingual_v2",
|
|
281
|
+
output_format="mp3_44100_128",
|
|
282
|
+
)
|
|
283
|
+
|
|
284
|
+
play(audio)
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
```python
|
|
288
|
+
from elevenlabs.client import ElevenLabs
|
|
289
|
+
|
|
290
|
+
client = ElevenLabs(
|
|
291
|
+
api_key="YOUR_API_KEY",
|
|
292
|
+
)
|
|
293
|
+
|
|
294
|
+
response = client.voices.search()
|
|
295
|
+
print(response.voices)
|
|
296
|
+
|
|
297
|
+
```python
|
|
298
|
+
from elevenlabs.client import ElevenLabs
|
|
299
|
+
from elevenlabs import play
|
|
300
|
+
|
|
301
|
+
client = ElevenLabs(
|
|
302
|
+
api_key="YOUR_API_KEY",
|
|
303
|
+
)
|
|
304
|
+
|
|
305
|
+
voice = client.voices.ivc.create(
|
|
306
|
+
name="Alex",
|
|
307
|
+
description="An old American male voice with a slight hoarseness in his throat. Perfect for news", # Optional
|
|
308
|
+
files=["./sample_0.mp3", "./sample_1.mp3", "./sample_2.mp3"],
|
|
309
|
+
)
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
```python
|
|
313
|
+
from elevenlabs import stream
|
|
314
|
+
from elevenlabs.client import ElevenLabs
|
|
315
|
+
|
|
316
|
+
client = ElevenLabs()
|
|
317
|
+
|
|
318
|
+
audio_stream = client.text_to_speech.stream(
|
|
319
|
+
text="This is a test",
|
|
320
|
+
voice_id="JBFqnCBsd6RMkjVDRZzb",
|
|
321
|
+
model_id="eleven_multilingual_v2"
|
|
322
|
+
)
|
|
323
|
+
|
|
324
|
+
# option 1: play the streamed audio locally
|
|
325
|
+
stream(audio_stream)
|
|
326
|
+
|
|
327
|
+
# option 2: process the audio bytes manually
|
|
328
|
+
for chunk in audio_stream:
|
|
329
|
+
if isinstance(chunk, bytes):
|
|
330
|
+
print(chunk)
|
|
331
|
+
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
```python
|
|
335
|
+
import asyncio
|
|
336
|
+
|
|
337
|
+
from elevenlabs.client import AsyncElevenLabs
|
|
338
|
+
|
|
339
|
+
eleven = AsyncElevenLabs(
|
|
340
|
+
api_key="MY_API_KEY"
|
|
341
|
+
)
|
|
342
|
+
|
|
343
|
+
async def print_models() -> None:
|
|
344
|
+
models = await eleven.models.list()
|
|
345
|
+
print(models)
|
|
346
|
+
|
|
347
|
+
asyncio.run(print_models())
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
```python
|
|
351
|
+
from .errors import BadRequestError, ForbiddenError, NotFoundError, TooEarlyError, UnprocessableEntityError
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
```python
|
|
355
|
+
from .client import AsyncElevenLabs, ElevenLabs
|
|
356
|
+
from .environment import ElevenLabsEnvironment
|
|
357
|
+
from .history import HistoryListRequestSource
|
|
358
|
+
from .play import play, save, stream
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
```python
|
|
362
|
+
def __init__(
|
|
363
|
+
self,
|
|
364
|
+
*,
|
|
365
|
+
base_url: typing.Optional[str] = None,
|
|
366
|
+
environment: ElevenLabsEnvironment = ElevenLabsEnvironment.PRODUCTION,
|
|
367
|
+
api_key: typing.Optional[str] = os.getenv("ELEVENLABS_API_KEY"),
|
|
368
|
+
timeout: typing.Optional[float] = 60,
|
|
369
|
+
httpx_client: typing.Optional[httpx.Client] = None
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
```python
|
|
373
|
+
def convert(
|
|
374
|
+
self,
|
|
375
|
+
voice_id: str,
|
|
376
|
+
*,
|
|
377
|
+
text: str,
|
|
378
|
+
enable_logging: typing.Optional[bool] = None,
|
|
379
|
+
optimize_streaming_latency: typing.Optional[int] = None,
|
|
380
|
+
output_format: typing.Optional[TextToSpeechConvertRequestOutputFormat] = None,
|
|
381
|
+
model_id: typing.Optional[str] = OMIT,
|
|
382
|
+
language_code: typing.Optional[str] = OMIT,
|
|
383
|
+
voice_settings: typing.Optional[VoiceSettings] = OMIT,
|
|
384
|
+
pronunciation_dictionary_locators: typing.Optional[
|
|
385
|
+
typing.Sequence[PronunciationDictionaryVersionLocator]
|
|
386
|
+
] = OMIT,
|
|
387
|
+
seed: typing.Optional[int] = OMIT,
|
|
388
|
+
previous_text: typing.Optional[str] = OMIT,
|
|
389
|
+
next_text: typing.Optional[str] = OMIT,
|
|
390
|
+
previous_request_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
391
|
+
next_request_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
392
|
+
use_pvc_as_ivc: typing.Optional[bool] = OMIT,
|
|
393
|
+
apply_text_normalization: typing.Optional[
|
|
394
|
+
BodyTextToSpeechV1TextToSpeechVoiceIdPostApplyTextNormalization
|
|
395
|
+
] = OMIT,
|
|
396
|
+
apply_language_text_normalization: typing.Optional[bool] = OMIT,
|
|
397
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
398
|
+
) -> typing.Iterator[bytes]:
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
```python
|
|
402
|
+
optimize_streaming_latency : typing.Optional[int]
|
|
403
|
+
You can turn on latency optimizations at some cost of quality. The best possible final latency varies by model. Possible values:
|
|
404
|
+
0 - default mode (no latency optimizations)
|
|
405
|
+
1 - normal latency optimizations (about 50% of possible latency improvement of option 3)
|
|
406
|
+
2 - strong latency optimizations (about 75% of possible latency improvement of option 3)
|
|
407
|
+
3 - max latency optimizations
|
|
408
|
+
4 - max latency optimizations, but also with text normalizer turned off for even more latency savings (best latency, but can mispronounce eg numbers and dates).
|
|
409
|
+
|
|
410
|
+
Defaults to None.
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
```python
|
|
414
|
+
output_format : typing.Optional[TextToSpeechConvertRequestOutputFormat]
|
|
415
|
+
Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs.
|
|
416
|
+
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
```python
|
|
420
|
+
voice_settings : typing.Optional[VoiceSettings]
|
|
421
|
+
Voice settings overriding stored settings for the given voice. They are applied only on the given request.
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
```python
|
|
425
|
+
def convert_with_timestamps(
|
|
426
|
+
self,
|
|
427
|
+
voice_id: str,
|
|
428
|
+
*,
|
|
429
|
+
text: str,
|
|
430
|
+
enable_logging: typing.Optional[bool] = None,
|
|
431
|
+
optimize_streaming_latency: typing.Optional[int] = None,
|
|
432
|
+
output_format: typing.Optional[TextToSpeechConvertWithTimestampsRequestOutputFormat] = None,
|
|
433
|
+
model_id: typing.Optional[str] = OMIT,
|
|
434
|
+
language_code: typing.Optional[str] = OMIT,
|
|
435
|
+
voice_settings: typing.Optional[VoiceSettings] = OMIT,
|
|
436
|
+
pronunciation_dictionary_locators: typing.Optional[
|
|
437
|
+
typing.Sequence[PronunciationDictionaryVersionLocator]
|
|
438
|
+
] = OMIT,
|
|
439
|
+
seed: typing.Optional[int] = OMIT,
|
|
440
|
+
previous_text: typing.Optional[str] = OMIT,
|
|
441
|
+
next_text: typing.Optional[str] = OMIT,
|
|
442
|
+
previous_request_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
443
|
+
next_request_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
444
|
+
use_pvc_as_ivc: typing.Optional[bool] = OMIT,
|
|
445
|
+
apply_text_normalization: typing.Optional[
|
|
446
|
+
BodyTextToSpeechWithTimestampsV1TextToSpeechVoiceIdWithTimestampsPostApplyTextNormalization
|
|
447
|
+
] = OMIT,
|
|
448
|
+
apply_language_text_normalization: typing.Optional[bool] = OMIT,
|
|
449
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
450
|
+
) -> AudioWithTimestampsResponse:
|
|
451
|
+
"""
|
|
452
|
+
Generate speech from text with precise character-level timing information for audio-text synchronization.
|
|
453
|
+
|
|
454
|
+
Parameters
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
```python
|
|
458
|
+
def stream(
|
|
459
|
+
self,
|
|
460
|
+
voice_id: str,
|
|
461
|
+
*,
|
|
462
|
+
text: str,
|
|
463
|
+
enable_logging: typing.Optional[bool] = None,
|
|
464
|
+
optimize_streaming_latency: typing.Optional[int] = None,
|
|
465
|
+
output_format: typing.Optional[TextToSpeechStreamRequestOutputFormat] = None,
|
|
466
|
+
model_id: typing.Optional[str] = OMIT,
|
|
467
|
+
language_code: typing.Optional[str] = OMIT,
|
|
468
|
+
voice_settings: typing.Optional[VoiceSettings] = OMIT,
|
|
469
|
+
pronunciation_dictionary_locators: typing.Optional[
|
|
470
|
+
typing.Sequence[PronunciationDictionaryVersionLocator]
|
|
471
|
+
] = OMIT,
|
|
472
|
+
seed: typing.Optional[int] = OMIT,
|
|
473
|
+
previous_text: typing.Optional[str] = OMIT,
|
|
474
|
+
next_text: typing.Optional[str] = OMIT,
|
|
475
|
+
previous_request_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
476
|
+
next_request_ids: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
477
|
+
use_pvc_as_ivc: typing.Optional[bool] = OMIT,
|
|
478
|
+
apply_text_normalization: typing.Optional[
|
|
479
|
+
BodyTextToSpeechStreamingV1TextToSpeechVoiceIdStreamPostApplyTextNormalization
|
|
480
|
+
] = OMIT,
|
|
481
|
+
apply_language_text_normalization: typing.Optional[bool] = OMIT,
|
|
482
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
483
|
+
) -> typing.Iterator[bytes]:
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
```python
|
|
487
|
+
TextToSpeechStreamRequestOutputFormat = typing.Union[
|
|
488
|
+
typing.Literal[
|
|
489
|
+
"mp3_22050_32",
|
|
490
|
+
"mp3_44100_32",
|
|
491
|
+
"mp3_44100_64",
|
|
492
|
+
"mp3_44100_96",
|
|
493
|
+
"mp3_44100_128",
|
|
494
|
+
"mp3_44100_192",
|
|
495
|
+
"pcm_8000",
|
|
496
|
+
"pcm_16000",
|
|
497
|
+
"pcm_22050",
|
|
498
|
+
"pcm_24000",
|
|
499
|
+
"pcm_44100",
|
|
500
|
+
"pcm_48000",
|
|
501
|
+
"ulaw_8000",
|
|
502
|
+
"alaw_8000",
|
|
503
|
+
"opus_48000_32",
|
|
504
|
+
"opus_48000_64",
|
|
505
|
+
"opus_48000_96",
|
|
506
|
+
"opus_48000_128",
|
|
507
|
+
"opus_48000_192",
|
|
508
|
+
],
|
|
509
|
+
typing.Any,
|
|
510
|
+
]
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
```python
|
|
514
|
+
def play(
|
|
515
|
+
audio: Union[bytes, Iterator[bytes]],
|
|
516
|
+
notebook: bool = False,
|
|
517
|
+
use_ffmpeg: bool = True
|
|
518
|
+
) -> None:
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
```python
|
|
522
|
+
def save(audio: Union[bytes, Iterator[bytes]], filename: str) -> None:
|
|
523
|
+
if isinstance(audio, Iterator):
|
|
524
|
+
audio = b"".join(audio)
|
|
525
|
+
with open(filename, "wb") as f:
|
|
526
|
+
f.write(audio)
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
```python
|
|
530
|
+
def stream(audio_stream: Iterator[bytes]) -> bytes:
|
|
531
|
+
if not is_installed("mpv"):
|
|
532
|
+
message = (
|
|
533
|
+
"mpv not found, necessary to stream audio. "
|
|
534
|
+
"On mac you can install it with 'brew install mpv'. "
|
|
535
|
+
"On linux and windows you can install it from https://mpv.io/"
|
|
536
|
+
)
|
|
537
|
+
raise ValueError(message)
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
src/elevenlabs/voices/ivc/client.py
|
|
541
|
+
```python
|
|
542
|
+
def create(
|
|
543
|
+
self,
|
|
544
|
+
*,
|
|
545
|
+
name: str,
|
|
546
|
+
files: typing.List[core.File],
|
|
547
|
+
remove_background_noise: typing.Optional[bool] = OMIT,
|
|
548
|
+
description: typing.Optional[str] = OMIT,
|
|
549
|
+
labels: typing.Optional[str] = OMIT,
|
|
550
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
551
|
+
) -> AddVoiceIvcResponseModel:
|
|
552
|
+
```
|