universal-mcp-applications 0.1.1__py3-none-any.whl → 0.1.3__py3-none-any.whl
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.
- universal_mcp/applications/airtable/app.py +1 -0
- universal_mcp/applications/apollo/app.py +1 -0
- universal_mcp/applications/{aws-s3 → aws_s3}/app.py +4 -5
- universal_mcp/applications/bill/app.py +3 -3
- universal_mcp/applications/box/app.py +2 -6
- universal_mcp/applications/braze/app.py +2 -6
- universal_mcp/applications/cal_com_v2/__init__.py +1 -0
- universal_mcp/applications/{cal-com-v2 → cal_com_v2}/app.py +138 -182
- universal_mcp/applications/clickup/app.py +2 -2
- universal_mcp/applications/confluence/app.py +1 -0
- universal_mcp/applications/contentful/app.py +8 -19
- universal_mcp/applications/digitalocean/app.py +9 -27
- universal_mcp/applications/{domain-checker → domain_checker}/app.py +2 -1
- universal_mcp/applications/elevenlabs/app.py +98 -3188
- universal_mcp/applications/falai/app.py +1 -0
- universal_mcp/applications/file_system/__init__.py +1 -0
- universal_mcp/applications/file_system/app.py +96 -0
- universal_mcp/applications/fireflies/app.py +4 -3
- universal_mcp/applications/fpl/app.py +1 -0
- universal_mcp/applications/fpl/utils/fixtures.py +1 -1
- universal_mcp/applications/fpl/utils/helper.py +1 -1
- universal_mcp/applications/fpl/utils/position_utils.py +0 -1
- universal_mcp/applications/{ghost-content → ghost_content}/app.py +2 -1
- universal_mcp/applications/github/app.py +4 -3
- universal_mcp/applications/{google-calendar → google_calendar}/app.py +2 -1
- universal_mcp/applications/{google-docs → google_docs}/app.py +1 -1
- universal_mcp/applications/{google-drive → google_drive}/app.py +2 -1
- universal_mcp/applications/google_gemini/app.py +183 -0
- universal_mcp/applications/{google-mail → google_mail}/app.py +2 -1
- universal_mcp/applications/{google-searchconsole → google_searchconsole}/app.py +1 -1
- universal_mcp/applications/{google-sheet → google_sheet}/app.py +3 -2
- universal_mcp/applications/google_sheet/helper.py +385 -0
- universal_mcp/applications/hashnode/app.py +2 -1
- universal_mcp/applications/{http-tools → http_tools}/app.py +2 -1
- universal_mcp/applications/hubspot/app.py +16 -2
- universal_mcp/applications/jira/app.py +7 -18
- universal_mcp/applications/markitdown/app.py +2 -3
- universal_mcp/applications/{ms-teams → ms_teams}/app.py +1 -1
- universal_mcp/applications/openai/app.py +2 -3
- universal_mcp/applications/outlook/app.py +1 -3
- universal_mcp/applications/pipedrive/app.py +2 -6
- universal_mcp/applications/reddit/app.py +1 -0
- universal_mcp/applications/replicate/app.py +3 -3
- universal_mcp/applications/resend/app.py +1 -2
- universal_mcp/applications/rocketlane/app.py +1 -0
- universal_mcp/applications/semrush/app.py +478 -1467
- universal_mcp/applications/sentry/README.md +20 -20
- universal_mcp/applications/sentry/app.py +40 -40
- universal_mcp/applications/serpapi/app.py +2 -2
- universal_mcp/applications/sharepoint/app.py +2 -1
- universal_mcp/applications/shopify/app.py +1 -0
- universal_mcp/applications/slack/app.py +3 -3
- universal_mcp/applications/trello/app.py +9 -27
- universal_mcp/applications/twilio/__init__.py +1 -0
- universal_mcp/applications/{twillo → twilio}/app.py +2 -2
- universal_mcp/applications/twitter/README.md +1 -1
- universal_mcp/applications/twitter/api_segments/dm_conversations_api.py +2 -2
- universal_mcp/applications/twitter/api_segments/lists_api.py +1 -1
- universal_mcp/applications/unipile/app.py +5 -1
- universal_mcp/applications/whatsapp/app.py +18 -17
- universal_mcp/applications/whatsapp/audio.py +110 -0
- universal_mcp/applications/whatsapp/whatsapp.py +398 -0
- universal_mcp/applications/{whatsapp-business → whatsapp_business}/app.py +1 -1
- universal_mcp/applications/youtube/app.py +195 -191
- universal_mcp/applications/zenquotes/app.py +1 -1
- {universal_mcp_applications-0.1.1.dist-info → universal_mcp_applications-0.1.3.dist-info}/METADATA +4 -2
- {universal_mcp_applications-0.1.1.dist-info → universal_mcp_applications-0.1.3.dist-info}/RECORD +97 -95
- universal_mcp/applications/cal-com-v2/__init__.py +0 -1
- universal_mcp/applications/google-ads/__init__.py +0 -1
- universal_mcp/applications/google-ads/app.py +0 -23
- universal_mcp/applications/google-gemini/app.py +0 -663
- universal_mcp/applications/twillo/README.md +0 -0
- universal_mcp/applications/twillo/__init__.py +0 -1
- /universal_mcp/applications/{aws-s3 → aws_s3}/README.md +0 -0
- /universal_mcp/applications/{aws-s3 → aws_s3}/__init__.py +0 -0
- /universal_mcp/applications/{cal-com-v2 → cal_com_v2}/README.md +0 -0
- /universal_mcp/applications/{domain-checker → domain_checker}/README.md +0 -0
- /universal_mcp/applications/{domain-checker → domain_checker}/__init__.py +0 -0
- /universal_mcp/applications/{ghost-content → ghost_content}/README.md +0 -0
- /universal_mcp/applications/{ghost-content → ghost_content}/__init__.py +0 -0
- /universal_mcp/applications/{google-calendar → google_calendar}/README.md +0 -0
- /universal_mcp/applications/{google-calendar → google_calendar}/__init__.py +0 -0
- /universal_mcp/applications/{google-docs → google_docs}/README.md +0 -0
- /universal_mcp/applications/{google-docs → google_docs}/__init__.py +0 -0
- /universal_mcp/applications/{google-drive → google_drive}/README.md +0 -0
- /universal_mcp/applications/{google-drive → google_drive}/__init__.py +0 -0
- /universal_mcp/applications/{google-gemini → google_gemini}/README.md +0 -0
- /universal_mcp/applications/{google-gemini → google_gemini}/__init__.py +0 -0
- /universal_mcp/applications/{google-mail → google_mail}/README.md +0 -0
- /universal_mcp/applications/{google-mail → google_mail}/__init__.py +0 -0
- /universal_mcp/applications/{google-searchconsole → google_searchconsole}/README.md +0 -0
- /universal_mcp/applications/{google-searchconsole → google_searchconsole}/__init__.py +0 -0
- /universal_mcp/applications/{google-sheet → google_sheet}/README.md +0 -0
- /universal_mcp/applications/{google-sheet → google_sheet}/__init__.py +0 -0
- /universal_mcp/applications/{http-tools → http_tools}/README.md +0 -0
- /universal_mcp/applications/{http-tools → http_tools}/__init__.py +0 -0
- /universal_mcp/applications/{ms-teams → ms_teams}/README.md +0 -0
- /universal_mcp/applications/{ms-teams → ms_teams}/__init__.py +0 -0
- /universal_mcp/applications/{google-ads → twilio}/README.md +0 -0
- /universal_mcp/applications/{whatsapp-business → whatsapp_business}/README.md +0 -0
- /universal_mcp/applications/{whatsapp-business → whatsapp_business}/__init__.py +0 -0
- {universal_mcp_applications-0.1.1.dist-info → universal_mcp_applications-0.1.3.dist-info}/WHEEL +0 -0
- {universal_mcp_applications-0.1.1.dist-info → universal_mcp_applications-0.1.3.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import uuid
|
|
2
|
+
from io import BytesIO
|
|
2
3
|
|
|
4
|
+
import requests
|
|
5
|
+
|
|
6
|
+
from elevenlabs import ElevenLabs
|
|
3
7
|
from universal_mcp.applications.application import APIApplication
|
|
8
|
+
from universal_mcp.applications.file_system.app import FileSystemApp
|
|
9
|
+
from universal_mcp.exceptions import NotAuthorizedError
|
|
4
10
|
from universal_mcp.integrations import Integration
|
|
5
11
|
|
|
6
12
|
|
|
@@ -9,3227 +15,131 @@ class ElevenlabsApp(APIApplication):
|
|
|
9
15
|
super().__init__(name="elevenlabs", integration=integration, **kwargs)
|
|
10
16
|
self.base_url = "https://api.elevenlabs.io"
|
|
11
17
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
Tags:
|
|
30
|
-
History, important
|
|
31
|
-
"""
|
|
32
|
-
url = f"{self.base_url}/v1/history"
|
|
33
|
-
query_params = {
|
|
34
|
-
k: v
|
|
35
|
-
for k, v in [("page_size", page_size), ("voice_id", voice_id)]
|
|
36
|
-
if v is not None
|
|
37
|
-
}
|
|
38
|
-
response = self._get(url, params=query_params)
|
|
39
|
-
response.raise_for_status()
|
|
40
|
-
if (
|
|
41
|
-
response.status_code == 204
|
|
42
|
-
or not response.content
|
|
43
|
-
or not response.text.strip()
|
|
44
|
-
):
|
|
45
|
-
return None
|
|
46
|
-
try:
|
|
47
|
-
return response.json()
|
|
48
|
-
except ValueError:
|
|
49
|
-
return None
|
|
50
|
-
|
|
51
|
-
def get_history_item_by_id(self, history_item_id: str) -> dict[str, Any]:
|
|
52
|
-
"""
|
|
53
|
-
Retrieves a specific history item by its identifier using the API defined at "/v1/history/{history_item_id}" with the GET method.
|
|
54
|
-
|
|
55
|
-
Args:
|
|
56
|
-
history_item_id (string): history_item_id
|
|
57
|
-
|
|
58
|
-
Returns:
|
|
59
|
-
dict[str, Any]: Success / Success
|
|
60
|
-
|
|
61
|
-
Raises:
|
|
62
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
63
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
64
|
-
|
|
65
|
-
Tags:
|
|
66
|
-
History, important
|
|
67
|
-
"""
|
|
68
|
-
if history_item_id is None:
|
|
69
|
-
raise ValueError("Missing required parameter 'history_item_id'.")
|
|
70
|
-
url = f"{self.base_url}/v1/history/{history_item_id}"
|
|
71
|
-
query_params = {}
|
|
72
|
-
response = self._get(url, params=query_params)
|
|
73
|
-
response.raise_for_status()
|
|
74
|
-
if (
|
|
75
|
-
response.status_code == 204
|
|
76
|
-
or not response.content
|
|
77
|
-
or not response.text.strip()
|
|
78
|
-
):
|
|
79
|
-
return None
|
|
80
|
-
try:
|
|
81
|
-
return response.json()
|
|
82
|
-
except ValueError:
|
|
83
|
-
return None
|
|
84
|
-
|
|
85
|
-
def delete_history_item(self, history_item_id: str) -> dict[str, Any]:
|
|
86
|
-
"""
|
|
87
|
-
Deletes a specific history item identified by its ID using the DELETE method.
|
|
88
|
-
|
|
89
|
-
Args:
|
|
90
|
-
history_item_id (string): history_item_id
|
|
91
|
-
|
|
92
|
-
Returns:
|
|
93
|
-
dict[str, Any]: Success / Success
|
|
94
|
-
|
|
95
|
-
Raises:
|
|
96
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
97
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
98
|
-
|
|
99
|
-
Tags:
|
|
100
|
-
History, important
|
|
101
|
-
"""
|
|
102
|
-
if history_item_id is None:
|
|
103
|
-
raise ValueError("Missing required parameter 'history_item_id'.")
|
|
104
|
-
url = f"{self.base_url}/v1/history/{history_item_id}"
|
|
105
|
-
query_params = {}
|
|
106
|
-
response = self._delete(url, params=query_params)
|
|
107
|
-
response.raise_for_status()
|
|
108
|
-
if (
|
|
109
|
-
response.status_code == 204
|
|
110
|
-
or not response.content
|
|
111
|
-
or not response.text.strip()
|
|
112
|
-
):
|
|
113
|
-
return None
|
|
114
|
-
try:
|
|
115
|
-
return response.json()
|
|
116
|
-
except ValueError:
|
|
117
|
-
return None
|
|
118
|
-
|
|
119
|
-
def get_audio_from_history_item(self, history_item_id: str) -> Any:
|
|
120
|
-
"""
|
|
121
|
-
Retrieves audio data for a specific history item identified by `{history_item_id}` using the `GET` method at the `/v1/history/{history_item_id}/audio` endpoint.
|
|
122
|
-
|
|
123
|
-
Args:
|
|
124
|
-
history_item_id (string): history_item_id
|
|
125
|
-
|
|
126
|
-
Returns:
|
|
127
|
-
Any: Success
|
|
128
|
-
|
|
129
|
-
Raises:
|
|
130
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
131
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
132
|
-
|
|
133
|
-
Tags:
|
|
134
|
-
History
|
|
135
|
-
"""
|
|
136
|
-
if history_item_id is None:
|
|
137
|
-
raise ValueError("Missing required parameter 'history_item_id'.")
|
|
138
|
-
url = f"{self.base_url}/v1/history/{history_item_id}/audio"
|
|
139
|
-
query_params = {}
|
|
140
|
-
response = self._get(url, params=query_params)
|
|
141
|
-
response.raise_for_status()
|
|
142
|
-
if (
|
|
143
|
-
response.status_code == 204
|
|
144
|
-
or not response.content
|
|
145
|
-
or not response.text.strip()
|
|
146
|
-
):
|
|
147
|
-
return None
|
|
148
|
-
try:
|
|
149
|
-
return response.json()
|
|
150
|
-
except ValueError:
|
|
151
|
-
return None
|
|
152
|
-
|
|
153
|
-
def download_history_items(
|
|
154
|
-
self, history_item_ids: list[str] | None = None
|
|
155
|
-
) -> Any:
|
|
156
|
-
"""
|
|
157
|
-
Initiates a historical data download process and returns a success status upon completion.
|
|
158
|
-
|
|
159
|
-
Args:
|
|
160
|
-
history_item_ids (array): history_item_ids Example: "['history_item_ids', 'history_item_ids']".
|
|
161
|
-
|
|
162
|
-
Returns:
|
|
163
|
-
Any: Success / Success
|
|
164
|
-
|
|
165
|
-
Raises:
|
|
166
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
167
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
168
|
-
|
|
169
|
-
Tags:
|
|
170
|
-
History
|
|
171
|
-
"""
|
|
172
|
-
request_body_data = None
|
|
173
|
-
request_body_data = {
|
|
174
|
-
"history_item_ids": history_item_ids,
|
|
175
|
-
}
|
|
176
|
-
request_body_data = {
|
|
177
|
-
k: v for k, v in request_body_data.items() if v is not None
|
|
178
|
-
}
|
|
179
|
-
url = f"{self.base_url}/v1/history/download"
|
|
180
|
-
query_params = {}
|
|
181
|
-
response = self._post(
|
|
182
|
-
url,
|
|
183
|
-
data=request_body_data,
|
|
184
|
-
params=query_params,
|
|
185
|
-
content_type="application/json",
|
|
186
|
-
)
|
|
187
|
-
response.raise_for_status()
|
|
188
|
-
if (
|
|
189
|
-
response.status_code == 204
|
|
190
|
-
or not response.content
|
|
191
|
-
or not response.text.strip()
|
|
192
|
-
):
|
|
193
|
-
return None
|
|
194
|
-
try:
|
|
195
|
-
return response.json()
|
|
196
|
-
except ValueError:
|
|
197
|
-
return None
|
|
198
|
-
|
|
199
|
-
def delete_sample(self, voice_id: str, sample_id: str) -> dict[str, Any]:
|
|
200
|
-
"""
|
|
201
|
-
Deletes a specific voice sample identified by the `sample_id` from a voice with the given `voice_id` using the DELETE method.
|
|
202
|
-
|
|
203
|
-
Args:
|
|
204
|
-
voice_id (string): voice_id
|
|
205
|
-
sample_id (string): sample_id
|
|
206
|
-
|
|
207
|
-
Returns:
|
|
208
|
-
dict[str, Any]: Success / Success
|
|
209
|
-
|
|
210
|
-
Raises:
|
|
211
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
212
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
213
|
-
|
|
214
|
-
Tags:
|
|
215
|
-
Samples
|
|
216
|
-
"""
|
|
217
|
-
if voice_id is None:
|
|
218
|
-
raise ValueError("Missing required parameter 'voice_id'.")
|
|
219
|
-
if sample_id is None:
|
|
220
|
-
raise ValueError("Missing required parameter 'sample_id'.")
|
|
221
|
-
url = f"{self.base_url}/v1/voices/{voice_id}/samples/{sample_id}"
|
|
222
|
-
query_params = {}
|
|
223
|
-
response = self._delete(url, params=query_params)
|
|
224
|
-
response.raise_for_status()
|
|
225
|
-
if (
|
|
226
|
-
response.status_code == 204
|
|
227
|
-
or not response.content
|
|
228
|
-
or not response.text.strip()
|
|
229
|
-
):
|
|
230
|
-
return None
|
|
231
|
-
try:
|
|
232
|
-
return response.json()
|
|
233
|
-
except ValueError:
|
|
234
|
-
return None
|
|
235
|
-
|
|
236
|
-
def get_audio_from_sample(self, voice_id: str, sample_id: str) -> Any:
|
|
237
|
-
"""
|
|
238
|
-
Retrieves the audio file for a specific sample associated with a given voice using the specified voice_id and sample_id.
|
|
239
|
-
|
|
240
|
-
Args:
|
|
241
|
-
voice_id (string): voice_id
|
|
242
|
-
sample_id (string): sample_id
|
|
243
|
-
|
|
244
|
-
Returns:
|
|
245
|
-
Any: Success
|
|
246
|
-
|
|
247
|
-
Raises:
|
|
248
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
249
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
250
|
-
|
|
251
|
-
Tags:
|
|
252
|
-
Samples
|
|
253
|
-
"""
|
|
254
|
-
if voice_id is None:
|
|
255
|
-
raise ValueError("Missing required parameter 'voice_id'.")
|
|
256
|
-
if sample_id is None:
|
|
257
|
-
raise ValueError("Missing required parameter 'sample_id'.")
|
|
258
|
-
url = f"{self.base_url}/v1/voices/{voice_id}/samples/{sample_id}/audio"
|
|
259
|
-
query_params = {}
|
|
260
|
-
response = self._get(url, params=query_params)
|
|
261
|
-
response.raise_for_status()
|
|
262
|
-
if (
|
|
263
|
-
response.status_code == 204
|
|
264
|
-
or not response.content
|
|
265
|
-
or not response.text.strip()
|
|
266
|
-
):
|
|
267
|
-
return None
|
|
268
|
-
try:
|
|
269
|
-
return response.json()
|
|
270
|
-
except ValueError:
|
|
271
|
-
return None
|
|
272
|
-
|
|
273
|
-
def convert(
|
|
274
|
-
self,
|
|
275
|
-
voice_id: str,
|
|
276
|
-
optimize_streaming_latency: str | None = None,
|
|
277
|
-
output_format: str | None = None,
|
|
278
|
-
text: str | None = None,
|
|
279
|
-
voice_settings: dict[str, Any] | None = None,
|
|
280
|
-
) -> Any:
|
|
281
|
-
"""
|
|
282
|
-
Converts text into speech using a specified voice, allowing for optimization of streaming latency and selection of output format.
|
|
283
|
-
|
|
284
|
-
Args:
|
|
285
|
-
voice_id (string): voice_id
|
|
286
|
-
optimize_streaming_latency (string): You can turn on latency optimizations at some cost of quality. The best possible final latency varies by model. Example: '0'.
|
|
287
|
-
output_format (string): The output format of the generated audio. Example: 'mp3_22050_32'.
|
|
288
|
-
text (string): text Example: "It sure does, Jackie… My mama always said: “In Carolina, the air's so thick you can wear it!”".
|
|
289
|
-
voice_settings (object): voice_settings Example: {'similarity_boost': 0.75, 'stability': 0.5, 'style': 0}.
|
|
290
|
-
|
|
291
|
-
Returns:
|
|
292
|
-
Any: Success
|
|
293
|
-
|
|
294
|
-
Raises:
|
|
295
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
296
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
297
|
-
|
|
298
|
-
Tags:
|
|
299
|
-
Text To Speech
|
|
300
|
-
"""
|
|
301
|
-
if voice_id is None:
|
|
302
|
-
raise ValueError("Missing required parameter 'voice_id'.")
|
|
303
|
-
request_body_data = None
|
|
304
|
-
request_body_data = {
|
|
305
|
-
"text": text,
|
|
306
|
-
"voice_settings": voice_settings,
|
|
307
|
-
}
|
|
308
|
-
request_body_data = {
|
|
309
|
-
k: v for k, v in request_body_data.items() if v is not None
|
|
310
|
-
}
|
|
311
|
-
url = f"{self.base_url}/v1/text-to-speech/{voice_id}"
|
|
312
|
-
query_params = {
|
|
313
|
-
k: v
|
|
314
|
-
for k, v in [
|
|
315
|
-
("optimize_streaming_latency", optimize_streaming_latency),
|
|
316
|
-
("output_format", output_format),
|
|
317
|
-
]
|
|
318
|
-
if v is not None
|
|
319
|
-
}
|
|
320
|
-
response = self._post(
|
|
321
|
-
url,
|
|
322
|
-
data=request_body_data,
|
|
323
|
-
params=query_params,
|
|
324
|
-
content_type="application/json",
|
|
325
|
-
)
|
|
326
|
-
response.raise_for_status()
|
|
327
|
-
if (
|
|
328
|
-
response.status_code == 204
|
|
329
|
-
or not response.content
|
|
330
|
-
or not response.text.strip()
|
|
331
|
-
):
|
|
332
|
-
return None
|
|
333
|
-
try:
|
|
334
|
-
return response.json()
|
|
335
|
-
except ValueError:
|
|
336
|
-
return None
|
|
337
|
-
|
|
338
|
-
def text_to_speech_with_timestamps(
|
|
339
|
-
self, voice_id: str, text: str | None = None
|
|
340
|
-
) -> dict[str, Any]:
|
|
341
|
-
"""
|
|
342
|
-
Generates speech from text with precise character or word-level timing information using the specified voice, supporting audio-text synchronization through timestamps.
|
|
343
|
-
|
|
344
|
-
Args:
|
|
345
|
-
voice_id (string): voice_id
|
|
346
|
-
text (string): text Example: 'text'.
|
|
347
|
-
|
|
348
|
-
Returns:
|
|
349
|
-
dict[str, Any]: Success / Success
|
|
350
|
-
|
|
351
|
-
Raises:
|
|
352
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
353
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
354
|
-
|
|
355
|
-
Tags:
|
|
356
|
-
Text To Speech
|
|
357
|
-
"""
|
|
358
|
-
if voice_id is None:
|
|
359
|
-
raise ValueError("Missing required parameter 'voice_id'.")
|
|
360
|
-
request_body_data = None
|
|
361
|
-
request_body_data = {
|
|
362
|
-
"text": text,
|
|
363
|
-
}
|
|
364
|
-
request_body_data = {
|
|
365
|
-
k: v for k, v in request_body_data.items() if v is not None
|
|
366
|
-
}
|
|
367
|
-
url = f"{self.base_url}/v1/text-to-speech/{voice_id}/with-timestamps"
|
|
368
|
-
query_params = {}
|
|
369
|
-
response = self._post(
|
|
370
|
-
url,
|
|
371
|
-
data=request_body_data,
|
|
372
|
-
params=query_params,
|
|
373
|
-
content_type="application/json",
|
|
374
|
-
)
|
|
375
|
-
response.raise_for_status()
|
|
376
|
-
if (
|
|
377
|
-
response.status_code == 204
|
|
378
|
-
or not response.content
|
|
379
|
-
or not response.text.strip()
|
|
380
|
-
):
|
|
381
|
-
return None
|
|
382
|
-
try:
|
|
383
|
-
return response.json()
|
|
384
|
-
except ValueError:
|
|
385
|
-
return None
|
|
386
|
-
|
|
387
|
-
def convert_as_stream(
|
|
388
|
-
self,
|
|
389
|
-
voice_id: str,
|
|
390
|
-
optimize_streaming_latency: str | None = None,
|
|
391
|
-
output_format: str | None = None,
|
|
392
|
-
text: str | None = None,
|
|
393
|
-
voice_settings: dict[str, Any] | None = None,
|
|
394
|
-
) -> Any:
|
|
395
|
-
"""
|
|
396
|
-
Converts text to speech stream using the specified voice ID with configurable latency and output format.
|
|
397
|
-
|
|
398
|
-
Args:
|
|
399
|
-
voice_id (string): voice_id
|
|
400
|
-
optimize_streaming_latency (string): You can turn on latency optimizations at some cost of quality. The best possible final latency varies by model. Example: '0'.
|
|
401
|
-
output_format (string): The output format of the generated audio. Example: 'mp3_22050_32'.
|
|
402
|
-
text (string): text Example: "It sure does, Jackie… My mama always said: “In Carolina, the air's so thick you can wear it!”".
|
|
403
|
-
voice_settings (object): voice_settings Example: {'similarity_boost': 0.3, 'stability': 0.1, 'style': 0.2}.
|
|
404
|
-
|
|
405
|
-
Returns:
|
|
406
|
-
Any: Success
|
|
407
|
-
|
|
408
|
-
Raises:
|
|
409
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
410
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
411
|
-
|
|
412
|
-
Tags:
|
|
413
|
-
Text To Speech
|
|
414
|
-
"""
|
|
415
|
-
if voice_id is None:
|
|
416
|
-
raise ValueError("Missing required parameter 'voice_id'.")
|
|
417
|
-
request_body_data = None
|
|
418
|
-
request_body_data = {
|
|
419
|
-
"text": text,
|
|
420
|
-
"voice_settings": voice_settings,
|
|
421
|
-
}
|
|
422
|
-
request_body_data = {
|
|
423
|
-
k: v for k, v in request_body_data.items() if v is not None
|
|
424
|
-
}
|
|
425
|
-
url = f"{self.base_url}/v1/text-to-speech/{voice_id}/stream"
|
|
426
|
-
query_params = {
|
|
427
|
-
k: v
|
|
428
|
-
for k, v in [
|
|
429
|
-
("optimize_streaming_latency", optimize_streaming_latency),
|
|
430
|
-
("output_format", output_format),
|
|
431
|
-
]
|
|
432
|
-
if v is not None
|
|
433
|
-
}
|
|
434
|
-
response = self._post(
|
|
435
|
-
url,
|
|
436
|
-
data=request_body_data,
|
|
437
|
-
params=query_params,
|
|
438
|
-
content_type="application/json",
|
|
439
|
-
)
|
|
440
|
-
response.raise_for_status()
|
|
441
|
-
if (
|
|
442
|
-
response.status_code == 204
|
|
443
|
-
or not response.content
|
|
444
|
-
or not response.text.strip()
|
|
445
|
-
):
|
|
446
|
-
return None
|
|
447
|
-
try:
|
|
448
|
-
return response.json()
|
|
449
|
-
except ValueError:
|
|
450
|
-
return None
|
|
451
|
-
|
|
452
|
-
def stream_text_with_timestamps(
|
|
453
|
-
self, voice_id: str, text: str | None = None
|
|
454
|
-
) -> Any:
|
|
455
|
-
"""
|
|
456
|
-
Converts text to speech using the specified voice ID, streaming the audio output with timestamps.
|
|
457
|
-
|
|
458
|
-
Args:
|
|
459
|
-
voice_id (string): voice_id
|
|
460
|
-
text (string): text Example: 'text'.
|
|
461
|
-
|
|
462
|
-
Returns:
|
|
463
|
-
Any: Success / Success
|
|
464
|
-
|
|
465
|
-
Raises:
|
|
466
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
467
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
468
|
-
|
|
469
|
-
Tags:
|
|
470
|
-
Text To Speech
|
|
471
|
-
"""
|
|
472
|
-
if voice_id is None:
|
|
473
|
-
raise ValueError("Missing required parameter 'voice_id'.")
|
|
474
|
-
request_body_data = None
|
|
475
|
-
request_body_data = {
|
|
476
|
-
"text": text,
|
|
477
|
-
}
|
|
478
|
-
request_body_data = {
|
|
479
|
-
k: v for k, v in request_body_data.items() if v is not None
|
|
480
|
-
}
|
|
481
|
-
url = f"{self.base_url}/v1/text-to-speech/{voice_id}/stream/with-timestamps"
|
|
482
|
-
query_params = {}
|
|
483
|
-
response = self._post(
|
|
484
|
-
url,
|
|
485
|
-
data=request_body_data,
|
|
486
|
-
params=query_params,
|
|
487
|
-
content_type="application/json",
|
|
488
|
-
)
|
|
489
|
-
response.raise_for_status()
|
|
490
|
-
if (
|
|
491
|
-
response.status_code == 204
|
|
492
|
-
or not response.content
|
|
493
|
-
or not response.text.strip()
|
|
494
|
-
):
|
|
495
|
-
return None
|
|
496
|
-
try:
|
|
497
|
-
return response.json()
|
|
498
|
-
except ValueError:
|
|
499
|
-
return None
|
|
500
|
-
|
|
501
|
-
def voice_generation_parameters(self) -> dict[str, Any]:
|
|
502
|
-
"""
|
|
503
|
-
Retrieves the parameters required for generating voice using the specified API endpoint.
|
|
504
|
-
|
|
505
|
-
Returns:
|
|
506
|
-
dict[str, Any]: Success / Success
|
|
507
|
-
|
|
508
|
-
Raises:
|
|
509
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
510
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
511
|
-
|
|
512
|
-
Tags:
|
|
513
|
-
Voice Generation
|
|
514
|
-
"""
|
|
515
|
-
url = f"{self.base_url}/v1/voice-generation/generate-voice/parameters"
|
|
516
|
-
query_params = {}
|
|
517
|
-
response = self._get(url, params=query_params)
|
|
518
|
-
response.raise_for_status()
|
|
519
|
-
if (
|
|
520
|
-
response.status_code == 204
|
|
521
|
-
or not response.content
|
|
522
|
-
or not response.text.strip()
|
|
523
|
-
):
|
|
524
|
-
return None
|
|
525
|
-
try:
|
|
526
|
-
return response.json()
|
|
527
|
-
except ValueError:
|
|
528
|
-
return None
|
|
529
|
-
|
|
530
|
-
def generate_arandom_voice(
|
|
18
|
+
@property
|
|
19
|
+
def client(self) -> ElevenLabs:
|
|
20
|
+
if self._client is None:
|
|
21
|
+
# credentials = self.integration.get_credentials()
|
|
22
|
+
# if not credentials:
|
|
23
|
+
# raise NotAuthorizedError("No credentials found")
|
|
24
|
+
api_key = "sk_50d565b590e5fecff99c12393b2ed7bc5d3dcb74a1fa6a68" # credentials.get("api_key") or credentials.get("API_KEY") or credentials.get("apiKey")
|
|
25
|
+
if not api_key:
|
|
26
|
+
raise NotAuthorizedError("No api key found")
|
|
27
|
+
self._client = ElevenLabs(api_key=api_key)
|
|
28
|
+
return self._client
|
|
29
|
+
|
|
30
|
+
# def get_voices(self):
|
|
31
|
+
# return self.client.voices.list_voices()
|
|
32
|
+
|
|
33
|
+
async def text_to_speech(
|
|
531
34
|
self,
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
text: str | None = None,
|
|
537
|
-
) -> Any:
|
|
35
|
+
text: str,
|
|
36
|
+
voice_id: str = "21m00Tcm4TlvDq8ikWAM",
|
|
37
|
+
model_id: str = "eleven_multilingual_v2",
|
|
38
|
+
) -> bytes:
|
|
538
39
|
"""
|
|
539
|
-
|
|
40
|
+
Converts text to speech using a specified voice.
|
|
540
41
|
|
|
541
42
|
Args:
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
43
|
+
text (str): The text to convert to speech.
|
|
44
|
+
voice_id (str): The ID of the voice to use.
|
|
45
|
+
model_id (str, optional): The model to use. Defaults to "eleven_multilingual_v2".
|
|
46
|
+
stability (float, optional): The stability of the voice.
|
|
47
|
+
similarity_boost (float, optional): The similarity boost of the voice.
|
|
547
48
|
|
|
548
49
|
Returns:
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
Raises:
|
|
552
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
553
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
554
|
-
|
|
50
|
+
bytes: The audio data.
|
|
51
|
+
|
|
555
52
|
Tags:
|
|
556
|
-
|
|
53
|
+
important
|
|
557
54
|
"""
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
"
|
|
563
|
-
"gender": gender,
|
|
564
|
-
"text": text,
|
|
565
|
-
}
|
|
566
|
-
request_body_data = {
|
|
567
|
-
k: v for k, v in request_body_data.items() if v is not None
|
|
568
|
-
}
|
|
569
|
-
url = f"{self.base_url}/v1/voice-generation/generate-voice"
|
|
570
|
-
query_params = {}
|
|
571
|
-
response = self._post(
|
|
572
|
-
url,
|
|
573
|
-
data=request_body_data,
|
|
574
|
-
params=query_params,
|
|
575
|
-
content_type="application/json",
|
|
55
|
+
audio_generator = self.client.text_to_speech.convert(
|
|
56
|
+
text=text,
|
|
57
|
+
voice_id=voice_id,
|
|
58
|
+
model_id=model_id,
|
|
59
|
+
output_format="mp3_44100_128",
|
|
576
60
|
)
|
|
577
|
-
response.raise_for_status()
|
|
578
|
-
if (
|
|
579
|
-
response.status_code == 204
|
|
580
|
-
or not response.content
|
|
581
|
-
or not response.text.strip()
|
|
582
|
-
):
|
|
583
|
-
return None
|
|
584
|
-
try:
|
|
585
|
-
return response.json()
|
|
586
|
-
except ValueError:
|
|
587
|
-
return None
|
|
588
61
|
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
voice_name: str | None = None,
|
|
594
|
-
) -> dict[str, Any]:
|
|
595
|
-
"""
|
|
596
|
-
Generates a custom voice using the provided parameters via the "/v1/voice-generation/create-voice" endpoint by sending a POST request, allowing users to create unique voice models.
|
|
597
|
-
|
|
598
|
-
Args:
|
|
599
|
-
generated_voice_id (string): generated_voice_id Example: 'generated_voice_id'.
|
|
600
|
-
voice_description (string): voice_description Example: 'voice_description'.
|
|
601
|
-
voice_name (string): voice_name Example: 'voice_name'.
|
|
62
|
+
# Collect all audio chunks from the generator
|
|
63
|
+
audio_data = b""
|
|
64
|
+
for chunk in audio_generator:
|
|
65
|
+
audio_data += chunk
|
|
602
66
|
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
Raises:
|
|
607
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
608
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
609
|
-
|
|
610
|
-
Tags:
|
|
611
|
-
Voice Generation
|
|
612
|
-
"""
|
|
613
|
-
request_body_data = None
|
|
614
|
-
request_body_data = {
|
|
615
|
-
"generated_voice_id": generated_voice_id,
|
|
616
|
-
"voice_description": voice_description,
|
|
617
|
-
"voice_name": voice_name,
|
|
618
|
-
}
|
|
619
|
-
request_body_data = {
|
|
620
|
-
k: v for k, v in request_body_data.items() if v is not None
|
|
621
|
-
}
|
|
622
|
-
url = f"{self.base_url}/v1/voice-generation/create-voice"
|
|
623
|
-
query_params = {}
|
|
624
|
-
response = self._post(
|
|
625
|
-
url,
|
|
626
|
-
data=request_body_data,
|
|
627
|
-
params=query_params,
|
|
628
|
-
content_type="application/json",
|
|
67
|
+
upload_result = await FileSystemApp.write_file(
|
|
68
|
+
audio_data, f"/tmp/{uuid.uuid4()}.mp3"
|
|
629
69
|
)
|
|
630
|
-
|
|
631
|
-
if (
|
|
632
|
-
response.status_code == 204
|
|
633
|
-
or not response.content
|
|
634
|
-
or not response.text.strip()
|
|
635
|
-
):
|
|
636
|
-
return None
|
|
637
|
-
try:
|
|
638
|
-
return response.json()
|
|
639
|
-
except ValueError:
|
|
640
|
-
return None
|
|
70
|
+
return upload_result["data"]["url"]
|
|
641
71
|
|
|
642
|
-
def
|
|
643
|
-
self,
|
|
644
|
-
) ->
|
|
72
|
+
async def speech_to_text(
|
|
73
|
+
self, audio_file_path: str, language_code: str = "eng", diarize: bool = True
|
|
74
|
+
) -> str:
|
|
645
75
|
"""
|
|
646
|
-
|
|
76
|
+
Converts speech to text.
|
|
77
|
+
NOTE: The REST API endpoint for this functionality is not yet publicly documented.
|
|
78
|
+
This is a placeholder and will not work until the endpoint is available.
|
|
647
79
|
|
|
648
80
|
Args:
|
|
649
|
-
|
|
650
|
-
voice_description (string): voice_description Example: 'voice_description'.
|
|
81
|
+
audio_file_path (str): The path to the audio file.
|
|
651
82
|
|
|
652
83
|
Returns:
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
Raises:
|
|
656
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
657
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
658
|
-
|
|
84
|
+
str: The transcribed text.
|
|
85
|
+
|
|
659
86
|
Tags:
|
|
660
|
-
|
|
87
|
+
important
|
|
661
88
|
"""
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
"
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
k: v for k, v in request_body_data.items() if v is not None
|
|
669
|
-
}
|
|
670
|
-
url = f"{self.base_url}/v1/text-to-voice/create-previews"
|
|
671
|
-
query_params = {}
|
|
672
|
-
response = self._post(
|
|
673
|
-
url,
|
|
674
|
-
data=request_body_data,
|
|
675
|
-
params=query_params,
|
|
676
|
-
content_type="application/json",
|
|
89
|
+
transcription = self.client.speech_to_text.convert(
|
|
90
|
+
file=audio_file_path,
|
|
91
|
+
model_id="scribe_v1", # Model to use, for now only "scribe_v1" is supported
|
|
92
|
+
tag_audio_events=True, # Tag audio events like laughter, applause, etc.
|
|
93
|
+
language_code=language_code, # Language of the audio file. If set to None, the model will detect the language automatically.
|
|
94
|
+
diarize=diarize, # Whether to annotate who is speaking
|
|
677
95
|
)
|
|
678
|
-
|
|
679
|
-
if (
|
|
680
|
-
response.status_code == 204
|
|
681
|
-
or not response.content
|
|
682
|
-
or not response.text.strip()
|
|
683
|
-
):
|
|
684
|
-
return None
|
|
685
|
-
try:
|
|
686
|
-
return response.json()
|
|
687
|
-
except ValueError:
|
|
688
|
-
return None
|
|
96
|
+
return transcription
|
|
689
97
|
|
|
690
|
-
def
|
|
98
|
+
async def speech_to_speech(
|
|
691
99
|
self,
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
) ->
|
|
696
|
-
"""
|
|
697
|
-
Creates a new voice entry in the voice library using a generated preview ID and returns voice details.
|
|
698
|
-
|
|
699
|
-
Args:
|
|
700
|
-
generated_voice_id (string): generated_voice_id Example: 'generated_voice_id'.
|
|
701
|
-
voice_description (string): voice_description Example: 'voice_description'.
|
|
702
|
-
voice_name (string): voice_name Example: 'voice_name'.
|
|
703
|
-
|
|
704
|
-
Returns:
|
|
705
|
-
dict[str, Any]: Success / Success
|
|
706
|
-
|
|
707
|
-
Raises:
|
|
708
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
709
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
710
|
-
|
|
711
|
-
Tags:
|
|
712
|
-
Text To Voice
|
|
713
|
-
"""
|
|
714
|
-
request_body_data = None
|
|
715
|
-
request_body_data = {
|
|
716
|
-
"generated_voice_id": generated_voice_id,
|
|
717
|
-
"voice_description": voice_description,
|
|
718
|
-
"voice_name": voice_name,
|
|
719
|
-
}
|
|
720
|
-
request_body_data = {
|
|
721
|
-
k: v for k, v in request_body_data.items() if v is not None
|
|
722
|
-
}
|
|
723
|
-
url = f"{self.base_url}/v1/text-to-voice/create-voice-from-preview"
|
|
724
|
-
query_params = {}
|
|
725
|
-
response = self._post(
|
|
726
|
-
url,
|
|
727
|
-
data=request_body_data,
|
|
728
|
-
params=query_params,
|
|
729
|
-
content_type="application/json",
|
|
730
|
-
)
|
|
731
|
-
response.raise_for_status()
|
|
732
|
-
if (
|
|
733
|
-
response.status_code == 204
|
|
734
|
-
or not response.content
|
|
735
|
-
or not response.text.strip()
|
|
736
|
-
):
|
|
737
|
-
return None
|
|
738
|
-
try:
|
|
739
|
-
return response.json()
|
|
740
|
-
except ValueError:
|
|
741
|
-
return None
|
|
742
|
-
|
|
743
|
-
def get_user_subscription_info(self) -> dict[str, Any]:
|
|
744
|
-
"""
|
|
745
|
-
Retrieves the user's subscription details from the API.
|
|
746
|
-
|
|
747
|
-
Returns:
|
|
748
|
-
dict[str, Any]: Success / Success
|
|
749
|
-
|
|
750
|
-
Raises:
|
|
751
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
752
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
753
|
-
|
|
754
|
-
Tags:
|
|
755
|
-
User
|
|
756
|
-
"""
|
|
757
|
-
url = f"{self.base_url}/v1/user/subscription"
|
|
758
|
-
query_params = {}
|
|
759
|
-
response = self._get(url, params=query_params)
|
|
760
|
-
response.raise_for_status()
|
|
761
|
-
if (
|
|
762
|
-
response.status_code == 204
|
|
763
|
-
or not response.content
|
|
764
|
-
or not response.text.strip()
|
|
765
|
-
):
|
|
766
|
-
return None
|
|
767
|
-
try:
|
|
768
|
-
return response.json()
|
|
769
|
-
except ValueError:
|
|
770
|
-
return None
|
|
771
|
-
|
|
772
|
-
def get_user_info(self) -> dict[str, Any]:
|
|
773
|
-
"""
|
|
774
|
-
Retrieves user information from the API.
|
|
775
|
-
|
|
776
|
-
Returns:
|
|
777
|
-
dict[str, Any]: Success / Success
|
|
778
|
-
|
|
779
|
-
Raises:
|
|
780
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
781
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
782
|
-
|
|
783
|
-
Tags:
|
|
784
|
-
User
|
|
785
|
-
"""
|
|
786
|
-
url = f"{self.base_url}/v1/user"
|
|
787
|
-
query_params = {}
|
|
788
|
-
response = self._get(url, params=query_params)
|
|
789
|
-
response.raise_for_status()
|
|
790
|
-
if (
|
|
791
|
-
response.status_code == 204
|
|
792
|
-
or not response.content
|
|
793
|
-
or not response.text.strip()
|
|
794
|
-
):
|
|
795
|
-
return None
|
|
796
|
-
try:
|
|
797
|
-
return response.json()
|
|
798
|
-
except ValueError:
|
|
799
|
-
return None
|
|
800
|
-
|
|
801
|
-
def get_voices(self) -> dict[str, Any]:
|
|
802
|
-
"""
|
|
803
|
-
Retrieves a list of voices using the "GET" method at the "/v1/voices" API endpoint.
|
|
804
|
-
|
|
805
|
-
Returns:
|
|
806
|
-
dict[str, Any]: Success / Success
|
|
807
|
-
|
|
808
|
-
Raises:
|
|
809
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
810
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
811
|
-
|
|
812
|
-
Tags:
|
|
813
|
-
voices
|
|
814
|
-
"""
|
|
815
|
-
url = f"{self.base_url}/v1/voices"
|
|
816
|
-
query_params = {}
|
|
817
|
-
response = self._get(url, params=query_params)
|
|
818
|
-
response.raise_for_status()
|
|
819
|
-
if (
|
|
820
|
-
response.status_code == 204
|
|
821
|
-
or not response.content
|
|
822
|
-
or not response.text.strip()
|
|
823
|
-
):
|
|
824
|
-
return None
|
|
825
|
-
try:
|
|
826
|
-
return response.json()
|
|
827
|
-
except ValueError:
|
|
828
|
-
return None
|
|
829
|
-
|
|
830
|
-
def get_default_voice_settings(self) -> dict[str, Any]:
|
|
831
|
-
"""
|
|
832
|
-
Retrieves the default voice settings using the "GET" method at the "/v1/voices/settings/default" endpoint.
|
|
833
|
-
|
|
834
|
-
Returns:
|
|
835
|
-
dict[str, Any]: Success / Success
|
|
836
|
-
|
|
837
|
-
Raises:
|
|
838
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
839
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
840
|
-
|
|
841
|
-
Tags:
|
|
842
|
-
voices
|
|
843
|
-
"""
|
|
844
|
-
url = f"{self.base_url}/v1/voices/settings/default"
|
|
845
|
-
query_params = {}
|
|
846
|
-
response = self._get(url, params=query_params)
|
|
847
|
-
response.raise_for_status()
|
|
848
|
-
if (
|
|
849
|
-
response.status_code == 204
|
|
850
|
-
or not response.content
|
|
851
|
-
or not response.text.strip()
|
|
852
|
-
):
|
|
853
|
-
return None
|
|
854
|
-
try:
|
|
855
|
-
return response.json()
|
|
856
|
-
except ValueError:
|
|
857
|
-
return None
|
|
858
|
-
|
|
859
|
-
def get_voice_settings(self, voice_id: str) -> dict[str, Any]:
|
|
860
|
-
"""
|
|
861
|
-
Retrieves voice settings for a specific voice identified by `{voice_id}` using the "GET" method, returning the current configuration for that voice.
|
|
862
|
-
|
|
863
|
-
Args:
|
|
864
|
-
voice_id (string): voice_id
|
|
865
|
-
|
|
866
|
-
Returns:
|
|
867
|
-
dict[str, Any]: Success / Success
|
|
868
|
-
|
|
869
|
-
Raises:
|
|
870
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
871
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
872
|
-
|
|
873
|
-
Tags:
|
|
874
|
-
voices
|
|
875
|
-
"""
|
|
876
|
-
if voice_id is None:
|
|
877
|
-
raise ValueError("Missing required parameter 'voice_id'.")
|
|
878
|
-
url = f"{self.base_url}/v1/voices/{voice_id}/settings"
|
|
879
|
-
query_params = {}
|
|
880
|
-
response = self._get(url, params=query_params)
|
|
881
|
-
response.raise_for_status()
|
|
882
|
-
if (
|
|
883
|
-
response.status_code == 204
|
|
884
|
-
or not response.content
|
|
885
|
-
or not response.text.strip()
|
|
886
|
-
):
|
|
887
|
-
return None
|
|
888
|
-
try:
|
|
889
|
-
return response.json()
|
|
890
|
-
except ValueError:
|
|
891
|
-
return None
|
|
892
|
-
|
|
893
|
-
def get_voice(self, voice_id: str) -> dict[str, Any]:
|
|
100
|
+
audio_url: str,
|
|
101
|
+
voice_id: str = "21m00Tcm4TlvDq8ikWAM",
|
|
102
|
+
model_id: str = "eleven_multilingual_sts_v2",
|
|
103
|
+
) -> bytes:
|
|
894
104
|
"""
|
|
895
|
-
|
|
105
|
+
Changes the voice in an audio file to a different voice.
|
|
896
106
|
|
|
897
107
|
Args:
|
|
898
|
-
voice_id (
|
|
108
|
+
voice_id (str): The ID of the voice to use for the conversion.
|
|
109
|
+
audio_file_path (str): The path to the audio file to transform.
|
|
110
|
+
model_id (str, optional): The model to use. Defaults to "eleven_multilingual_sts_v2".
|
|
899
111
|
|
|
900
112
|
Returns:
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
Raises:
|
|
904
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
905
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
906
|
-
|
|
907
|
-
Tags:
|
|
908
|
-
voices
|
|
909
|
-
"""
|
|
910
|
-
if voice_id is None:
|
|
911
|
-
raise ValueError("Missing required parameter 'voice_id'.")
|
|
912
|
-
url = f"{self.base_url}/v1/voices/{voice_id}"
|
|
913
|
-
query_params = {}
|
|
914
|
-
response = self._get(url, params=query_params)
|
|
915
|
-
response.raise_for_status()
|
|
916
|
-
if (
|
|
917
|
-
response.status_code == 204
|
|
918
|
-
or not response.content
|
|
919
|
-
or not response.text.strip()
|
|
920
|
-
):
|
|
921
|
-
return None
|
|
922
|
-
try:
|
|
923
|
-
return response.json()
|
|
924
|
-
except ValueError:
|
|
925
|
-
return None
|
|
926
|
-
|
|
927
|
-
def delete_voice(self, voice_id: str) -> dict[str, Any]:
|
|
928
|
-
"""
|
|
929
|
-
Deletes a voice with the specified ID using the DELETE method at the "/v1/voices/{voice_id}" endpoint.
|
|
930
|
-
|
|
931
|
-
Args:
|
|
932
|
-
voice_id (string): voice_id
|
|
933
|
-
|
|
934
|
-
Returns:
|
|
935
|
-
dict[str, Any]: Success / Success
|
|
936
|
-
|
|
937
|
-
Raises:
|
|
938
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
939
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
940
|
-
|
|
941
|
-
Tags:
|
|
942
|
-
voices
|
|
943
|
-
"""
|
|
944
|
-
if voice_id is None:
|
|
945
|
-
raise ValueError("Missing required parameter 'voice_id'.")
|
|
946
|
-
url = f"{self.base_url}/v1/voices/{voice_id}"
|
|
947
|
-
query_params = {}
|
|
948
|
-
response = self._delete(url, params=query_params)
|
|
949
|
-
response.raise_for_status()
|
|
950
|
-
if (
|
|
951
|
-
response.status_code == 204
|
|
952
|
-
or not response.content
|
|
953
|
-
or not response.text.strip()
|
|
954
|
-
):
|
|
955
|
-
return None
|
|
956
|
-
try:
|
|
957
|
-
return response.json()
|
|
958
|
-
except ValueError:
|
|
959
|
-
return None
|
|
960
|
-
|
|
961
|
-
def edit_voice_settings(
|
|
962
|
-
self, voice_id: str, request_body: dict[str, Any] | None = None
|
|
963
|
-
) -> dict[str, Any]:
|
|
964
|
-
"""
|
|
965
|
-
Updates voice settings for a specified voice ID and returns a success status.
|
|
966
|
-
|
|
967
|
-
Args:
|
|
968
|
-
voice_id (string): voice_id
|
|
969
|
-
request_body (dict | None): Optional dictionary for an empty JSON request body (e.g., {}).
|
|
970
|
-
|
|
971
|
-
Returns:
|
|
972
|
-
dict[str, Any]: Success / Success
|
|
973
|
-
|
|
974
|
-
Raises:
|
|
975
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
976
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
977
|
-
|
|
978
|
-
Tags:
|
|
979
|
-
voices
|
|
980
|
-
"""
|
|
981
|
-
if voice_id is None:
|
|
982
|
-
raise ValueError("Missing required parameter 'voice_id'.")
|
|
983
|
-
request_body_data = None
|
|
984
|
-
request_body_data = request_body if request_body is not None else {}
|
|
985
|
-
url = f"{self.base_url}/v1/voices/{voice_id}/settings/edit"
|
|
986
|
-
query_params = {}
|
|
987
|
-
response = self._post(
|
|
988
|
-
url,
|
|
989
|
-
data=request_body_data,
|
|
990
|
-
params=query_params,
|
|
991
|
-
content_type="application/json",
|
|
992
|
-
)
|
|
993
|
-
response.raise_for_status()
|
|
994
|
-
if (
|
|
995
|
-
response.status_code == 204
|
|
996
|
-
or not response.content
|
|
997
|
-
or not response.text.strip()
|
|
998
|
-
):
|
|
999
|
-
return None
|
|
1000
|
-
try:
|
|
1001
|
-
return response.json()
|
|
1002
|
-
except ValueError:
|
|
1003
|
-
return None
|
|
1004
|
-
|
|
1005
|
-
def add_voice(self, name: str | None = None) -> dict[str, Any]:
|
|
1006
|
-
"""
|
|
1007
|
-
Adds a new voice entry to the voices collection using the provided data.
|
|
1008
|
-
|
|
1009
|
-
Args:
|
|
1010
|
-
name (string): name Example: 'Alex'.
|
|
1011
|
-
|
|
1012
|
-
Returns:
|
|
1013
|
-
dict[str, Any]: Success
|
|
1014
|
-
|
|
1015
|
-
Raises:
|
|
1016
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
1017
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
1018
|
-
|
|
1019
|
-
Tags:
|
|
1020
|
-
voices
|
|
1021
|
-
"""
|
|
1022
|
-
request_body_data = None
|
|
1023
|
-
request_body_data = {
|
|
1024
|
-
"name": name,
|
|
1025
|
-
}
|
|
1026
|
-
request_body_data = {
|
|
1027
|
-
k: v for k, v in request_body_data.items() if v is not None
|
|
1028
|
-
}
|
|
1029
|
-
url = f"{self.base_url}/v1/voices/add"
|
|
1030
|
-
query_params = {}
|
|
1031
|
-
response = self._post(
|
|
1032
|
-
url,
|
|
1033
|
-
data=request_body_data,
|
|
1034
|
-
params=query_params,
|
|
1035
|
-
content_type="application/json",
|
|
1036
|
-
)
|
|
1037
|
-
response.raise_for_status()
|
|
1038
|
-
if (
|
|
1039
|
-
response.status_code == 204
|
|
1040
|
-
or not response.content
|
|
1041
|
-
or not response.text.strip()
|
|
1042
|
-
):
|
|
1043
|
-
return None
|
|
1044
|
-
try:
|
|
1045
|
-
return response.json()
|
|
1046
|
-
except ValueError:
|
|
1047
|
-
return None
|
|
1048
|
-
|
|
1049
|
-
def edit_voice(self, voice_id: str, name: str | None = None) -> dict[str, Any]:
|
|
1050
|
-
"""
|
|
1051
|
-
Updates the specified voice by ID using a POST request and returns a success status upon completion.
|
|
1052
|
-
|
|
1053
|
-
Args:
|
|
1054
|
-
voice_id (string): voice_id
|
|
1055
|
-
name (string): name Example: 'George'.
|
|
1056
|
-
|
|
1057
|
-
Returns:
|
|
1058
|
-
dict[str, Any]: Success
|
|
1059
|
-
|
|
1060
|
-
Raises:
|
|
1061
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
1062
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
1063
|
-
|
|
1064
|
-
Tags:
|
|
1065
|
-
voices, important
|
|
1066
|
-
"""
|
|
1067
|
-
if voice_id is None:
|
|
1068
|
-
raise ValueError("Missing required parameter 'voice_id'.")
|
|
1069
|
-
request_body_data = None
|
|
1070
|
-
request_body_data = {
|
|
1071
|
-
"name": name,
|
|
1072
|
-
}
|
|
1073
|
-
request_body_data = {
|
|
1074
|
-
k: v for k, v in request_body_data.items() if v is not None
|
|
1075
|
-
}
|
|
1076
|
-
url = f"{self.base_url}/v1/voices/{voice_id}/edit"
|
|
1077
|
-
query_params = {}
|
|
1078
|
-
response = self._post(
|
|
1079
|
-
url,
|
|
1080
|
-
data=request_body_data,
|
|
1081
|
-
params=query_params,
|
|
1082
|
-
content_type="application/json",
|
|
1083
|
-
)
|
|
1084
|
-
response.raise_for_status()
|
|
1085
|
-
if (
|
|
1086
|
-
response.status_code == 204
|
|
1087
|
-
or not response.content
|
|
1088
|
-
or not response.text.strip()
|
|
1089
|
-
):
|
|
1090
|
-
return None
|
|
1091
|
-
try:
|
|
1092
|
-
return response.json()
|
|
1093
|
-
except ValueError:
|
|
1094
|
-
return None
|
|
1095
|
-
|
|
1096
|
-
def add_sharing_voice(
|
|
1097
|
-
self, public_user_id: str, voice_id: str, new_name: str | None = None
|
|
1098
|
-
) -> dict[str, Any]:
|
|
1099
|
-
"""
|
|
1100
|
-
Adds a voice associated with a public user ID and voice ID using the specified API endpoint.
|
|
1101
|
-
|
|
1102
|
-
Args:
|
|
1103
|
-
public_user_id (string): public_user_id
|
|
1104
|
-
voice_id (string): voice_id
|
|
1105
|
-
new_name (string): new_name Example: 'new_name'.
|
|
1106
|
-
|
|
1107
|
-
Returns:
|
|
1108
|
-
dict[str, Any]: Success / Success
|
|
1109
|
-
|
|
1110
|
-
Raises:
|
|
1111
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
1112
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
1113
|
-
|
|
113
|
+
bytes: The transformed audio data.
|
|
114
|
+
|
|
1114
115
|
Tags:
|
|
1115
|
-
|
|
116
|
+
important
|
|
1116
117
|
"""
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
"
|
|
1124
|
-
}
|
|
1125
|
-
request_body_data = {
|
|
1126
|
-
k: v for k, v in request_body_data.items() if v is not None
|
|
1127
|
-
}
|
|
1128
|
-
url = f"{self.base_url}/v1/voices/add/{public_user_id}/{voice_id}"
|
|
1129
|
-
query_params = {}
|
|
1130
|
-
response = self._post(
|
|
1131
|
-
url,
|
|
1132
|
-
data=request_body_data,
|
|
1133
|
-
params=query_params,
|
|
1134
|
-
content_type="application/json",
|
|
118
|
+
response = requests.get(audio_url)
|
|
119
|
+
audio_data = BytesIO(response.content)
|
|
120
|
+
response = self.client.speech_to_speech.convert(
|
|
121
|
+
voice_id=voice_id,
|
|
122
|
+
audio=audio_data,
|
|
123
|
+
model_id=model_id,
|
|
124
|
+
output_format="mp3_44100_128",
|
|
1135
125
|
)
|
|
1136
|
-
response.
|
|
1137
|
-
if (
|
|
1138
|
-
response.status_code == 204
|
|
1139
|
-
or not response.content
|
|
1140
|
-
or not response.text.strip()
|
|
1141
|
-
):
|
|
1142
|
-
return None
|
|
1143
|
-
try:
|
|
1144
|
-
return response.json()
|
|
1145
|
-
except ValueError:
|
|
1146
|
-
return None
|
|
126
|
+
return response.content
|
|
1147
127
|
|
|
1148
|
-
def
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
"""
|
|
1155
|
-
Retrieves a list of shared voices filtered by parameters like gender and language, with pagination support via page_size.
|
|
128
|
+
def list_tools(self):
|
|
129
|
+
return [
|
|
130
|
+
self.text_to_speech,
|
|
131
|
+
self.speech_to_text,
|
|
132
|
+
self.speech_to_speech,
|
|
133
|
+
]
|
|
1156
134
|
|
|
1157
|
-
Args:
|
|
1158
|
-
page_size (string): How many shared voices to return at maximum. Can not exceed 100, defaults to 30. Example: '1'.
|
|
1159
|
-
gender (string): gender used for filtering Example: 'female'.
|
|
1160
|
-
language (string): language used for filtering Example: 'en'.
|
|
1161
135
|
|
|
1162
|
-
|
|
1163
|
-
|
|
136
|
+
async def test_elevenlabs():
|
|
137
|
+
app = ElevenlabsApp()
|
|
138
|
+
audio = await app.text_to_speech("Hello, world!")
|
|
139
|
+
print(audio)
|
|
1164
140
|
|
|
1165
|
-
Raises:
|
|
1166
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
1167
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
1168
141
|
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
"""
|
|
1172
|
-
url = f"{self.base_url}/v1/shared-voices"
|
|
1173
|
-
query_params = {
|
|
1174
|
-
k: v
|
|
1175
|
-
for k, v in [
|
|
1176
|
-
("page_size", page_size),
|
|
1177
|
-
("gender", gender),
|
|
1178
|
-
("language", language),
|
|
1179
|
-
]
|
|
1180
|
-
if v is not None
|
|
1181
|
-
}
|
|
1182
|
-
response = self._get(url, params=query_params)
|
|
1183
|
-
response.raise_for_status()
|
|
1184
|
-
if (
|
|
1185
|
-
response.status_code == 204
|
|
1186
|
-
or not response.content
|
|
1187
|
-
or not response.text.strip()
|
|
1188
|
-
):
|
|
1189
|
-
return None
|
|
1190
|
-
try:
|
|
1191
|
-
return response.json()
|
|
1192
|
-
except ValueError:
|
|
1193
|
-
return None
|
|
142
|
+
if __name__ == "__main__":
|
|
143
|
+
import asyncio
|
|
1194
144
|
|
|
1195
|
-
|
|
1196
|
-
self, request_body: dict[str, Any] | None = None
|
|
1197
|
-
) -> dict[str, Any]:
|
|
1198
|
-
"""
|
|
1199
|
-
Generates a list of similar voices using the POST method at the "/v1/similar-voices" endpoint.
|
|
1200
|
-
|
|
1201
|
-
Args:
|
|
1202
|
-
request_body (dict | None): Optional dictionary for an empty JSON request body (e.g., {}).
|
|
1203
|
-
|
|
1204
|
-
Returns:
|
|
1205
|
-
dict[str, Any]: Success
|
|
1206
|
-
|
|
1207
|
-
Raises:
|
|
1208
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
1209
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
1210
|
-
|
|
1211
|
-
Tags:
|
|
1212
|
-
voices
|
|
1213
|
-
"""
|
|
1214
|
-
request_body_data = None
|
|
1215
|
-
request_body_data = request_body if request_body is not None else {}
|
|
1216
|
-
url = f"{self.base_url}/v1/similar-voices"
|
|
1217
|
-
query_params = {}
|
|
1218
|
-
response = self._post(
|
|
1219
|
-
url,
|
|
1220
|
-
data=request_body_data,
|
|
1221
|
-
params=query_params,
|
|
1222
|
-
content_type="application/json",
|
|
1223
|
-
)
|
|
1224
|
-
response.raise_for_status()
|
|
1225
|
-
if (
|
|
1226
|
-
response.status_code == 204
|
|
1227
|
-
or not response.content
|
|
1228
|
-
or not response.text.strip()
|
|
1229
|
-
):
|
|
1230
|
-
return None
|
|
1231
|
-
try:
|
|
1232
|
-
return response.json()
|
|
1233
|
-
except ValueError:
|
|
1234
|
-
return None
|
|
1235
|
-
|
|
1236
|
-
def get_aprofile_page(self, handle: str) -> dict[str, Any]:
|
|
1237
|
-
"""
|
|
1238
|
-
Retrieves a unified customer profile by handle and returns the associated attributes, identifiers, and traits.
|
|
1239
|
-
|
|
1240
|
-
Args:
|
|
1241
|
-
handle (string): handle
|
|
1242
|
-
|
|
1243
|
-
Returns:
|
|
1244
|
-
dict[str, Any]: Success / Success
|
|
1245
|
-
|
|
1246
|
-
Raises:
|
|
1247
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
1248
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
1249
|
-
|
|
1250
|
-
Tags:
|
|
1251
|
-
voices
|
|
1252
|
-
"""
|
|
1253
|
-
if handle is None:
|
|
1254
|
-
raise ValueError("Missing required parameter 'handle'.")
|
|
1255
|
-
url = f"{self.base_url}/profile/{handle}"
|
|
1256
|
-
query_params = {}
|
|
1257
|
-
response = self._get(url, params=query_params)
|
|
1258
|
-
response.raise_for_status()
|
|
1259
|
-
if (
|
|
1260
|
-
response.status_code == 204
|
|
1261
|
-
or not response.content
|
|
1262
|
-
or not response.text.strip()
|
|
1263
|
-
):
|
|
1264
|
-
return None
|
|
1265
|
-
try:
|
|
1266
|
-
return response.json()
|
|
1267
|
-
except ValueError:
|
|
1268
|
-
return None
|
|
1269
|
-
|
|
1270
|
-
def get_projects(self) -> dict[str, Any]:
|
|
1271
|
-
"""
|
|
1272
|
-
Retrieves a list of projects using the API defined at the "/v1/projects" endpoint via the GET method.
|
|
1273
|
-
|
|
1274
|
-
Returns:
|
|
1275
|
-
dict[str, Any]: Success / Success
|
|
1276
|
-
|
|
1277
|
-
Raises:
|
|
1278
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
1279
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
1280
|
-
|
|
1281
|
-
Tags:
|
|
1282
|
-
Projects, important
|
|
1283
|
-
"""
|
|
1284
|
-
url = f"{self.base_url}/v1/projects"
|
|
1285
|
-
query_params = {}
|
|
1286
|
-
response = self._get(url, params=query_params)
|
|
1287
|
-
response.raise_for_status()
|
|
1288
|
-
if (
|
|
1289
|
-
response.status_code == 204
|
|
1290
|
-
or not response.content
|
|
1291
|
-
or not response.text.strip()
|
|
1292
|
-
):
|
|
1293
|
-
return None
|
|
1294
|
-
try:
|
|
1295
|
-
return response.json()
|
|
1296
|
-
except ValueError:
|
|
1297
|
-
return None
|
|
1298
|
-
|
|
1299
|
-
def add_project(
|
|
1300
|
-
self,
|
|
1301
|
-
default_model_id: str | None = None,
|
|
1302
|
-
default_paragraph_voice_id: str | None = None,
|
|
1303
|
-
default_title_voice_id: str | None = None,
|
|
1304
|
-
name: str | None = None,
|
|
1305
|
-
) -> dict[str, Any]:
|
|
1306
|
-
"""
|
|
1307
|
-
Creates a new project and returns a status message.
|
|
1308
|
-
|
|
1309
|
-
Args:
|
|
1310
|
-
default_model_id (string): default_model_id Example: 'default_model_id'.
|
|
1311
|
-
default_paragraph_voice_id (string): default_paragraph_voice_id Example: 'default_paragraph_voice_id'.
|
|
1312
|
-
default_title_voice_id (string): default_title_voice_id Example: 'default_title_voice_id'.
|
|
1313
|
-
name (string): name Example: 'name'.
|
|
1314
|
-
|
|
1315
|
-
Returns:
|
|
1316
|
-
dict[str, Any]: Success
|
|
1317
|
-
|
|
1318
|
-
Raises:
|
|
1319
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
1320
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
1321
|
-
|
|
1322
|
-
Tags:
|
|
1323
|
-
Projects, important
|
|
1324
|
-
"""
|
|
1325
|
-
request_body_data = None
|
|
1326
|
-
request_body_data = {
|
|
1327
|
-
"default_model_id": default_model_id,
|
|
1328
|
-
"default_paragraph_voice_id": default_paragraph_voice_id,
|
|
1329
|
-
"default_title_voice_id": default_title_voice_id,
|
|
1330
|
-
"name": name,
|
|
1331
|
-
}
|
|
1332
|
-
request_body_data = {
|
|
1333
|
-
k: v for k, v in request_body_data.items() if v is not None
|
|
1334
|
-
}
|
|
1335
|
-
url = f"{self.base_url}/v1/projects/add"
|
|
1336
|
-
query_params = {}
|
|
1337
|
-
response = self._post(
|
|
1338
|
-
url,
|
|
1339
|
-
data=request_body_data,
|
|
1340
|
-
params=query_params,
|
|
1341
|
-
content_type="application/json",
|
|
1342
|
-
)
|
|
1343
|
-
response.raise_for_status()
|
|
1344
|
-
if (
|
|
1345
|
-
response.status_code == 204
|
|
1346
|
-
or not response.content
|
|
1347
|
-
or not response.text.strip()
|
|
1348
|
-
):
|
|
1349
|
-
return None
|
|
1350
|
-
try:
|
|
1351
|
-
return response.json()
|
|
1352
|
-
except ValueError:
|
|
1353
|
-
return None
|
|
1354
|
-
|
|
1355
|
-
def get_project_by_id(self, project_id: str) -> dict[str, Any]:
|
|
1356
|
-
"""
|
|
1357
|
-
Retrieves information for a specific project identified by `{project_id}` using the API endpoint at "/v1/projects/{project_id}" via the GET method.
|
|
1358
|
-
|
|
1359
|
-
Args:
|
|
1360
|
-
project_id (string): project_id
|
|
1361
|
-
|
|
1362
|
-
Returns:
|
|
1363
|
-
dict[str, Any]: Success / Success
|
|
1364
|
-
|
|
1365
|
-
Raises:
|
|
1366
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
1367
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
1368
|
-
|
|
1369
|
-
Tags:
|
|
1370
|
-
Projects
|
|
1371
|
-
"""
|
|
1372
|
-
if project_id is None:
|
|
1373
|
-
raise ValueError("Missing required parameter 'project_id'.")
|
|
1374
|
-
url = f"{self.base_url}/v1/projects/{project_id}"
|
|
1375
|
-
query_params = {}
|
|
1376
|
-
response = self._get(url, params=query_params)
|
|
1377
|
-
response.raise_for_status()
|
|
1378
|
-
if (
|
|
1379
|
-
response.status_code == 204
|
|
1380
|
-
or not response.content
|
|
1381
|
-
or not response.text.strip()
|
|
1382
|
-
):
|
|
1383
|
-
return None
|
|
1384
|
-
try:
|
|
1385
|
-
return response.json()
|
|
1386
|
-
except ValueError:
|
|
1387
|
-
return None
|
|
1388
|
-
|
|
1389
|
-
def edit_basic_project_info(
|
|
1390
|
-
self,
|
|
1391
|
-
project_id: str,
|
|
1392
|
-
default_paragraph_voice_id: str | None = None,
|
|
1393
|
-
default_title_voice_id: str | None = None,
|
|
1394
|
-
name: str | None = None,
|
|
1395
|
-
) -> dict[str, Any]:
|
|
1396
|
-
"""
|
|
1397
|
-
Creates a new project resource by sending data to the specified project identifier using the POST method at the "/v1/projects/{project_id}" endpoint.
|
|
1398
|
-
|
|
1399
|
-
Args:
|
|
1400
|
-
project_id (string): project_id
|
|
1401
|
-
default_paragraph_voice_id (string): default_paragraph_voice_id Example: 'default_paragraph_voice_id'.
|
|
1402
|
-
default_title_voice_id (string): default_title_voice_id Example: 'default_title_voice_id'.
|
|
1403
|
-
name (string): name Example: 'name'.
|
|
1404
|
-
|
|
1405
|
-
Returns:
|
|
1406
|
-
dict[str, Any]: Success / Success
|
|
1407
|
-
|
|
1408
|
-
Raises:
|
|
1409
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
1410
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
1411
|
-
|
|
1412
|
-
Tags:
|
|
1413
|
-
Projects
|
|
1414
|
-
"""
|
|
1415
|
-
if project_id is None:
|
|
1416
|
-
raise ValueError("Missing required parameter 'project_id'.")
|
|
1417
|
-
request_body_data = None
|
|
1418
|
-
request_body_data = {
|
|
1419
|
-
"default_paragraph_voice_id": default_paragraph_voice_id,
|
|
1420
|
-
"default_title_voice_id": default_title_voice_id,
|
|
1421
|
-
"name": name,
|
|
1422
|
-
}
|
|
1423
|
-
request_body_data = {
|
|
1424
|
-
k: v for k, v in request_body_data.items() if v is not None
|
|
1425
|
-
}
|
|
1426
|
-
url = f"{self.base_url}/v1/projects/{project_id}"
|
|
1427
|
-
query_params = {}
|
|
1428
|
-
response = self._post(
|
|
1429
|
-
url,
|
|
1430
|
-
data=request_body_data,
|
|
1431
|
-
params=query_params,
|
|
1432
|
-
content_type="application/json",
|
|
1433
|
-
)
|
|
1434
|
-
response.raise_for_status()
|
|
1435
|
-
if (
|
|
1436
|
-
response.status_code == 204
|
|
1437
|
-
or not response.content
|
|
1438
|
-
or not response.text.strip()
|
|
1439
|
-
):
|
|
1440
|
-
return None
|
|
1441
|
-
try:
|
|
1442
|
-
return response.json()
|
|
1443
|
-
except ValueError:
|
|
1444
|
-
return None
|
|
1445
|
-
|
|
1446
|
-
def delete_project(self, project_id: str) -> dict[str, Any]:
|
|
1447
|
-
"""
|
|
1448
|
-
Deletes the specified project and returns a success status upon completion.
|
|
1449
|
-
|
|
1450
|
-
Args:
|
|
1451
|
-
project_id (string): project_id
|
|
1452
|
-
|
|
1453
|
-
Returns:
|
|
1454
|
-
dict[str, Any]: Success / Success
|
|
1455
|
-
|
|
1456
|
-
Raises:
|
|
1457
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
1458
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
1459
|
-
|
|
1460
|
-
Tags:
|
|
1461
|
-
Projects, important
|
|
1462
|
-
"""
|
|
1463
|
-
if project_id is None:
|
|
1464
|
-
raise ValueError("Missing required parameter 'project_id'.")
|
|
1465
|
-
url = f"{self.base_url}/v1/projects/{project_id}"
|
|
1466
|
-
query_params = {}
|
|
1467
|
-
response = self._delete(url, params=query_params)
|
|
1468
|
-
response.raise_for_status()
|
|
1469
|
-
if (
|
|
1470
|
-
response.status_code == 204
|
|
1471
|
-
or not response.content
|
|
1472
|
-
or not response.text.strip()
|
|
1473
|
-
):
|
|
1474
|
-
return None
|
|
1475
|
-
try:
|
|
1476
|
-
return response.json()
|
|
1477
|
-
except ValueError:
|
|
1478
|
-
return None
|
|
1479
|
-
|
|
1480
|
-
def convert_project(self, project_id: str) -> dict[str, Any]:
|
|
1481
|
-
"""
|
|
1482
|
-
Converts a specified project identified by project_id and returns the conversion result.
|
|
1483
|
-
|
|
1484
|
-
Args:
|
|
1485
|
-
project_id (string): project_id
|
|
1486
|
-
|
|
1487
|
-
Returns:
|
|
1488
|
-
dict[str, Any]: Success / Success
|
|
1489
|
-
|
|
1490
|
-
Raises:
|
|
1491
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
1492
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
1493
|
-
|
|
1494
|
-
Tags:
|
|
1495
|
-
Projects
|
|
1496
|
-
"""
|
|
1497
|
-
if project_id is None:
|
|
1498
|
-
raise ValueError("Missing required parameter 'project_id'.")
|
|
1499
|
-
request_body_data = None
|
|
1500
|
-
url = f"{self.base_url}/v1/projects/{project_id}/convert"
|
|
1501
|
-
query_params = {}
|
|
1502
|
-
response = self._post(
|
|
1503
|
-
url,
|
|
1504
|
-
data=request_body_data,
|
|
1505
|
-
params=query_params,
|
|
1506
|
-
content_type="application/json",
|
|
1507
|
-
)
|
|
1508
|
-
response.raise_for_status()
|
|
1509
|
-
if (
|
|
1510
|
-
response.status_code == 204
|
|
1511
|
-
or not response.content
|
|
1512
|
-
or not response.text.strip()
|
|
1513
|
-
):
|
|
1514
|
-
return None
|
|
1515
|
-
try:
|
|
1516
|
-
return response.json()
|
|
1517
|
-
except ValueError:
|
|
1518
|
-
return None
|
|
1519
|
-
|
|
1520
|
-
def get_project_snapshots(self, project_id: str) -> dict[str, Any]:
|
|
1521
|
-
"""
|
|
1522
|
-
Retrieves a list of snapshots associated with a specified project.
|
|
1523
|
-
|
|
1524
|
-
Args:
|
|
1525
|
-
project_id (string): project_id
|
|
1526
|
-
|
|
1527
|
-
Returns:
|
|
1528
|
-
dict[str, Any]: Success / Success
|
|
1529
|
-
|
|
1530
|
-
Raises:
|
|
1531
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
1532
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
1533
|
-
|
|
1534
|
-
Tags:
|
|
1535
|
-
Projects
|
|
1536
|
-
"""
|
|
1537
|
-
if project_id is None:
|
|
1538
|
-
raise ValueError("Missing required parameter 'project_id'.")
|
|
1539
|
-
url = f"{self.base_url}/v1/projects/{project_id}/snapshots"
|
|
1540
|
-
query_params = {}
|
|
1541
|
-
response = self._get(url, params=query_params)
|
|
1542
|
-
response.raise_for_status()
|
|
1543
|
-
if (
|
|
1544
|
-
response.status_code == 204
|
|
1545
|
-
or not response.content
|
|
1546
|
-
or not response.text.strip()
|
|
1547
|
-
):
|
|
1548
|
-
return None
|
|
1549
|
-
try:
|
|
1550
|
-
return response.json()
|
|
1551
|
-
except ValueError:
|
|
1552
|
-
return None
|
|
1553
|
-
|
|
1554
|
-
def streams_archive_with_project_audio(
|
|
1555
|
-
self, project_id: str, project_snapshot_id: str
|
|
1556
|
-
) -> Any:
|
|
1557
|
-
"""
|
|
1558
|
-
Archives a project snapshot using the specified project ID and snapshot ID and returns a success status.
|
|
1559
|
-
|
|
1560
|
-
Args:
|
|
1561
|
-
project_id (string): project_id
|
|
1562
|
-
project_snapshot_id (string): project_snapshot_id
|
|
1563
|
-
|
|
1564
|
-
Returns:
|
|
1565
|
-
Any: Success / Success
|
|
1566
|
-
|
|
1567
|
-
Raises:
|
|
1568
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
1569
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
1570
|
-
|
|
1571
|
-
Tags:
|
|
1572
|
-
Projects
|
|
1573
|
-
"""
|
|
1574
|
-
if project_id is None:
|
|
1575
|
-
raise ValueError("Missing required parameter 'project_id'.")
|
|
1576
|
-
if project_snapshot_id is None:
|
|
1577
|
-
raise ValueError("Missing required parameter 'project_snapshot_id'.")
|
|
1578
|
-
request_body_data = None
|
|
1579
|
-
url = f"{self.base_url}/v1/projects/{project_id}/snapshots/{project_snapshot_id}/archive"
|
|
1580
|
-
query_params = {}
|
|
1581
|
-
response = self._post(
|
|
1582
|
-
url,
|
|
1583
|
-
data=request_body_data,
|
|
1584
|
-
params=query_params,
|
|
1585
|
-
content_type="application/json",
|
|
1586
|
-
)
|
|
1587
|
-
response.raise_for_status()
|
|
1588
|
-
if (
|
|
1589
|
-
response.status_code == 204
|
|
1590
|
-
or not response.content
|
|
1591
|
-
or not response.text.strip()
|
|
1592
|
-
):
|
|
1593
|
-
return None
|
|
1594
|
-
try:
|
|
1595
|
-
return response.json()
|
|
1596
|
-
except ValueError:
|
|
1597
|
-
return None
|
|
1598
|
-
|
|
1599
|
-
def add_chapter_to_aproject(
|
|
1600
|
-
self, project_id: str, name: str | None = None
|
|
1601
|
-
) -> dict[str, Any]:
|
|
1602
|
-
"""
|
|
1603
|
-
Adds a new chapter to a specified project using the provided project identifier and returns a success status upon completion.
|
|
1604
|
-
|
|
1605
|
-
Args:
|
|
1606
|
-
project_id (string): project_id
|
|
1607
|
-
name (string): name Example: 'name'.
|
|
1608
|
-
|
|
1609
|
-
Returns:
|
|
1610
|
-
dict[str, Any]: Success / Success
|
|
1611
|
-
|
|
1612
|
-
Raises:
|
|
1613
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
1614
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
1615
|
-
|
|
1616
|
-
Tags:
|
|
1617
|
-
Projects
|
|
1618
|
-
"""
|
|
1619
|
-
if project_id is None:
|
|
1620
|
-
raise ValueError("Missing required parameter 'project_id'.")
|
|
1621
|
-
request_body_data = None
|
|
1622
|
-
request_body_data = {
|
|
1623
|
-
"name": name,
|
|
1624
|
-
}
|
|
1625
|
-
request_body_data = {
|
|
1626
|
-
k: v for k, v in request_body_data.items() if v is not None
|
|
1627
|
-
}
|
|
1628
|
-
url = f"{self.base_url}/v1/projects/{project_id}/chapters/add"
|
|
1629
|
-
query_params = {}
|
|
1630
|
-
response = self._post(
|
|
1631
|
-
url,
|
|
1632
|
-
data=request_body_data,
|
|
1633
|
-
params=query_params,
|
|
1634
|
-
content_type="application/json",
|
|
1635
|
-
)
|
|
1636
|
-
response.raise_for_status()
|
|
1637
|
-
if (
|
|
1638
|
-
response.status_code == 204
|
|
1639
|
-
or not response.content
|
|
1640
|
-
or not response.text.strip()
|
|
1641
|
-
):
|
|
1642
|
-
return None
|
|
1643
|
-
try:
|
|
1644
|
-
return response.json()
|
|
1645
|
-
except ValueError:
|
|
1646
|
-
return None
|
|
1647
|
-
|
|
1648
|
-
def update_project_pronunciations(
|
|
1649
|
-
self,
|
|
1650
|
-
project_id: str,
|
|
1651
|
-
pronunciation_dictionary_locators: list[dict[str, Any]] | None = None,
|
|
1652
|
-
) -> dict[str, Any]:
|
|
1653
|
-
"""
|
|
1654
|
-
Updates pronunciation dictionaries for a specified project using the POST method, returning a successful status message upon completion.
|
|
1655
|
-
|
|
1656
|
-
Args:
|
|
1657
|
-
project_id (string): project_id
|
|
1658
|
-
pronunciation_dictionary_locators (array): pronunciation_dictionary_locators Example: "[{'pronunciation_dictionary_id': 'pronunciation_dictionary_id', 'version_id': 'version_id'}, {'pronunciation_dictionary_id': 'pronunciation_dictionary_id', 'version_id': 'version_id'}]".
|
|
1659
|
-
|
|
1660
|
-
Returns:
|
|
1661
|
-
dict[str, Any]: Success / Success
|
|
1662
|
-
|
|
1663
|
-
Raises:
|
|
1664
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
1665
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
1666
|
-
|
|
1667
|
-
Tags:
|
|
1668
|
-
Projects
|
|
1669
|
-
"""
|
|
1670
|
-
if project_id is None:
|
|
1671
|
-
raise ValueError("Missing required parameter 'project_id'.")
|
|
1672
|
-
request_body_data = None
|
|
1673
|
-
request_body_data = {
|
|
1674
|
-
"pronunciation_dictionary_locators": pronunciation_dictionary_locators,
|
|
1675
|
-
}
|
|
1676
|
-
request_body_data = {
|
|
1677
|
-
k: v for k, v in request_body_data.items() if v is not None
|
|
1678
|
-
}
|
|
1679
|
-
url = f"{self.base_url}/v1/projects/{project_id}/update-pronunciation-dictionaries"
|
|
1680
|
-
query_params = {}
|
|
1681
|
-
response = self._post(
|
|
1682
|
-
url,
|
|
1683
|
-
data=request_body_data,
|
|
1684
|
-
params=query_params,
|
|
1685
|
-
content_type="application/json",
|
|
1686
|
-
)
|
|
1687
|
-
response.raise_for_status()
|
|
1688
|
-
if (
|
|
1689
|
-
response.status_code == 204
|
|
1690
|
-
or not response.content
|
|
1691
|
-
or not response.text.strip()
|
|
1692
|
-
):
|
|
1693
|
-
return None
|
|
1694
|
-
try:
|
|
1695
|
-
return response.json()
|
|
1696
|
-
except ValueError:
|
|
1697
|
-
return None
|
|
1698
|
-
|
|
1699
|
-
def get_chapters(self, project_id: str) -> dict[str, Any]:
|
|
1700
|
-
"""
|
|
1701
|
-
Retrieves a chapter for a specified project by ID using the GET method.
|
|
1702
|
-
|
|
1703
|
-
Args:
|
|
1704
|
-
project_id (string): project_id
|
|
1705
|
-
|
|
1706
|
-
Returns:
|
|
1707
|
-
dict[str, Any]: Success / Success
|
|
1708
|
-
|
|
1709
|
-
Raises:
|
|
1710
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
1711
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
1712
|
-
|
|
1713
|
-
Tags:
|
|
1714
|
-
Chapters
|
|
1715
|
-
"""
|
|
1716
|
-
if project_id is None:
|
|
1717
|
-
raise ValueError("Missing required parameter 'project_id'.")
|
|
1718
|
-
url = f"{self.base_url}/v1/projects/{project_id}/chapters"
|
|
1719
|
-
query_params = {}
|
|
1720
|
-
response = self._get(url, params=query_params)
|
|
1721
|
-
response.raise_for_status()
|
|
1722
|
-
if (
|
|
1723
|
-
response.status_code == 204
|
|
1724
|
-
or not response.content
|
|
1725
|
-
or not response.text.strip()
|
|
1726
|
-
):
|
|
1727
|
-
return None
|
|
1728
|
-
try:
|
|
1729
|
-
return response.json()
|
|
1730
|
-
except ValueError:
|
|
1731
|
-
return None
|
|
1732
|
-
|
|
1733
|
-
def get_chapter_by_id(self, project_id: str, chapter_id: str) -> dict[str, Any]:
|
|
1734
|
-
"""
|
|
1735
|
-
Retrieves a specific chapter within a project identified by project_id and chapter_id.
|
|
1736
|
-
|
|
1737
|
-
Args:
|
|
1738
|
-
project_id (string): project_id
|
|
1739
|
-
chapter_id (string): chapter_id
|
|
1740
|
-
|
|
1741
|
-
Returns:
|
|
1742
|
-
dict[str, Any]: Success / Success
|
|
1743
|
-
|
|
1744
|
-
Raises:
|
|
1745
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
1746
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
1747
|
-
|
|
1748
|
-
Tags:
|
|
1749
|
-
Chapters
|
|
1750
|
-
"""
|
|
1751
|
-
if project_id is None:
|
|
1752
|
-
raise ValueError("Missing required parameter 'project_id'.")
|
|
1753
|
-
if chapter_id is None:
|
|
1754
|
-
raise ValueError("Missing required parameter 'chapter_id'.")
|
|
1755
|
-
url = f"{self.base_url}/v1/projects/{project_id}/chapters/{chapter_id}"
|
|
1756
|
-
query_params = {}
|
|
1757
|
-
response = self._get(url, params=query_params)
|
|
1758
|
-
response.raise_for_status()
|
|
1759
|
-
if (
|
|
1760
|
-
response.status_code == 204
|
|
1761
|
-
or not response.content
|
|
1762
|
-
or not response.text.strip()
|
|
1763
|
-
):
|
|
1764
|
-
return None
|
|
1765
|
-
try:
|
|
1766
|
-
return response.json()
|
|
1767
|
-
except ValueError:
|
|
1768
|
-
return None
|
|
1769
|
-
|
|
1770
|
-
def delete_chapter(self, project_id: str, chapter_id: str) -> dict[str, Any]:
|
|
1771
|
-
"""
|
|
1772
|
-
Deletes a specific chapter within a project using the "DELETE" method.
|
|
1773
|
-
|
|
1774
|
-
Args:
|
|
1775
|
-
project_id (string): project_id
|
|
1776
|
-
chapter_id (string): chapter_id
|
|
1777
|
-
|
|
1778
|
-
Returns:
|
|
1779
|
-
dict[str, Any]: Success / Success
|
|
1780
|
-
|
|
1781
|
-
Raises:
|
|
1782
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
1783
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
1784
|
-
|
|
1785
|
-
Tags:
|
|
1786
|
-
Chapters
|
|
1787
|
-
"""
|
|
1788
|
-
if project_id is None:
|
|
1789
|
-
raise ValueError("Missing required parameter 'project_id'.")
|
|
1790
|
-
if chapter_id is None:
|
|
1791
|
-
raise ValueError("Missing required parameter 'chapter_id'.")
|
|
1792
|
-
url = f"{self.base_url}/v1/projects/{project_id}/chapters/{chapter_id}"
|
|
1793
|
-
query_params = {}
|
|
1794
|
-
response = self._delete(url, params=query_params)
|
|
1795
|
-
response.raise_for_status()
|
|
1796
|
-
if (
|
|
1797
|
-
response.status_code == 204
|
|
1798
|
-
or not response.content
|
|
1799
|
-
or not response.text.strip()
|
|
1800
|
-
):
|
|
1801
|
-
return None
|
|
1802
|
-
try:
|
|
1803
|
-
return response.json()
|
|
1804
|
-
except ValueError:
|
|
1805
|
-
return None
|
|
1806
|
-
|
|
1807
|
-
def convert_chapter(self, project_id: str, chapter_id: str) -> dict[str, Any]:
|
|
1808
|
-
"""
|
|
1809
|
-
Converts a chapter in a project using the POST method and returns a response upon successful conversion.
|
|
1810
|
-
|
|
1811
|
-
Args:
|
|
1812
|
-
project_id (string): project_id
|
|
1813
|
-
chapter_id (string): chapter_id
|
|
1814
|
-
|
|
1815
|
-
Returns:
|
|
1816
|
-
dict[str, Any]: Success / Success
|
|
1817
|
-
|
|
1818
|
-
Raises:
|
|
1819
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
1820
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
1821
|
-
|
|
1822
|
-
Tags:
|
|
1823
|
-
Chapters
|
|
1824
|
-
"""
|
|
1825
|
-
if project_id is None:
|
|
1826
|
-
raise ValueError("Missing required parameter 'project_id'.")
|
|
1827
|
-
if chapter_id is None:
|
|
1828
|
-
raise ValueError("Missing required parameter 'chapter_id'.")
|
|
1829
|
-
request_body_data = None
|
|
1830
|
-
url = f"{self.base_url}/v1/projects/{project_id}/chapters/{chapter_id}/convert"
|
|
1831
|
-
query_params = {}
|
|
1832
|
-
response = self._post(
|
|
1833
|
-
url,
|
|
1834
|
-
data=request_body_data,
|
|
1835
|
-
params=query_params,
|
|
1836
|
-
content_type="application/json",
|
|
1837
|
-
)
|
|
1838
|
-
response.raise_for_status()
|
|
1839
|
-
if (
|
|
1840
|
-
response.status_code == 204
|
|
1841
|
-
or not response.content
|
|
1842
|
-
or not response.text.strip()
|
|
1843
|
-
):
|
|
1844
|
-
return None
|
|
1845
|
-
try:
|
|
1846
|
-
return response.json()
|
|
1847
|
-
except ValueError:
|
|
1848
|
-
return None
|
|
1849
|
-
|
|
1850
|
-
def get_chapter_snapshots(self, project_id: str, chapter_id: str) -> dict[str, Any]:
|
|
1851
|
-
"""
|
|
1852
|
-
Retrieves a snapshot for a specific chapter within a project using the provided project and chapter IDs.
|
|
1853
|
-
|
|
1854
|
-
Args:
|
|
1855
|
-
project_id (string): project_id
|
|
1856
|
-
chapter_id (string): chapter_id
|
|
1857
|
-
|
|
1858
|
-
Returns:
|
|
1859
|
-
dict[str, Any]: Success / Success
|
|
1860
|
-
|
|
1861
|
-
Raises:
|
|
1862
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
1863
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
1864
|
-
|
|
1865
|
-
Tags:
|
|
1866
|
-
Chapters
|
|
1867
|
-
"""
|
|
1868
|
-
if project_id is None:
|
|
1869
|
-
raise ValueError("Missing required parameter 'project_id'.")
|
|
1870
|
-
if chapter_id is None:
|
|
1871
|
-
raise ValueError("Missing required parameter 'chapter_id'.")
|
|
1872
|
-
url = (
|
|
1873
|
-
f"{self.base_url}/v1/projects/{project_id}/chapters/{chapter_id}/snapshots"
|
|
1874
|
-
)
|
|
1875
|
-
query_params = {}
|
|
1876
|
-
response = self._get(url, params=query_params)
|
|
1877
|
-
response.raise_for_status()
|
|
1878
|
-
if (
|
|
1879
|
-
response.status_code == 204
|
|
1880
|
-
or not response.content
|
|
1881
|
-
or not response.text.strip()
|
|
1882
|
-
):
|
|
1883
|
-
return None
|
|
1884
|
-
try:
|
|
1885
|
-
return response.json()
|
|
1886
|
-
except ValueError:
|
|
1887
|
-
return None
|
|
1888
|
-
|
|
1889
|
-
def stream_chapter_audio(
|
|
1890
|
-
self,
|
|
1891
|
-
project_id: str,
|
|
1892
|
-
chapter_id: str,
|
|
1893
|
-
chapter_snapshot_id: str,
|
|
1894
|
-
request_body: dict[str, Any] | None = None,
|
|
1895
|
-
) -> Any:
|
|
1896
|
-
"""
|
|
1897
|
-
Streams data from a specific chapter snapshot in a project using the API and returns a response indicating success.
|
|
1898
|
-
|
|
1899
|
-
Args:
|
|
1900
|
-
project_id (string): project_id
|
|
1901
|
-
chapter_id (string): chapter_id
|
|
1902
|
-
chapter_snapshot_id (string): chapter_snapshot_id
|
|
1903
|
-
request_body (dict | None): Optional dictionary for an empty JSON request body (e.g., {}).
|
|
1904
|
-
|
|
1905
|
-
Returns:
|
|
1906
|
-
Any: Success / Success
|
|
1907
|
-
|
|
1908
|
-
Raises:
|
|
1909
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
1910
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
1911
|
-
|
|
1912
|
-
Tags:
|
|
1913
|
-
Chapters
|
|
1914
|
-
"""
|
|
1915
|
-
if project_id is None:
|
|
1916
|
-
raise ValueError("Missing required parameter 'project_id'.")
|
|
1917
|
-
if chapter_id is None:
|
|
1918
|
-
raise ValueError("Missing required parameter 'chapter_id'.")
|
|
1919
|
-
if chapter_snapshot_id is None:
|
|
1920
|
-
raise ValueError("Missing required parameter 'chapter_snapshot_id'.")
|
|
1921
|
-
request_body_data = None
|
|
1922
|
-
request_body_data = request_body if request_body is not None else {}
|
|
1923
|
-
url = f"{self.base_url}/v1/projects/{project_id}/chapters/{chapter_id}/snapshots/{chapter_snapshot_id}/stream"
|
|
1924
|
-
query_params = {}
|
|
1925
|
-
response = self._post(
|
|
1926
|
-
url,
|
|
1927
|
-
data=request_body_data,
|
|
1928
|
-
params=query_params,
|
|
1929
|
-
content_type="application/json",
|
|
1930
|
-
)
|
|
1931
|
-
response.raise_for_status()
|
|
1932
|
-
if (
|
|
1933
|
-
response.status_code == 204
|
|
1934
|
-
or not response.content
|
|
1935
|
-
or not response.text.strip()
|
|
1936
|
-
):
|
|
1937
|
-
return None
|
|
1938
|
-
try:
|
|
1939
|
-
return response.json()
|
|
1940
|
-
except ValueError:
|
|
1941
|
-
return None
|
|
1942
|
-
|
|
1943
|
-
def dub_avideo_or_an_audio_file(
|
|
1944
|
-
self, target_lang: str | None = None
|
|
1945
|
-
) -> dict[str, Any]:
|
|
1946
|
-
"""
|
|
1947
|
-
Initiates a dubbing process and returns a status message using the API defined at the "/v1/dubbing" endpoint via the POST method.
|
|
1948
|
-
|
|
1949
|
-
Args:
|
|
1950
|
-
target_lang (string): target_lang Example: 'target_lang'.
|
|
1951
|
-
|
|
1952
|
-
Returns:
|
|
1953
|
-
dict[str, Any]: Success
|
|
1954
|
-
|
|
1955
|
-
Raises:
|
|
1956
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
1957
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
1958
|
-
|
|
1959
|
-
Tags:
|
|
1960
|
-
Dubbing
|
|
1961
|
-
"""
|
|
1962
|
-
request_body_data = None
|
|
1963
|
-
request_body_data = {
|
|
1964
|
-
"target_lang": target_lang,
|
|
1965
|
-
}
|
|
1966
|
-
request_body_data = {
|
|
1967
|
-
k: v for k, v in request_body_data.items() if v is not None
|
|
1968
|
-
}
|
|
1969
|
-
url = f"{self.base_url}/v1/dubbing"
|
|
1970
|
-
query_params = {}
|
|
1971
|
-
response = self._post(
|
|
1972
|
-
url,
|
|
1973
|
-
data=request_body_data,
|
|
1974
|
-
params=query_params,
|
|
1975
|
-
content_type="application/json",
|
|
1976
|
-
)
|
|
1977
|
-
response.raise_for_status()
|
|
1978
|
-
if (
|
|
1979
|
-
response.status_code == 204
|
|
1980
|
-
or not response.content
|
|
1981
|
-
or not response.text.strip()
|
|
1982
|
-
):
|
|
1983
|
-
return None
|
|
1984
|
-
try:
|
|
1985
|
-
return response.json()
|
|
1986
|
-
except ValueError:
|
|
1987
|
-
return None
|
|
1988
|
-
|
|
1989
|
-
def get_dubbing_project_metadata(self, dubbing_id: str) -> dict[str, Any]:
|
|
1990
|
-
"""
|
|
1991
|
-
Retrieves the details of a specific dubbing job using the provided dubbing ID.
|
|
1992
|
-
|
|
1993
|
-
Args:
|
|
1994
|
-
dubbing_id (string): dubbing_id
|
|
1995
|
-
|
|
1996
|
-
Returns:
|
|
1997
|
-
dict[str, Any]: Success / Success
|
|
1998
|
-
|
|
1999
|
-
Raises:
|
|
2000
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
2001
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
2002
|
-
|
|
2003
|
-
Tags:
|
|
2004
|
-
Dubbing
|
|
2005
|
-
"""
|
|
2006
|
-
if dubbing_id is None:
|
|
2007
|
-
raise ValueError("Missing required parameter 'dubbing_id'.")
|
|
2008
|
-
url = f"{self.base_url}/v1/dubbing/{dubbing_id}"
|
|
2009
|
-
query_params = {}
|
|
2010
|
-
response = self._get(url, params=query_params)
|
|
2011
|
-
response.raise_for_status()
|
|
2012
|
-
if (
|
|
2013
|
-
response.status_code == 204
|
|
2014
|
-
or not response.content
|
|
2015
|
-
or not response.text.strip()
|
|
2016
|
-
):
|
|
2017
|
-
return None
|
|
2018
|
-
try:
|
|
2019
|
-
return response.json()
|
|
2020
|
-
except ValueError:
|
|
2021
|
-
return None
|
|
2022
|
-
|
|
2023
|
-
def delete_dubbing_project(self, dubbing_id: str) -> dict[str, Any]:
|
|
2024
|
-
"""
|
|
2025
|
-
Deletes a dubbing project with the specified ID and returns a success status upon completion.
|
|
2026
|
-
|
|
2027
|
-
Args:
|
|
2028
|
-
dubbing_id (string): dubbing_id
|
|
2029
|
-
|
|
2030
|
-
Returns:
|
|
2031
|
-
dict[str, Any]: Success / Success
|
|
2032
|
-
|
|
2033
|
-
Raises:
|
|
2034
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
2035
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
2036
|
-
|
|
2037
|
-
Tags:
|
|
2038
|
-
Dubbing
|
|
2039
|
-
"""
|
|
2040
|
-
if dubbing_id is None:
|
|
2041
|
-
raise ValueError("Missing required parameter 'dubbing_id'.")
|
|
2042
|
-
url = f"{self.base_url}/v1/dubbing/{dubbing_id}"
|
|
2043
|
-
query_params = {}
|
|
2044
|
-
response = self._delete(url, params=query_params)
|
|
2045
|
-
response.raise_for_status()
|
|
2046
|
-
if (
|
|
2047
|
-
response.status_code == 204
|
|
2048
|
-
or not response.content
|
|
2049
|
-
or not response.text.strip()
|
|
2050
|
-
):
|
|
2051
|
-
return None
|
|
2052
|
-
try:
|
|
2053
|
-
return response.json()
|
|
2054
|
-
except ValueError:
|
|
2055
|
-
return None
|
|
2056
|
-
|
|
2057
|
-
def get_transcript_for_dub(
|
|
2058
|
-
self, dubbing_id: str, language_code: str
|
|
2059
|
-
) -> dict[str, Any]:
|
|
2060
|
-
"""
|
|
2061
|
-
Retrieves the transcript for a specific dubbing task in the requested language using the "GET" method.
|
|
2062
|
-
|
|
2063
|
-
Args:
|
|
2064
|
-
dubbing_id (string): dubbing_id
|
|
2065
|
-
language_code (string): language_code
|
|
2066
|
-
|
|
2067
|
-
Returns:
|
|
2068
|
-
dict[str, Any]: Success / Success
|
|
2069
|
-
|
|
2070
|
-
Raises:
|
|
2071
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
2072
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
2073
|
-
|
|
2074
|
-
Tags:
|
|
2075
|
-
Dubbing
|
|
2076
|
-
"""
|
|
2077
|
-
if dubbing_id is None:
|
|
2078
|
-
raise ValueError("Missing required parameter 'dubbing_id'.")
|
|
2079
|
-
if language_code is None:
|
|
2080
|
-
raise ValueError("Missing required parameter 'language_code'.")
|
|
2081
|
-
url = f"{self.base_url}/v1/dubbing/{dubbing_id}/transcript/{language_code}"
|
|
2082
|
-
query_params = {}
|
|
2083
|
-
response = self._get(url, params=query_params)
|
|
2084
|
-
response.raise_for_status()
|
|
2085
|
-
if (
|
|
2086
|
-
response.status_code == 204
|
|
2087
|
-
or not response.content
|
|
2088
|
-
or not response.text.strip()
|
|
2089
|
-
):
|
|
2090
|
-
return None
|
|
2091
|
-
try:
|
|
2092
|
-
return response.json()
|
|
2093
|
-
except ValueError:
|
|
2094
|
-
return None
|
|
2095
|
-
|
|
2096
|
-
def get_models(self) -> list[Any]:
|
|
2097
|
-
"""
|
|
2098
|
-
Retrieves a list of models using the GET method at the "/v1/models" endpoint.
|
|
2099
|
-
|
|
2100
|
-
Returns:
|
|
2101
|
-
list[Any]: Success / Success
|
|
2102
|
-
|
|
2103
|
-
Raises:
|
|
2104
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
2105
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
2106
|
-
|
|
2107
|
-
Tags:
|
|
2108
|
-
Models
|
|
2109
|
-
"""
|
|
2110
|
-
url = f"{self.base_url}/v1/models"
|
|
2111
|
-
query_params = {}
|
|
2112
|
-
response = self._get(url, params=query_params)
|
|
2113
|
-
response.raise_for_status()
|
|
2114
|
-
if (
|
|
2115
|
-
response.status_code == 204
|
|
2116
|
-
or not response.content
|
|
2117
|
-
or not response.text.strip()
|
|
2118
|
-
):
|
|
2119
|
-
return None
|
|
2120
|
-
try:
|
|
2121
|
-
return response.json()
|
|
2122
|
-
except ValueError:
|
|
2123
|
-
return None
|
|
2124
|
-
|
|
2125
|
-
def post_audio_native(self, name: str | None = None) -> dict[str, Any]:
|
|
2126
|
-
"""
|
|
2127
|
-
Processes audio data using the audio-native API and returns a response.
|
|
2128
|
-
|
|
2129
|
-
Args:
|
|
2130
|
-
name (string): name Example: 'name'.
|
|
2131
|
-
|
|
2132
|
-
Returns:
|
|
2133
|
-
dict[str, Any]: Success
|
|
2134
|
-
|
|
2135
|
-
Raises:
|
|
2136
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
2137
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
2138
|
-
|
|
2139
|
-
Tags:
|
|
2140
|
-
Audio Native
|
|
2141
|
-
"""
|
|
2142
|
-
request_body_data = None
|
|
2143
|
-
request_body_data = {
|
|
2144
|
-
"name": name,
|
|
2145
|
-
}
|
|
2146
|
-
request_body_data = {
|
|
2147
|
-
k: v for k, v in request_body_data.items() if v is not None
|
|
2148
|
-
}
|
|
2149
|
-
url = f"{self.base_url}/v1/audio-native"
|
|
2150
|
-
query_params = {}
|
|
2151
|
-
response = self._post(
|
|
2152
|
-
url,
|
|
2153
|
-
data=request_body_data,
|
|
2154
|
-
params=query_params,
|
|
2155
|
-
content_type="application/json",
|
|
2156
|
-
)
|
|
2157
|
-
response.raise_for_status()
|
|
2158
|
-
if (
|
|
2159
|
-
response.status_code == 204
|
|
2160
|
-
or not response.content
|
|
2161
|
-
or not response.text.strip()
|
|
2162
|
-
):
|
|
2163
|
-
return None
|
|
2164
|
-
try:
|
|
2165
|
-
return response.json()
|
|
2166
|
-
except ValueError:
|
|
2167
|
-
return None
|
|
2168
|
-
|
|
2169
|
-
def get_characters_usage_metrics(
|
|
2170
|
-
self, start_unix: str | None = None, end_unix: str | None = None
|
|
2171
|
-
) -> dict[str, Any]:
|
|
2172
|
-
"""
|
|
2173
|
-
Retrieves character statistics within a specified time frame using the start and end Unix timestamps provided in the query parameters.
|
|
2174
|
-
|
|
2175
|
-
Args:
|
|
2176
|
-
start_unix (string): UTC Unix timestamp for the start of the usage window, in milliseconds. To include the first day of the window, the timestamp should be at 00:00:00 of that day. Example: '1'.
|
|
2177
|
-
end_unix (string): UTC Unix timestamp for the end of the usage window, in milliseconds. To include the last day of the window, the timestamp should be at 23:59:59 of that day. Example: '1'.
|
|
2178
|
-
|
|
2179
|
-
Returns:
|
|
2180
|
-
dict[str, Any]: Success / Success
|
|
2181
|
-
|
|
2182
|
-
Raises:
|
|
2183
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
2184
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
2185
|
-
|
|
2186
|
-
Tags:
|
|
2187
|
-
Usage
|
|
2188
|
-
"""
|
|
2189
|
-
url = f"{self.base_url}/v1/usage/character-stats"
|
|
2190
|
-
query_params = {
|
|
2191
|
-
k: v
|
|
2192
|
-
for k, v in [("start_unix", start_unix), ("end_unix", end_unix)]
|
|
2193
|
-
if v is not None
|
|
2194
|
-
}
|
|
2195
|
-
response = self._get(url, params=query_params)
|
|
2196
|
-
response.raise_for_status()
|
|
2197
|
-
if (
|
|
2198
|
-
response.status_code == 204
|
|
2199
|
-
or not response.content
|
|
2200
|
-
or not response.text.strip()
|
|
2201
|
-
):
|
|
2202
|
-
return None
|
|
2203
|
-
try:
|
|
2204
|
-
return response.json()
|
|
2205
|
-
except ValueError:
|
|
2206
|
-
return None
|
|
2207
|
-
|
|
2208
|
-
def add_apronunciation_dictionary(
|
|
2209
|
-
self, name: str | None = None
|
|
2210
|
-
) -> dict[str, Any]:
|
|
2211
|
-
"""
|
|
2212
|
-
Creates a pronunciation dictionary from a lexicon file and returns its ID and metadata.
|
|
2213
|
-
|
|
2214
|
-
Args:
|
|
2215
|
-
name (string): name Example: 'name'.
|
|
2216
|
-
|
|
2217
|
-
Returns:
|
|
2218
|
-
dict[str, Any]: Success
|
|
2219
|
-
|
|
2220
|
-
Raises:
|
|
2221
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
2222
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
2223
|
-
|
|
2224
|
-
Tags:
|
|
2225
|
-
Pronunciation Dictionary
|
|
2226
|
-
"""
|
|
2227
|
-
request_body_data = None
|
|
2228
|
-
request_body_data = {
|
|
2229
|
-
"name": name,
|
|
2230
|
-
}
|
|
2231
|
-
request_body_data = {
|
|
2232
|
-
k: v for k, v in request_body_data.items() if v is not None
|
|
2233
|
-
}
|
|
2234
|
-
url = f"{self.base_url}/v1/pronunciation-dictionaries/add-from-file"
|
|
2235
|
-
query_params = {}
|
|
2236
|
-
response = self._post(
|
|
2237
|
-
url,
|
|
2238
|
-
data=request_body_data,
|
|
2239
|
-
params=query_params,
|
|
2240
|
-
content_type="application/json",
|
|
2241
|
-
)
|
|
2242
|
-
response.raise_for_status()
|
|
2243
|
-
if (
|
|
2244
|
-
response.status_code == 204
|
|
2245
|
-
or not response.content
|
|
2246
|
-
or not response.text.strip()
|
|
2247
|
-
):
|
|
2248
|
-
return None
|
|
2249
|
-
try:
|
|
2250
|
-
return response.json()
|
|
2251
|
-
except ValueError:
|
|
2252
|
-
return None
|
|
2253
|
-
|
|
2254
|
-
def add_rules_to_dictionary(
|
|
2255
|
-
self,
|
|
2256
|
-
pronunciation_dictionary_id: str,
|
|
2257
|
-
rules: list[dict[str, Any]] | None = None,
|
|
2258
|
-
) -> dict[str, Any]:
|
|
2259
|
-
"""
|
|
2260
|
-
Adds pronunciation rules to a specific pronunciation dictionary identified by its ID using the POST method.
|
|
2261
|
-
|
|
2262
|
-
Args:
|
|
2263
|
-
pronunciation_dictionary_id (string): pronunciation_dictionary_id
|
|
2264
|
-
rules (array): rules Example: "[{'alias': 'alias', 'string_to_replace': 'string_to_replace', 'type': 'alias'}, {'alias': 'alias', 'string_to_replace': 'string_to_replace', 'type': 'alias'}]".
|
|
2265
|
-
|
|
2266
|
-
Returns:
|
|
2267
|
-
dict[str, Any]: Success / Success
|
|
2268
|
-
|
|
2269
|
-
Raises:
|
|
2270
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
2271
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
2272
|
-
|
|
2273
|
-
Tags:
|
|
2274
|
-
Pronunciation Dictionary
|
|
2275
|
-
"""
|
|
2276
|
-
if pronunciation_dictionary_id is None:
|
|
2277
|
-
raise ValueError(
|
|
2278
|
-
"Missing required parameter 'pronunciation_dictionary_id'."
|
|
2279
|
-
)
|
|
2280
|
-
request_body_data = None
|
|
2281
|
-
request_body_data = {
|
|
2282
|
-
"rules": rules,
|
|
2283
|
-
}
|
|
2284
|
-
request_body_data = {
|
|
2285
|
-
k: v for k, v in request_body_data.items() if v is not None
|
|
2286
|
-
}
|
|
2287
|
-
url = f"{self.base_url}/v1/pronunciation-dictionaries/{pronunciation_dictionary_id}/add-rules"
|
|
2288
|
-
query_params = {}
|
|
2289
|
-
response = self._post(
|
|
2290
|
-
url,
|
|
2291
|
-
data=request_body_data,
|
|
2292
|
-
params=query_params,
|
|
2293
|
-
content_type="application/json",
|
|
2294
|
-
)
|
|
2295
|
-
response.raise_for_status()
|
|
2296
|
-
if (
|
|
2297
|
-
response.status_code == 204
|
|
2298
|
-
or not response.content
|
|
2299
|
-
or not response.text.strip()
|
|
2300
|
-
):
|
|
2301
|
-
return None
|
|
2302
|
-
try:
|
|
2303
|
-
return response.json()
|
|
2304
|
-
except ValueError:
|
|
2305
|
-
return None
|
|
2306
|
-
|
|
2307
|
-
def remove_pronunciation_rules(
|
|
2308
|
-
self, pronunciation_dictionary_id: str, rule_strings: list[str] | None = None
|
|
2309
|
-
) -> dict[str, Any]:
|
|
2310
|
-
"""
|
|
2311
|
-
Removes specified pronunciation rules from a pronunciation dictionary using a POST request.
|
|
2312
|
-
|
|
2313
|
-
Args:
|
|
2314
|
-
pronunciation_dictionary_id (string): pronunciation_dictionary_id
|
|
2315
|
-
rule_strings (array): rule_strings Example: "['rule_strings', 'rule_strings']".
|
|
2316
|
-
|
|
2317
|
-
Returns:
|
|
2318
|
-
dict[str, Any]: Success / Success
|
|
2319
|
-
|
|
2320
|
-
Raises:
|
|
2321
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
2322
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
2323
|
-
|
|
2324
|
-
Tags:
|
|
2325
|
-
Pronunciation Dictionary
|
|
2326
|
-
"""
|
|
2327
|
-
if pronunciation_dictionary_id is None:
|
|
2328
|
-
raise ValueError(
|
|
2329
|
-
"Missing required parameter 'pronunciation_dictionary_id'."
|
|
2330
|
-
)
|
|
2331
|
-
request_body_data = None
|
|
2332
|
-
request_body_data = {
|
|
2333
|
-
"rule_strings": rule_strings,
|
|
2334
|
-
}
|
|
2335
|
-
request_body_data = {
|
|
2336
|
-
k: v for k, v in request_body_data.items() if v is not None
|
|
2337
|
-
}
|
|
2338
|
-
url = f"{self.base_url}/v1/pronunciation-dictionaries/{pronunciation_dictionary_id}/remove-rules"
|
|
2339
|
-
query_params = {}
|
|
2340
|
-
response = self._post(
|
|
2341
|
-
url,
|
|
2342
|
-
data=request_body_data,
|
|
2343
|
-
params=query_params,
|
|
2344
|
-
content_type="application/json",
|
|
2345
|
-
)
|
|
2346
|
-
response.raise_for_status()
|
|
2347
|
-
if (
|
|
2348
|
-
response.status_code == 204
|
|
2349
|
-
or not response.content
|
|
2350
|
-
or not response.text.strip()
|
|
2351
|
-
):
|
|
2352
|
-
return None
|
|
2353
|
-
try:
|
|
2354
|
-
return response.json()
|
|
2355
|
-
except ValueError:
|
|
2356
|
-
return None
|
|
2357
|
-
|
|
2358
|
-
def get_dictionary_version_file(self, dictionary_id: str, version_id: str) -> Any:
|
|
2359
|
-
"""
|
|
2360
|
-
Retrieves and downloads a specific version of a pronunciation dictionary file using its dictionary ID and version ID.
|
|
2361
|
-
|
|
2362
|
-
Args:
|
|
2363
|
-
dictionary_id (string): dictionary_id
|
|
2364
|
-
version_id (string): version_id
|
|
2365
|
-
|
|
2366
|
-
Returns:
|
|
2367
|
-
Any: Success
|
|
2368
|
-
|
|
2369
|
-
Raises:
|
|
2370
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
2371
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
2372
|
-
|
|
2373
|
-
Tags:
|
|
2374
|
-
Pronunciation Dictionary
|
|
2375
|
-
"""
|
|
2376
|
-
if dictionary_id is None:
|
|
2377
|
-
raise ValueError("Missing required parameter 'dictionary_id'.")
|
|
2378
|
-
if version_id is None:
|
|
2379
|
-
raise ValueError("Missing required parameter 'version_id'.")
|
|
2380
|
-
url = f"{self.base_url}/v1/pronunciation-dictionaries/{dictionary_id}/{version_id}/download"
|
|
2381
|
-
query_params = {}
|
|
2382
|
-
response = self._get(url, params=query_params)
|
|
2383
|
-
response.raise_for_status()
|
|
2384
|
-
if (
|
|
2385
|
-
response.status_code == 204
|
|
2386
|
-
or not response.content
|
|
2387
|
-
or not response.text.strip()
|
|
2388
|
-
):
|
|
2389
|
-
return None
|
|
2390
|
-
try:
|
|
2391
|
-
return response.json()
|
|
2392
|
-
except ValueError:
|
|
2393
|
-
return None
|
|
2394
|
-
|
|
2395
|
-
def get_pronunciation_dictionary(
|
|
2396
|
-
self, pronunciation_dictionary_id: str
|
|
2397
|
-
) -> dict[str, Any]:
|
|
2398
|
-
"""
|
|
2399
|
-
Retrieves a specific pronunciation dictionary by its ID using the "GET" method from the "/v1/pronunciation-dictionaries/{pronunciation_dictionary_id}" endpoint.
|
|
2400
|
-
|
|
2401
|
-
Args:
|
|
2402
|
-
pronunciation_dictionary_id (string): pronunciation_dictionary_id
|
|
2403
|
-
|
|
2404
|
-
Returns:
|
|
2405
|
-
dict[str, Any]: Success / Success
|
|
2406
|
-
|
|
2407
|
-
Raises:
|
|
2408
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
2409
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
2410
|
-
|
|
2411
|
-
Tags:
|
|
2412
|
-
Pronunciation Dictionary
|
|
2413
|
-
"""
|
|
2414
|
-
if pronunciation_dictionary_id is None:
|
|
2415
|
-
raise ValueError(
|
|
2416
|
-
"Missing required parameter 'pronunciation_dictionary_id'."
|
|
2417
|
-
)
|
|
2418
|
-
url = f"{self.base_url}/v1/pronunciation-dictionaries/{pronunciation_dictionary_id}"
|
|
2419
|
-
query_params = {}
|
|
2420
|
-
response = self._get(url, params=query_params)
|
|
2421
|
-
response.raise_for_status()
|
|
2422
|
-
if (
|
|
2423
|
-
response.status_code == 204
|
|
2424
|
-
or not response.content
|
|
2425
|
-
or not response.text.strip()
|
|
2426
|
-
):
|
|
2427
|
-
return None
|
|
2428
|
-
try:
|
|
2429
|
-
return response.json()
|
|
2430
|
-
except ValueError:
|
|
2431
|
-
return None
|
|
2432
|
-
|
|
2433
|
-
def get_pronunciation_dictionaries(
|
|
2434
|
-
self, page_size: str | None = None
|
|
2435
|
-
) -> dict[str, Any]:
|
|
2436
|
-
"""
|
|
2437
|
-
Retrieves a list of pronunciation dictionaries using the GET method at the "/v1/pronunciation-dictionaries" endpoint, allowing users to specify the number of items per page via the "page_size" query parameter.
|
|
2438
|
-
|
|
2439
|
-
Args:
|
|
2440
|
-
page_size (string): How many pronunciation dictionaries to return at maximum. Can not exceed 100, defaults to 30. Example: '1'.
|
|
2441
|
-
|
|
2442
|
-
Returns:
|
|
2443
|
-
dict[str, Any]: Success / Success
|
|
2444
|
-
|
|
2445
|
-
Raises:
|
|
2446
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
2447
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
2448
|
-
|
|
2449
|
-
Tags:
|
|
2450
|
-
Pronunciation Dictionary
|
|
2451
|
-
"""
|
|
2452
|
-
url = f"{self.base_url}/v1/pronunciation-dictionaries"
|
|
2453
|
-
query_params = {k: v for k, v in [("page_size", page_size)] if v is not None}
|
|
2454
|
-
response = self._get(url, params=query_params)
|
|
2455
|
-
response.raise_for_status()
|
|
2456
|
-
if (
|
|
2457
|
-
response.status_code == 204
|
|
2458
|
-
or not response.content
|
|
2459
|
-
or not response.text.strip()
|
|
2460
|
-
):
|
|
2461
|
-
return None
|
|
2462
|
-
try:
|
|
2463
|
-
return response.json()
|
|
2464
|
-
except ValueError:
|
|
2465
|
-
return None
|
|
2466
|
-
|
|
2467
|
-
def invite_user(self, email: str | None = None) -> dict[str, Any]:
|
|
2468
|
-
"""
|
|
2469
|
-
Invites a user to join a workspace by sending an invitation, allowing them to access the specified workspace upon acceptance.
|
|
2470
|
-
|
|
2471
|
-
Args:
|
|
2472
|
-
email (string): email Example: 'email'.
|
|
2473
|
-
|
|
2474
|
-
Returns:
|
|
2475
|
-
dict[str, Any]: Success / Success
|
|
2476
|
-
|
|
2477
|
-
Raises:
|
|
2478
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
2479
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
2480
|
-
|
|
2481
|
-
Tags:
|
|
2482
|
-
Workspace
|
|
2483
|
-
"""
|
|
2484
|
-
request_body_data = None
|
|
2485
|
-
request_body_data = {
|
|
2486
|
-
"email": email,
|
|
2487
|
-
}
|
|
2488
|
-
request_body_data = {
|
|
2489
|
-
k: v for k, v in request_body_data.items() if v is not None
|
|
2490
|
-
}
|
|
2491
|
-
url = f"{self.base_url}/v1/workspace/invites/add"
|
|
2492
|
-
query_params = {}
|
|
2493
|
-
response = self._post(
|
|
2494
|
-
url,
|
|
2495
|
-
data=request_body_data,
|
|
2496
|
-
params=query_params,
|
|
2497
|
-
content_type="application/json",
|
|
2498
|
-
)
|
|
2499
|
-
response.raise_for_status()
|
|
2500
|
-
if (
|
|
2501
|
-
response.status_code == 204
|
|
2502
|
-
or not response.content
|
|
2503
|
-
or not response.text.strip()
|
|
2504
|
-
):
|
|
2505
|
-
return None
|
|
2506
|
-
try:
|
|
2507
|
-
return response.json()
|
|
2508
|
-
except ValueError:
|
|
2509
|
-
return None
|
|
2510
|
-
|
|
2511
|
-
def delete_existing_invitation(self, email: str | None = None) -> dict[str, Any]:
|
|
2512
|
-
"""
|
|
2513
|
-
Deletes a workspace invite and returns a success response upon completion.
|
|
2514
|
-
|
|
2515
|
-
Args:
|
|
2516
|
-
email (string): email Example: 'email'.
|
|
2517
|
-
|
|
2518
|
-
Returns:
|
|
2519
|
-
dict[str, Any]: Success / Success
|
|
2520
|
-
|
|
2521
|
-
Raises:
|
|
2522
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
2523
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
2524
|
-
|
|
2525
|
-
Tags:
|
|
2526
|
-
Workspace
|
|
2527
|
-
"""
|
|
2528
|
-
request_body_data = {
|
|
2529
|
-
"email": email,
|
|
2530
|
-
}
|
|
2531
|
-
request_body_data = {
|
|
2532
|
-
k: v for k, v in request_body_data.items() if v is not None
|
|
2533
|
-
}
|
|
2534
|
-
url = f"{self.base_url}/v1/workspace/invites"
|
|
2535
|
-
query_params = {}
|
|
2536
|
-
response = self._delete(url, params=query_params)
|
|
2537
|
-
response.raise_for_status()
|
|
2538
|
-
if (
|
|
2539
|
-
response.status_code == 204
|
|
2540
|
-
or not response.content
|
|
2541
|
-
or not response.text.strip()
|
|
2542
|
-
):
|
|
2543
|
-
return None
|
|
2544
|
-
try:
|
|
2545
|
-
return response.json()
|
|
2546
|
-
except ValueError:
|
|
2547
|
-
return None
|
|
2548
|
-
|
|
2549
|
-
def update_member(self, email: str | None = None) -> dict[str, Any]:
|
|
2550
|
-
"""
|
|
2551
|
-
Adds members to a workspace and returns the updated member list upon success.
|
|
2552
|
-
|
|
2553
|
-
Args:
|
|
2554
|
-
email (string): email Example: 'email'.
|
|
2555
|
-
|
|
2556
|
-
Returns:
|
|
2557
|
-
dict[str, Any]: Success / Success
|
|
2558
|
-
|
|
2559
|
-
Raises:
|
|
2560
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
2561
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
2562
|
-
|
|
2563
|
-
Tags:
|
|
2564
|
-
Workspace
|
|
2565
|
-
"""
|
|
2566
|
-
request_body_data = None
|
|
2567
|
-
request_body_data = {
|
|
2568
|
-
"email": email,
|
|
2569
|
-
}
|
|
2570
|
-
request_body_data = {
|
|
2571
|
-
k: v for k, v in request_body_data.items() if v is not None
|
|
2572
|
-
}
|
|
2573
|
-
url = f"{self.base_url}/v1/workspace/members"
|
|
2574
|
-
query_params = {}
|
|
2575
|
-
response = self._post(
|
|
2576
|
-
url,
|
|
2577
|
-
data=request_body_data,
|
|
2578
|
-
params=query_params,
|
|
2579
|
-
content_type="application/json",
|
|
2580
|
-
)
|
|
2581
|
-
response.raise_for_status()
|
|
2582
|
-
if (
|
|
2583
|
-
response.status_code == 204
|
|
2584
|
-
or not response.content
|
|
2585
|
-
or not response.text.strip()
|
|
2586
|
-
):
|
|
2587
|
-
return None
|
|
2588
|
-
try:
|
|
2589
|
-
return response.json()
|
|
2590
|
-
except ValueError:
|
|
2591
|
-
return None
|
|
2592
|
-
|
|
2593
|
-
def get_signed_url(self, agent_id: str | None = None) -> dict[str, Any]:
|
|
2594
|
-
"""
|
|
2595
|
-
Generates a signed URL for initiating a conversation with a specific conversational AI agent, identified by the provided `agent_id`, using the ElevenLabs API.
|
|
2596
|
-
|
|
2597
|
-
Args:
|
|
2598
|
-
agent_id (string): The id of the agent you're taking the action on. Example: '21m00Tcm4TlvDq8ikWAM'.
|
|
2599
|
-
|
|
2600
|
-
Returns:
|
|
2601
|
-
dict[str, Any]: Success / Success
|
|
2602
|
-
|
|
2603
|
-
Raises:
|
|
2604
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
2605
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
2606
|
-
|
|
2607
|
-
Tags:
|
|
2608
|
-
Conversational Ai
|
|
2609
|
-
"""
|
|
2610
|
-
url = f"{self.base_url}/v1/convai/conversation/get_signed_url"
|
|
2611
|
-
query_params = {k: v for k, v in [("agent_id", agent_id)] if v is not None}
|
|
2612
|
-
response = self._get(url, params=query_params)
|
|
2613
|
-
response.raise_for_status()
|
|
2614
|
-
if (
|
|
2615
|
-
response.status_code == 204
|
|
2616
|
-
or not response.content
|
|
2617
|
-
or not response.text.strip()
|
|
2618
|
-
):
|
|
2619
|
-
return None
|
|
2620
|
-
try:
|
|
2621
|
-
return response.json()
|
|
2622
|
-
except ValueError:
|
|
2623
|
-
return None
|
|
2624
|
-
|
|
2625
|
-
def create_agent(
|
|
2626
|
-
self, conversation_config: dict[str, Any] | None = None
|
|
2627
|
-
) -> dict[str, Any]:
|
|
2628
|
-
"""
|
|
2629
|
-
Creates a conversational AI agent with specified configuration settings and returns the agent details.
|
|
2630
|
-
|
|
2631
|
-
Args:
|
|
2632
|
-
conversation_config (object): conversation_config Example: {}.
|
|
2633
|
-
|
|
2634
|
-
Returns:
|
|
2635
|
-
dict[str, Any]: Success / Success
|
|
2636
|
-
|
|
2637
|
-
Raises:
|
|
2638
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
2639
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
2640
|
-
|
|
2641
|
-
Tags:
|
|
2642
|
-
Conversational Ai
|
|
2643
|
-
"""
|
|
2644
|
-
request_body_data = None
|
|
2645
|
-
request_body_data = {
|
|
2646
|
-
"conversation_config": conversation_config,
|
|
2647
|
-
}
|
|
2648
|
-
request_body_data = {
|
|
2649
|
-
k: v for k, v in request_body_data.items() if v is not None
|
|
2650
|
-
}
|
|
2651
|
-
url = f"{self.base_url}/v1/convai/agents/create"
|
|
2652
|
-
query_params = {}
|
|
2653
|
-
response = self._post(
|
|
2654
|
-
url,
|
|
2655
|
-
data=request_body_data,
|
|
2656
|
-
params=query_params,
|
|
2657
|
-
content_type="application/json",
|
|
2658
|
-
)
|
|
2659
|
-
response.raise_for_status()
|
|
2660
|
-
if (
|
|
2661
|
-
response.status_code == 204
|
|
2662
|
-
or not response.content
|
|
2663
|
-
or not response.text.strip()
|
|
2664
|
-
):
|
|
2665
|
-
return None
|
|
2666
|
-
try:
|
|
2667
|
-
return response.json()
|
|
2668
|
-
except ValueError:
|
|
2669
|
-
return None
|
|
2670
|
-
|
|
2671
|
-
def get_agent(self, agent_id: str) -> dict[str, Any]:
|
|
2672
|
-
"""
|
|
2673
|
-
Retrieves information about a specific conversational AI agent by its unique identifier using the GET method at the "/v1/convai/agents/{agent_id}" API endpoint.
|
|
2674
|
-
|
|
2675
|
-
Args:
|
|
2676
|
-
agent_id (string): agent_id
|
|
2677
|
-
|
|
2678
|
-
Returns:
|
|
2679
|
-
dict[str, Any]: Success / Success
|
|
2680
|
-
|
|
2681
|
-
Raises:
|
|
2682
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
2683
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
2684
|
-
|
|
2685
|
-
Tags:
|
|
2686
|
-
Conversational Ai
|
|
2687
|
-
"""
|
|
2688
|
-
if agent_id is None:
|
|
2689
|
-
raise ValueError("Missing required parameter 'agent_id'.")
|
|
2690
|
-
url = f"{self.base_url}/v1/convai/agents/{agent_id}"
|
|
2691
|
-
query_params = {}
|
|
2692
|
-
response = self._get(url, params=query_params)
|
|
2693
|
-
response.raise_for_status()
|
|
2694
|
-
if (
|
|
2695
|
-
response.status_code == 204
|
|
2696
|
-
or not response.content
|
|
2697
|
-
or not response.text.strip()
|
|
2698
|
-
):
|
|
2699
|
-
return None
|
|
2700
|
-
try:
|
|
2701
|
-
return response.json()
|
|
2702
|
-
except ValueError:
|
|
2703
|
-
return None
|
|
2704
|
-
|
|
2705
|
-
def delete_agent(self, agent_id: str) -> dict[str, Any]:
|
|
2706
|
-
"""
|
|
2707
|
-
Deletes a specified Conversational AI agent using the DELETE method.
|
|
2708
|
-
|
|
2709
|
-
Args:
|
|
2710
|
-
agent_id (string): agent_id
|
|
2711
|
-
|
|
2712
|
-
Returns:
|
|
2713
|
-
dict[str, Any]: Success / Success
|
|
2714
|
-
|
|
2715
|
-
Raises:
|
|
2716
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
2717
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
2718
|
-
|
|
2719
|
-
Tags:
|
|
2720
|
-
Conversational Ai
|
|
2721
|
-
"""
|
|
2722
|
-
if agent_id is None:
|
|
2723
|
-
raise ValueError("Missing required parameter 'agent_id'.")
|
|
2724
|
-
url = f"{self.base_url}/v1/convai/agents/{agent_id}"
|
|
2725
|
-
query_params = {}
|
|
2726
|
-
response = self._delete(url, params=query_params)
|
|
2727
|
-
response.raise_for_status()
|
|
2728
|
-
if (
|
|
2729
|
-
response.status_code == 204
|
|
2730
|
-
or not response.content
|
|
2731
|
-
or not response.text.strip()
|
|
2732
|
-
):
|
|
2733
|
-
return None
|
|
2734
|
-
try:
|
|
2735
|
-
return response.json()
|
|
2736
|
-
except ValueError:
|
|
2737
|
-
return None
|
|
2738
|
-
|
|
2739
|
-
def patches_an_agent_settings(
|
|
2740
|
-
self, agent_id: str, request_body: dict[str, Any] | None = None
|
|
2741
|
-
) -> dict[str, Any]:
|
|
2742
|
-
"""
|
|
2743
|
-
Updates an existing conversational AI agent's settings using the specified agent ID, allowing changes to properties such as the agent's name and tool configurations.
|
|
2744
|
-
|
|
2745
|
-
Args:
|
|
2746
|
-
agent_id (string): agent_id
|
|
2747
|
-
request_body (dict | None): Optional dictionary for an empty JSON request body (e.g., {}).
|
|
2748
|
-
|
|
2749
|
-
Returns:
|
|
2750
|
-
dict[str, Any]: Success / Success
|
|
2751
|
-
|
|
2752
|
-
Raises:
|
|
2753
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
2754
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
2755
|
-
|
|
2756
|
-
Tags:
|
|
2757
|
-
Conversational Ai
|
|
2758
|
-
"""
|
|
2759
|
-
if agent_id is None:
|
|
2760
|
-
raise ValueError("Missing required parameter 'agent_id'.")
|
|
2761
|
-
request_body_data = None
|
|
2762
|
-
request_body_data = request_body if request_body is not None else {}
|
|
2763
|
-
url = f"{self.base_url}/v1/convai/agents/{agent_id}"
|
|
2764
|
-
query_params = {}
|
|
2765
|
-
response = self._patch(url, data=request_body_data, params=query_params)
|
|
2766
|
-
response.raise_for_status()
|
|
2767
|
-
if (
|
|
2768
|
-
response.status_code == 204
|
|
2769
|
-
or not response.content
|
|
2770
|
-
or not response.text.strip()
|
|
2771
|
-
):
|
|
2772
|
-
return None
|
|
2773
|
-
try:
|
|
2774
|
-
return response.json()
|
|
2775
|
-
except ValueError:
|
|
2776
|
-
return None
|
|
2777
|
-
|
|
2778
|
-
def get_agent_widget_config(self, agent_id: str) -> dict[str, Any]:
|
|
2779
|
-
"""
|
|
2780
|
-
Retrieves and configures the Convai widget for the specified agent, but the provided details do not specify the exact functionality of this specific endpoint, suggesting it may relate to integrating or customizing Convai's character interaction capabilities.
|
|
2781
|
-
|
|
2782
|
-
Args:
|
|
2783
|
-
agent_id (string): agent_id
|
|
2784
|
-
|
|
2785
|
-
Returns:
|
|
2786
|
-
dict[str, Any]: Success / Success
|
|
2787
|
-
|
|
2788
|
-
Raises:
|
|
2789
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
2790
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
2791
|
-
|
|
2792
|
-
Tags:
|
|
2793
|
-
Conversational Ai
|
|
2794
|
-
"""
|
|
2795
|
-
if agent_id is None:
|
|
2796
|
-
raise ValueError("Missing required parameter 'agent_id'.")
|
|
2797
|
-
url = f"{self.base_url}/v1/convai/agents/{agent_id}/widget"
|
|
2798
|
-
query_params = {}
|
|
2799
|
-
response = self._get(url, params=query_params)
|
|
2800
|
-
response.raise_for_status()
|
|
2801
|
-
if (
|
|
2802
|
-
response.status_code == 204
|
|
2803
|
-
or not response.content
|
|
2804
|
-
or not response.text.strip()
|
|
2805
|
-
):
|
|
2806
|
-
return None
|
|
2807
|
-
try:
|
|
2808
|
-
return response.json()
|
|
2809
|
-
except ValueError:
|
|
2810
|
-
return None
|
|
2811
|
-
|
|
2812
|
-
def get_shareable_agent_link(self, agent_id: str) -> dict[str, Any]:
|
|
2813
|
-
"""
|
|
2814
|
-
Retrieves and establishes a link for a Convai agent using the specified agent ID, facilitating integration or connectivity operations.
|
|
2815
|
-
|
|
2816
|
-
Args:
|
|
2817
|
-
agent_id (string): agent_id
|
|
2818
|
-
|
|
2819
|
-
Returns:
|
|
2820
|
-
dict[str, Any]: Success / Success
|
|
2821
|
-
|
|
2822
|
-
Raises:
|
|
2823
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
2824
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
2825
|
-
|
|
2826
|
-
Tags:
|
|
2827
|
-
Conversational Ai
|
|
2828
|
-
"""
|
|
2829
|
-
if agent_id is None:
|
|
2830
|
-
raise ValueError("Missing required parameter 'agent_id'.")
|
|
2831
|
-
url = f"{self.base_url}/v1/convai/agents/{agent_id}/link"
|
|
2832
|
-
query_params = {}
|
|
2833
|
-
response = self._get(url, params=query_params)
|
|
2834
|
-
response.raise_for_status()
|
|
2835
|
-
if (
|
|
2836
|
-
response.status_code == 204
|
|
2837
|
-
or not response.content
|
|
2838
|
-
or not response.text.strip()
|
|
2839
|
-
):
|
|
2840
|
-
return None
|
|
2841
|
-
try:
|
|
2842
|
-
return response.json()
|
|
2843
|
-
except ValueError:
|
|
2844
|
-
return None
|
|
2845
|
-
|
|
2846
|
-
def post_agent_avatar(
|
|
2847
|
-
self, agent_id: str, request_body: dict[str, Any] | None = None
|
|
2848
|
-
) -> dict[str, Any]:
|
|
2849
|
-
"""
|
|
2850
|
-
Creates and configures a Convai avatar for a specific agent using the POST method, though the exact details of this endpoint are not provided in the available documentation.
|
|
2851
|
-
|
|
2852
|
-
Args:
|
|
2853
|
-
agent_id (string): agent_id
|
|
2854
|
-
request_body (dict | None): Optional dictionary for an empty JSON request body (e.g., {}).
|
|
2855
|
-
|
|
2856
|
-
Returns:
|
|
2857
|
-
dict[str, Any]: Success
|
|
2858
|
-
|
|
2859
|
-
Raises:
|
|
2860
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
2861
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
2862
|
-
|
|
2863
|
-
Tags:
|
|
2864
|
-
Conversational Ai
|
|
2865
|
-
"""
|
|
2866
|
-
if agent_id is None:
|
|
2867
|
-
raise ValueError("Missing required parameter 'agent_id'.")
|
|
2868
|
-
request_body_data = None
|
|
2869
|
-
request_body_data = request_body if request_body is not None else {}
|
|
2870
|
-
url = f"{self.base_url}/v1/convai/agents/{agent_id}/avatar"
|
|
2871
|
-
query_params = {}
|
|
2872
|
-
response = self._post(
|
|
2873
|
-
url,
|
|
2874
|
-
data=request_body_data,
|
|
2875
|
-
params=query_params,
|
|
2876
|
-
content_type="application/json",
|
|
2877
|
-
)
|
|
2878
|
-
response.raise_for_status()
|
|
2879
|
-
if (
|
|
2880
|
-
response.status_code == 204
|
|
2881
|
-
or not response.content
|
|
2882
|
-
or not response.text.strip()
|
|
2883
|
-
):
|
|
2884
|
-
return None
|
|
2885
|
-
try:
|
|
2886
|
-
return response.json()
|
|
2887
|
-
except ValueError:
|
|
2888
|
-
return None
|
|
2889
|
-
|
|
2890
|
-
def get_agent_knowledge_base(
|
|
2891
|
-
self, agent_id: str, documentation_id: str
|
|
2892
|
-
) -> dict[str, Any]:
|
|
2893
|
-
"""
|
|
2894
|
-
Retrieves specific documentation for a knowledge base associated with an agent in Convai.
|
|
2895
|
-
|
|
2896
|
-
Args:
|
|
2897
|
-
agent_id (string): agent_id
|
|
2898
|
-
documentation_id (string): documentation_id
|
|
2899
|
-
|
|
2900
|
-
Returns:
|
|
2901
|
-
dict[str, Any]: Success / Success
|
|
2902
|
-
|
|
2903
|
-
Raises:
|
|
2904
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
2905
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
2906
|
-
|
|
2907
|
-
Tags:
|
|
2908
|
-
Conversational Ai
|
|
2909
|
-
"""
|
|
2910
|
-
if agent_id is None:
|
|
2911
|
-
raise ValueError("Missing required parameter 'agent_id'.")
|
|
2912
|
-
if documentation_id is None:
|
|
2913
|
-
raise ValueError("Missing required parameter 'documentation_id'.")
|
|
2914
|
-
url = f"{self.base_url}/v1/convai/agents/{agent_id}/knowledge-base/{documentation_id}"
|
|
2915
|
-
query_params = {}
|
|
2916
|
-
response = self._get(url, params=query_params)
|
|
2917
|
-
response.raise_for_status()
|
|
2918
|
-
if (
|
|
2919
|
-
response.status_code == 204
|
|
2920
|
-
or not response.content
|
|
2921
|
-
or not response.text.strip()
|
|
2922
|
-
):
|
|
2923
|
-
return None
|
|
2924
|
-
try:
|
|
2925
|
-
return response.json()
|
|
2926
|
-
except ValueError:
|
|
2927
|
-
return None
|
|
2928
|
-
|
|
2929
|
-
def add_agent_secret(
|
|
2930
|
-
self,
|
|
2931
|
-
agent_id: str,
|
|
2932
|
-
name: str | None = None,
|
|
2933
|
-
secret_value: str | None = None,
|
|
2934
|
-
) -> dict[str, Any]:
|
|
2935
|
-
"""
|
|
2936
|
-
Adds a secret to a specified conversational AI agent through the API and returns a status confirmation.
|
|
2937
|
-
|
|
2938
|
-
Args:
|
|
2939
|
-
agent_id (string): agent_id
|
|
2940
|
-
name (string): name Example: 'name'.
|
|
2941
|
-
secret_value (string): secret_value Example: 'secret_value'.
|
|
2942
|
-
|
|
2943
|
-
Returns:
|
|
2944
|
-
dict[str, Any]: Success / Success
|
|
2945
|
-
|
|
2946
|
-
Raises:
|
|
2947
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
2948
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
2949
|
-
|
|
2950
|
-
Tags:
|
|
2951
|
-
Conversational Ai
|
|
2952
|
-
"""
|
|
2953
|
-
if agent_id is None:
|
|
2954
|
-
raise ValueError("Missing required parameter 'agent_id'.")
|
|
2955
|
-
request_body_data = None
|
|
2956
|
-
request_body_data = {
|
|
2957
|
-
"name": name,
|
|
2958
|
-
"secret_value": secret_value,
|
|
2959
|
-
}
|
|
2960
|
-
request_body_data = {
|
|
2961
|
-
k: v for k, v in request_body_data.items() if v is not None
|
|
2962
|
-
}
|
|
2963
|
-
url = f"{self.base_url}/v1/convai/agents/{agent_id}/add-secret"
|
|
2964
|
-
query_params = {}
|
|
2965
|
-
response = self._post(
|
|
2966
|
-
url,
|
|
2967
|
-
data=request_body_data,
|
|
2968
|
-
params=query_params,
|
|
2969
|
-
content_type="application/json",
|
|
2970
|
-
)
|
|
2971
|
-
response.raise_for_status()
|
|
2972
|
-
if (
|
|
2973
|
-
response.status_code == 204
|
|
2974
|
-
or not response.content
|
|
2975
|
-
or not response.text.strip()
|
|
2976
|
-
):
|
|
2977
|
-
return None
|
|
2978
|
-
try:
|
|
2979
|
-
return response.json()
|
|
2980
|
-
except ValueError:
|
|
2981
|
-
return None
|
|
2982
|
-
|
|
2983
|
-
def add_to_agent_sknowledge_base(
|
|
2984
|
-
self, agent_id: str, request_body: dict[str, Any] | None = None
|
|
2985
|
-
) -> dict[str, Any]:
|
|
2986
|
-
"""
|
|
2987
|
-
Adds new content to an agent's knowledge base by uploading a file or resource, which can be used to enhance the agent's conversational capabilities.
|
|
2988
|
-
|
|
2989
|
-
Args:
|
|
2990
|
-
agent_id (string): agent_id
|
|
2991
|
-
request_body (dict | None): Optional dictionary for an empty JSON request body (e.g., {}).
|
|
2992
|
-
|
|
2993
|
-
Returns:
|
|
2994
|
-
dict[str, Any]: Success
|
|
2995
|
-
|
|
2996
|
-
Raises:
|
|
2997
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
2998
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
2999
|
-
|
|
3000
|
-
Tags:
|
|
3001
|
-
Conversational Ai
|
|
3002
|
-
"""
|
|
3003
|
-
if agent_id is None:
|
|
3004
|
-
raise ValueError("Missing required parameter 'agent_id'.")
|
|
3005
|
-
request_body_data = None
|
|
3006
|
-
request_body_data = request_body if request_body is not None else {}
|
|
3007
|
-
url = f"{self.base_url}/v1/convai/agents/{agent_id}/add-to-knowledge-base"
|
|
3008
|
-
query_params = {}
|
|
3009
|
-
response = self._post(
|
|
3010
|
-
url,
|
|
3011
|
-
data=request_body_data,
|
|
3012
|
-
params=query_params,
|
|
3013
|
-
content_type="application/json",
|
|
3014
|
-
)
|
|
3015
|
-
response.raise_for_status()
|
|
3016
|
-
if (
|
|
3017
|
-
response.status_code == 204
|
|
3018
|
-
or not response.content
|
|
3019
|
-
or not response.text.strip()
|
|
3020
|
-
):
|
|
3021
|
-
return None
|
|
3022
|
-
try:
|
|
3023
|
-
return response.json()
|
|
3024
|
-
except ValueError:
|
|
3025
|
-
return None
|
|
3026
|
-
|
|
3027
|
-
def get_agents_page(self) -> dict[str, Any]:
|
|
3028
|
-
"""
|
|
3029
|
-
Retrieves a list of conversational AI agents available in the Convai system.
|
|
3030
|
-
|
|
3031
|
-
Returns:
|
|
3032
|
-
dict[str, Any]: Success / Success
|
|
3033
|
-
|
|
3034
|
-
Raises:
|
|
3035
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
3036
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
3037
|
-
|
|
3038
|
-
Tags:
|
|
3039
|
-
Conversational Ai
|
|
3040
|
-
"""
|
|
3041
|
-
url = f"{self.base_url}/v1/convai/agents"
|
|
3042
|
-
query_params = {}
|
|
3043
|
-
response = self._get(url, params=query_params)
|
|
3044
|
-
response.raise_for_status()
|
|
3045
|
-
if (
|
|
3046
|
-
response.status_code == 204
|
|
3047
|
-
or not response.content
|
|
3048
|
-
or not response.text.strip()
|
|
3049
|
-
):
|
|
3050
|
-
return None
|
|
3051
|
-
try:
|
|
3052
|
-
return response.json()
|
|
3053
|
-
except ValueError:
|
|
3054
|
-
return None
|
|
3055
|
-
|
|
3056
|
-
def get_conversations(self, agent_id: str | None = None) -> dict[str, Any]:
|
|
3057
|
-
"""
|
|
3058
|
-
Retrieves conversation history for a specified agent ID.
|
|
3059
|
-
|
|
3060
|
-
Args:
|
|
3061
|
-
agent_id (string): The id of the agent you're taking the action on. Example: '21m00Tcm4TlvDq8ikWAM'.
|
|
3062
|
-
|
|
3063
|
-
Returns:
|
|
3064
|
-
dict[str, Any]: Success / Success
|
|
3065
|
-
|
|
3066
|
-
Raises:
|
|
3067
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
3068
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
3069
|
-
|
|
3070
|
-
Tags:
|
|
3071
|
-
Conversational Ai
|
|
3072
|
-
"""
|
|
3073
|
-
url = f"{self.base_url}/v1/convai/conversations"
|
|
3074
|
-
query_params = {k: v for k, v in [("agent_id", agent_id)] if v is not None}
|
|
3075
|
-
response = self._get(url, params=query_params)
|
|
3076
|
-
response.raise_for_status()
|
|
3077
|
-
if (
|
|
3078
|
-
response.status_code == 204
|
|
3079
|
-
or not response.content
|
|
3080
|
-
or not response.text.strip()
|
|
3081
|
-
):
|
|
3082
|
-
return None
|
|
3083
|
-
try:
|
|
3084
|
-
return response.json()
|
|
3085
|
-
except ValueError:
|
|
3086
|
-
return None
|
|
3087
|
-
|
|
3088
|
-
def get_conversation_details(self, conversation_id: str) -> dict[str, Any]:
|
|
3089
|
-
"""
|
|
3090
|
-
Retrieves and formats the details of a specific conversation based on the provided conversation ID.
|
|
3091
|
-
|
|
3092
|
-
Args:
|
|
3093
|
-
conversation_id (string): conversation_id
|
|
3094
|
-
|
|
3095
|
-
Returns:
|
|
3096
|
-
dict[str, Any]: Success / Success
|
|
3097
|
-
|
|
3098
|
-
Raises:
|
|
3099
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
3100
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
3101
|
-
|
|
3102
|
-
Tags:
|
|
3103
|
-
Conversational Ai
|
|
3104
|
-
"""
|
|
3105
|
-
if conversation_id is None:
|
|
3106
|
-
raise ValueError("Missing required parameter 'conversation_id'.")
|
|
3107
|
-
url = f"{self.base_url}/v1/convai/conversations/{conversation_id}"
|
|
3108
|
-
query_params = {}
|
|
3109
|
-
response = self._get(url, params=query_params)
|
|
3110
|
-
response.raise_for_status()
|
|
3111
|
-
if (
|
|
3112
|
-
response.status_code == 204
|
|
3113
|
-
or not response.content
|
|
3114
|
-
or not response.text.strip()
|
|
3115
|
-
):
|
|
3116
|
-
return None
|
|
3117
|
-
try:
|
|
3118
|
-
return response.json()
|
|
3119
|
-
except ValueError:
|
|
3120
|
-
return None
|
|
3121
|
-
|
|
3122
|
-
def get_conversation_audio(self, conversation_id: str) -> Any:
|
|
3123
|
-
"""
|
|
3124
|
-
Retrieves the audio from a specific conversation using the ElevenLabs Conversational AI API.
|
|
3125
|
-
|
|
3126
|
-
Args:
|
|
3127
|
-
conversation_id (string): conversation_id
|
|
3128
|
-
|
|
3129
|
-
Returns:
|
|
3130
|
-
Any: Success / Success
|
|
3131
|
-
|
|
3132
|
-
Raises:
|
|
3133
|
-
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
3134
|
-
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
3135
|
-
|
|
3136
|
-
Tags:
|
|
3137
|
-
Conversational Ai
|
|
3138
|
-
"""
|
|
3139
|
-
if conversation_id is None:
|
|
3140
|
-
raise ValueError("Missing required parameter 'conversation_id'.")
|
|
3141
|
-
url = f"{self.base_url}/v1/convai/conversations/{conversation_id}/audio"
|
|
3142
|
-
query_params = {}
|
|
3143
|
-
response = self._get(url, params=query_params)
|
|
3144
|
-
response.raise_for_status()
|
|
3145
|
-
if (
|
|
3146
|
-
response.status_code == 204
|
|
3147
|
-
or not response.content
|
|
3148
|
-
or not response.text.strip()
|
|
3149
|
-
):
|
|
3150
|
-
return None
|
|
3151
|
-
try:
|
|
3152
|
-
return response.json()
|
|
3153
|
-
except ValueError:
|
|
3154
|
-
return None
|
|
3155
|
-
|
|
3156
|
-
def list_tools(self):
|
|
3157
|
-
return [
|
|
3158
|
-
self.get_generated_items,
|
|
3159
|
-
self.get_history_item_by_id,
|
|
3160
|
-
self.delete_history_item,
|
|
3161
|
-
self.get_audio_from_history_item,
|
|
3162
|
-
self.download_history_items,
|
|
3163
|
-
self.delete_sample,
|
|
3164
|
-
self.get_audio_from_sample,
|
|
3165
|
-
self.convert,
|
|
3166
|
-
self.text_to_speech_with_timestamps,
|
|
3167
|
-
self.convert_as_stream,
|
|
3168
|
-
self.stream_text_with_timestamps,
|
|
3169
|
-
self.voice_generation_parameters,
|
|
3170
|
-
self.generate_arandom_voice,
|
|
3171
|
-
self.create_voice_model,
|
|
3172
|
-
self.create_previews,
|
|
3173
|
-
self.create_voice_from_preview,
|
|
3174
|
-
self.get_user_subscription_info,
|
|
3175
|
-
self.get_user_info,
|
|
3176
|
-
self.get_voices,
|
|
3177
|
-
self.get_default_voice_settings,
|
|
3178
|
-
self.get_voice_settings,
|
|
3179
|
-
self.get_voice,
|
|
3180
|
-
self.delete_voice,
|
|
3181
|
-
self.edit_voice_settings,
|
|
3182
|
-
self.add_voice,
|
|
3183
|
-
self.edit_voice,
|
|
3184
|
-
self.add_sharing_voice,
|
|
3185
|
-
self.get_shared_voices,
|
|
3186
|
-
self.get_similar_library_voices,
|
|
3187
|
-
self.get_aprofile_page,
|
|
3188
|
-
self.get_projects,
|
|
3189
|
-
self.add_project,
|
|
3190
|
-
self.get_project_by_id,
|
|
3191
|
-
self.edit_basic_project_info,
|
|
3192
|
-
self.delete_project,
|
|
3193
|
-
self.convert_project,
|
|
3194
|
-
self.get_project_snapshots,
|
|
3195
|
-
self.streams_archive_with_project_audio,
|
|
3196
|
-
self.add_chapter_to_aproject,
|
|
3197
|
-
self.update_project_pronunciations,
|
|
3198
|
-
self.get_chapters,
|
|
3199
|
-
self.get_chapter_by_id,
|
|
3200
|
-
self.delete_chapter,
|
|
3201
|
-
self.convert_chapter,
|
|
3202
|
-
self.get_chapter_snapshots,
|
|
3203
|
-
self.stream_chapter_audio,
|
|
3204
|
-
self.dub_avideo_or_an_audio_file,
|
|
3205
|
-
self.get_dubbing_project_metadata,
|
|
3206
|
-
self.delete_dubbing_project,
|
|
3207
|
-
self.get_transcript_for_dub,
|
|
3208
|
-
self.get_models,
|
|
3209
|
-
self.post_audio_native,
|
|
3210
|
-
self.get_characters_usage_metrics,
|
|
3211
|
-
self.add_apronunciation_dictionary,
|
|
3212
|
-
self.add_rules_to_dictionary,
|
|
3213
|
-
self.remove_pronunciation_rules,
|
|
3214
|
-
self.get_dictionary_version_file,
|
|
3215
|
-
self.get_pronunciation_dictionary,
|
|
3216
|
-
self.get_pronunciation_dictionaries,
|
|
3217
|
-
self.invite_user,
|
|
3218
|
-
self.delete_existing_invitation,
|
|
3219
|
-
self.update_member,
|
|
3220
|
-
self.get_signed_url,
|
|
3221
|
-
self.create_agent,
|
|
3222
|
-
self.get_agent,
|
|
3223
|
-
self.delete_agent,
|
|
3224
|
-
self.patches_an_agent_settings,
|
|
3225
|
-
self.get_agent_widget_config,
|
|
3226
|
-
self.get_shareable_agent_link,
|
|
3227
|
-
self.post_agent_avatar,
|
|
3228
|
-
self.get_agent_knowledge_base,
|
|
3229
|
-
self.add_agent_secret,
|
|
3230
|
-
self.add_to_agent_sknowledge_base,
|
|
3231
|
-
self.get_agents_page,
|
|
3232
|
-
self.get_conversations,
|
|
3233
|
-
self.get_conversation_details,
|
|
3234
|
-
self.get_conversation_audio,
|
|
3235
|
-
]
|
|
145
|
+
asyncio.run(test_elevenlabs())
|