speechify-api 0.0.145__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.
- speechify_api-0.0.145.dist-info/METADATA +167 -0
- speechify_api-0.0.145.dist-info/RECORD +73 -0
- speechify_api-0.0.145.dist-info/WHEEL +4 -0
- speechifyinc/__init__.py +17 -0
- speechifyinc/api/__init__.py +5 -0
- speechifyinc/api/types/__init__.py +5 -0
- speechifyinc/api/types/audio_stream_request_accept.py +5 -0
- speechifyinc/client.py +150 -0
- speechifyinc/core/__init__.py +47 -0
- speechifyinc/core/api_error.py +15 -0
- speechifyinc/core/client_wrapper.py +76 -0
- speechifyinc/core/datetime_utils.py +28 -0
- speechifyinc/core/file.py +67 -0
- speechifyinc/core/http_client.py +499 -0
- speechifyinc/core/jsonable_encoder.py +101 -0
- speechifyinc/core/pydantic_utilities.py +296 -0
- speechifyinc/core/query_encoder.py +58 -0
- speechifyinc/core/remove_none_from_dict.py +11 -0
- speechifyinc/core/request_options.py +35 -0
- speechifyinc/core/serialization.py +272 -0
- speechifyinc/environment.py +7 -0
- speechifyinc/py.typed +0 -0
- speechifyinc/tts/__init__.py +78 -0
- speechifyinc/tts/audio/__init__.py +5 -0
- speechifyinc/tts/audio/client.py +544 -0
- speechifyinc/tts/audio/types/__init__.py +8 -0
- speechifyinc/tts/audio/types/audio_stream_request_accept.py +5 -0
- speechifyinc/tts/audio/types/get_speech_request_audio_format.py +5 -0
- speechifyinc/tts/audio/types/get_speech_request_model.py +7 -0
- speechifyinc/tts/audio/types/get_stream_request_model.py +7 -0
- speechifyinc/tts/auth/__init__.py +5 -0
- speechifyinc/tts/auth/client.py +171 -0
- speechifyinc/tts/auth/types/__init__.py +5 -0
- speechifyinc/tts/auth/types/create_access_token_request_scope.py +10 -0
- speechifyinc/tts/client.py +26 -0
- speechifyinc/tts/errors/__init__.py +9 -0
- speechifyinc/tts/errors/bad_request_error.py +9 -0
- speechifyinc/tts/errors/forbidden_error.py +9 -0
- speechifyinc/tts/errors/internal_server_error.py +9 -0
- speechifyinc/tts/errors/not_found_error.py +9 -0
- speechifyinc/tts/errors/payment_required_error.py +9 -0
- speechifyinc/tts/types/__init__.py +57 -0
- speechifyinc/tts/types/access_token.py +34 -0
- speechifyinc/tts/types/access_token_scope.py +10 -0
- speechifyinc/tts/types/api_key.py +47 -0
- speechifyinc/tts/types/create_voice_language.py +20 -0
- speechifyinc/tts/types/create_voice_model.py +22 -0
- speechifyinc/tts/types/create_voice_model_name.py +7 -0
- speechifyinc/tts/types/created_voice.py +28 -0
- speechifyinc/tts/types/created_voice_gender.py +5 -0
- speechifyinc/tts/types/created_voice_type.py +5 -0
- speechifyinc/tts/types/experimental_stream_request.py +49 -0
- speechifyinc/tts/types/experimental_stream_request_model.py +7 -0
- speechifyinc/tts/types/experimental_stream_response.py +33 -0
- speechifyinc/tts/types/get_speech_options_request.py +32 -0
- speechifyinc/tts/types/get_speech_response.py +36 -0
- speechifyinc/tts/types/get_speech_response_audio_format.py +5 -0
- speechifyinc/tts/types/get_stream_options_request.py +32 -0
- speechifyinc/tts/types/get_voice.py +30 -0
- speechifyinc/tts/types/get_voice_gender.py +5 -0
- speechifyinc/tts/types/get_voice_language.py +20 -0
- speechifyinc/tts/types/get_voice_type.py +5 -0
- speechifyinc/tts/types/get_voices_model.py +22 -0
- speechifyinc/tts/types/get_voices_model_name.py +7 -0
- speechifyinc/tts/types/nested_chunk.py +28 -0
- speechifyinc/tts/types/o_auth_error.py +21 -0
- speechifyinc/tts/types/o_auth_error_error.py +10 -0
- speechifyinc/tts/types/speech_marks.py +34 -0
- speechifyinc/tts/voices/__init__.py +5 -0
- speechifyinc/tts/voices/client.py +559 -0
- speechifyinc/tts/voices/types/__init__.py +5 -0
- speechifyinc/tts/voices/types/voices_create_request_gender.py +5 -0
- speechifyinc/version.py +3 -0
|
@@ -0,0 +1,559 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
from ...core.client_wrapper import SyncClientWrapper
|
|
5
|
+
from ...core.request_options import RequestOptions
|
|
6
|
+
from ..types.get_voice import GetVoice
|
|
7
|
+
from ...core.pydantic_utilities import parse_obj_as
|
|
8
|
+
from ..errors.not_found_error import NotFoundError
|
|
9
|
+
from ..errors.internal_server_error import InternalServerError
|
|
10
|
+
from json.decoder import JSONDecodeError
|
|
11
|
+
from ...core.api_error import ApiError
|
|
12
|
+
from .types.voices_create_request_gender import VoicesCreateRequestGender
|
|
13
|
+
from ... import core
|
|
14
|
+
from ..types.created_voice import CreatedVoice
|
|
15
|
+
from ..errors.bad_request_error import BadRequestError
|
|
16
|
+
from ..errors.payment_required_error import PaymentRequiredError
|
|
17
|
+
from ...core.jsonable_encoder import jsonable_encoder
|
|
18
|
+
from ...core.client_wrapper import AsyncClientWrapper
|
|
19
|
+
|
|
20
|
+
# this is used as the default value for optional parameters
|
|
21
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class VoicesClient:
|
|
25
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
26
|
+
self._client_wrapper = client_wrapper
|
|
27
|
+
|
|
28
|
+
def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.List[GetVoice]:
|
|
29
|
+
"""
|
|
30
|
+
Gets the list of voices available for the user
|
|
31
|
+
|
|
32
|
+
Parameters
|
|
33
|
+
----------
|
|
34
|
+
request_options : typing.Optional[RequestOptions]
|
|
35
|
+
Request-specific configuration.
|
|
36
|
+
|
|
37
|
+
Returns
|
|
38
|
+
-------
|
|
39
|
+
typing.List[GetVoice]
|
|
40
|
+
A list of voices
|
|
41
|
+
|
|
42
|
+
Examples
|
|
43
|
+
--------
|
|
44
|
+
from speechifyinc import Speechify
|
|
45
|
+
|
|
46
|
+
client = Speechify(
|
|
47
|
+
token="YOUR_TOKEN",
|
|
48
|
+
)
|
|
49
|
+
client.tts.voices.list()
|
|
50
|
+
"""
|
|
51
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
52
|
+
"v1/voices",
|
|
53
|
+
method="GET",
|
|
54
|
+
request_options=request_options,
|
|
55
|
+
)
|
|
56
|
+
try:
|
|
57
|
+
if 200 <= _response.status_code < 300:
|
|
58
|
+
return typing.cast(
|
|
59
|
+
typing.List[GetVoice],
|
|
60
|
+
parse_obj_as(
|
|
61
|
+
type_=typing.List[GetVoice], # type: ignore
|
|
62
|
+
object_=_response.json(),
|
|
63
|
+
),
|
|
64
|
+
)
|
|
65
|
+
if _response.status_code == 404:
|
|
66
|
+
raise NotFoundError(
|
|
67
|
+
typing.cast(
|
|
68
|
+
typing.Optional[typing.Any],
|
|
69
|
+
parse_obj_as(
|
|
70
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
71
|
+
object_=_response.json(),
|
|
72
|
+
),
|
|
73
|
+
)
|
|
74
|
+
)
|
|
75
|
+
if _response.status_code == 500:
|
|
76
|
+
raise InternalServerError(
|
|
77
|
+
typing.cast(
|
|
78
|
+
typing.Optional[typing.Any],
|
|
79
|
+
parse_obj_as(
|
|
80
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
81
|
+
object_=_response.json(),
|
|
82
|
+
),
|
|
83
|
+
)
|
|
84
|
+
)
|
|
85
|
+
_response_json = _response.json()
|
|
86
|
+
except JSONDecodeError:
|
|
87
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
88
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
89
|
+
|
|
90
|
+
def create(
|
|
91
|
+
self,
|
|
92
|
+
*,
|
|
93
|
+
name: str,
|
|
94
|
+
gender: VoicesCreateRequestGender,
|
|
95
|
+
sample: core.File,
|
|
96
|
+
consent: str,
|
|
97
|
+
locale: typing.Optional[str] = OMIT,
|
|
98
|
+
avatar: typing.Optional[core.File] = OMIT,
|
|
99
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
100
|
+
) -> CreatedVoice:
|
|
101
|
+
"""
|
|
102
|
+
Create a personal (cloned) voice for the user
|
|
103
|
+
|
|
104
|
+
Parameters
|
|
105
|
+
----------
|
|
106
|
+
name : str
|
|
107
|
+
Name of the personal voice
|
|
108
|
+
|
|
109
|
+
gender : VoicesCreateRequestGender
|
|
110
|
+
Gender marker for the personal voice
|
|
111
|
+
male GenderMale
|
|
112
|
+
female GenderFemale
|
|
113
|
+
notSpecified GenderNotSpecified
|
|
114
|
+
|
|
115
|
+
sample : core.File
|
|
116
|
+
See core.File for more documentation
|
|
117
|
+
|
|
118
|
+
consent : str
|
|
119
|
+
A **string** representing the user consent information in JSON format
|
|
120
|
+
This should include the fullName and email of the consenting individual.
|
|
121
|
+
For example, `{"fullName": "John Doe", "email": "john@example.com"}`
|
|
122
|
+
|
|
123
|
+
locale : typing.Optional[str]
|
|
124
|
+
Native language (locale) of the personal voice (e.g. en-US, es-ES, etc.)
|
|
125
|
+
|
|
126
|
+
avatar : typing.Optional[core.File]
|
|
127
|
+
See core.File for more documentation
|
|
128
|
+
|
|
129
|
+
request_options : typing.Optional[RequestOptions]
|
|
130
|
+
Request-specific configuration.
|
|
131
|
+
|
|
132
|
+
Returns
|
|
133
|
+
-------
|
|
134
|
+
CreatedVoice
|
|
135
|
+
A created voice
|
|
136
|
+
|
|
137
|
+
Examples
|
|
138
|
+
--------
|
|
139
|
+
from speechifyinc import Speechify
|
|
140
|
+
|
|
141
|
+
client = Speechify(
|
|
142
|
+
token="YOUR_TOKEN",
|
|
143
|
+
)
|
|
144
|
+
client.tts.voices.create(
|
|
145
|
+
name="name",
|
|
146
|
+
gender="male",
|
|
147
|
+
consent="consent",
|
|
148
|
+
)
|
|
149
|
+
"""
|
|
150
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
151
|
+
"v1/voices",
|
|
152
|
+
method="POST",
|
|
153
|
+
data={
|
|
154
|
+
"name": name,
|
|
155
|
+
"locale": locale,
|
|
156
|
+
"gender": gender,
|
|
157
|
+
"consent": consent,
|
|
158
|
+
},
|
|
159
|
+
files={
|
|
160
|
+
"sample": sample,
|
|
161
|
+
"avatar": avatar,
|
|
162
|
+
},
|
|
163
|
+
request_options=request_options,
|
|
164
|
+
omit=OMIT,
|
|
165
|
+
)
|
|
166
|
+
try:
|
|
167
|
+
if 200 <= _response.status_code < 300:
|
|
168
|
+
return typing.cast(
|
|
169
|
+
CreatedVoice,
|
|
170
|
+
parse_obj_as(
|
|
171
|
+
type_=CreatedVoice, # type: ignore
|
|
172
|
+
object_=_response.json(),
|
|
173
|
+
),
|
|
174
|
+
)
|
|
175
|
+
if _response.status_code == 400:
|
|
176
|
+
raise BadRequestError(
|
|
177
|
+
typing.cast(
|
|
178
|
+
typing.Optional[typing.Any],
|
|
179
|
+
parse_obj_as(
|
|
180
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
181
|
+
object_=_response.json(),
|
|
182
|
+
),
|
|
183
|
+
)
|
|
184
|
+
)
|
|
185
|
+
if _response.status_code == 402:
|
|
186
|
+
raise PaymentRequiredError(
|
|
187
|
+
typing.cast(
|
|
188
|
+
typing.Optional[typing.Any],
|
|
189
|
+
parse_obj_as(
|
|
190
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
191
|
+
object_=_response.json(),
|
|
192
|
+
),
|
|
193
|
+
)
|
|
194
|
+
)
|
|
195
|
+
if _response.status_code == 500:
|
|
196
|
+
raise InternalServerError(
|
|
197
|
+
typing.cast(
|
|
198
|
+
typing.Optional[typing.Any],
|
|
199
|
+
parse_obj_as(
|
|
200
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
201
|
+
object_=_response.json(),
|
|
202
|
+
),
|
|
203
|
+
)
|
|
204
|
+
)
|
|
205
|
+
_response_json = _response.json()
|
|
206
|
+
except JSONDecodeError:
|
|
207
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
208
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
209
|
+
|
|
210
|
+
def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
211
|
+
"""
|
|
212
|
+
Delete a personal (cloned) voice
|
|
213
|
+
|
|
214
|
+
Parameters
|
|
215
|
+
----------
|
|
216
|
+
id : str
|
|
217
|
+
The ID of the voice to delete
|
|
218
|
+
|
|
219
|
+
request_options : typing.Optional[RequestOptions]
|
|
220
|
+
Request-specific configuration.
|
|
221
|
+
|
|
222
|
+
Returns
|
|
223
|
+
-------
|
|
224
|
+
None
|
|
225
|
+
|
|
226
|
+
Examples
|
|
227
|
+
--------
|
|
228
|
+
from speechifyinc import Speechify
|
|
229
|
+
|
|
230
|
+
client = Speechify(
|
|
231
|
+
token="YOUR_TOKEN",
|
|
232
|
+
)
|
|
233
|
+
client.tts.voices.delete(
|
|
234
|
+
id="id",
|
|
235
|
+
)
|
|
236
|
+
"""
|
|
237
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
238
|
+
f"v1/voices/{jsonable_encoder(id)}",
|
|
239
|
+
method="DELETE",
|
|
240
|
+
request_options=request_options,
|
|
241
|
+
)
|
|
242
|
+
try:
|
|
243
|
+
if 200 <= _response.status_code < 300:
|
|
244
|
+
return
|
|
245
|
+
if _response.status_code == 400:
|
|
246
|
+
raise BadRequestError(
|
|
247
|
+
typing.cast(
|
|
248
|
+
typing.Optional[typing.Any],
|
|
249
|
+
parse_obj_as(
|
|
250
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
251
|
+
object_=_response.json(),
|
|
252
|
+
),
|
|
253
|
+
)
|
|
254
|
+
)
|
|
255
|
+
if _response.status_code == 404:
|
|
256
|
+
raise NotFoundError(
|
|
257
|
+
typing.cast(
|
|
258
|
+
typing.Optional[typing.Any],
|
|
259
|
+
parse_obj_as(
|
|
260
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
261
|
+
object_=_response.json(),
|
|
262
|
+
),
|
|
263
|
+
)
|
|
264
|
+
)
|
|
265
|
+
if _response.status_code == 500:
|
|
266
|
+
raise InternalServerError(
|
|
267
|
+
typing.cast(
|
|
268
|
+
typing.Optional[typing.Any],
|
|
269
|
+
parse_obj_as(
|
|
270
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
271
|
+
object_=_response.json(),
|
|
272
|
+
),
|
|
273
|
+
)
|
|
274
|
+
)
|
|
275
|
+
_response_json = _response.json()
|
|
276
|
+
except JSONDecodeError:
|
|
277
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
278
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
class AsyncVoicesClient:
|
|
282
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
283
|
+
self._client_wrapper = client_wrapper
|
|
284
|
+
|
|
285
|
+
async def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.List[GetVoice]:
|
|
286
|
+
"""
|
|
287
|
+
Gets the list of voices available for the user
|
|
288
|
+
|
|
289
|
+
Parameters
|
|
290
|
+
----------
|
|
291
|
+
request_options : typing.Optional[RequestOptions]
|
|
292
|
+
Request-specific configuration.
|
|
293
|
+
|
|
294
|
+
Returns
|
|
295
|
+
-------
|
|
296
|
+
typing.List[GetVoice]
|
|
297
|
+
A list of voices
|
|
298
|
+
|
|
299
|
+
Examples
|
|
300
|
+
--------
|
|
301
|
+
import asyncio
|
|
302
|
+
|
|
303
|
+
from speechifyinc import AsyncSpeechify
|
|
304
|
+
|
|
305
|
+
client = AsyncSpeechify(
|
|
306
|
+
token="YOUR_TOKEN",
|
|
307
|
+
)
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
async def main() -> None:
|
|
311
|
+
await client.tts.voices.list()
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
asyncio.run(main())
|
|
315
|
+
"""
|
|
316
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
317
|
+
"v1/voices",
|
|
318
|
+
method="GET",
|
|
319
|
+
request_options=request_options,
|
|
320
|
+
)
|
|
321
|
+
try:
|
|
322
|
+
if 200 <= _response.status_code < 300:
|
|
323
|
+
return typing.cast(
|
|
324
|
+
typing.List[GetVoice],
|
|
325
|
+
parse_obj_as(
|
|
326
|
+
type_=typing.List[GetVoice], # type: ignore
|
|
327
|
+
object_=_response.json(),
|
|
328
|
+
),
|
|
329
|
+
)
|
|
330
|
+
if _response.status_code == 404:
|
|
331
|
+
raise NotFoundError(
|
|
332
|
+
typing.cast(
|
|
333
|
+
typing.Optional[typing.Any],
|
|
334
|
+
parse_obj_as(
|
|
335
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
336
|
+
object_=_response.json(),
|
|
337
|
+
),
|
|
338
|
+
)
|
|
339
|
+
)
|
|
340
|
+
if _response.status_code == 500:
|
|
341
|
+
raise InternalServerError(
|
|
342
|
+
typing.cast(
|
|
343
|
+
typing.Optional[typing.Any],
|
|
344
|
+
parse_obj_as(
|
|
345
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
346
|
+
object_=_response.json(),
|
|
347
|
+
),
|
|
348
|
+
)
|
|
349
|
+
)
|
|
350
|
+
_response_json = _response.json()
|
|
351
|
+
except JSONDecodeError:
|
|
352
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
353
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
354
|
+
|
|
355
|
+
async def create(
|
|
356
|
+
self,
|
|
357
|
+
*,
|
|
358
|
+
name: str,
|
|
359
|
+
gender: VoicesCreateRequestGender,
|
|
360
|
+
sample: core.File,
|
|
361
|
+
consent: str,
|
|
362
|
+
locale: typing.Optional[str] = OMIT,
|
|
363
|
+
avatar: typing.Optional[core.File] = OMIT,
|
|
364
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
365
|
+
) -> CreatedVoice:
|
|
366
|
+
"""
|
|
367
|
+
Create a personal (cloned) voice for the user
|
|
368
|
+
|
|
369
|
+
Parameters
|
|
370
|
+
----------
|
|
371
|
+
name : str
|
|
372
|
+
Name of the personal voice
|
|
373
|
+
|
|
374
|
+
gender : VoicesCreateRequestGender
|
|
375
|
+
Gender marker for the personal voice
|
|
376
|
+
male GenderMale
|
|
377
|
+
female GenderFemale
|
|
378
|
+
notSpecified GenderNotSpecified
|
|
379
|
+
|
|
380
|
+
sample : core.File
|
|
381
|
+
See core.File for more documentation
|
|
382
|
+
|
|
383
|
+
consent : str
|
|
384
|
+
A **string** representing the user consent information in JSON format
|
|
385
|
+
This should include the fullName and email of the consenting individual.
|
|
386
|
+
For example, `{"fullName": "John Doe", "email": "john@example.com"}`
|
|
387
|
+
|
|
388
|
+
locale : typing.Optional[str]
|
|
389
|
+
Native language (locale) of the personal voice (e.g. en-US, es-ES, etc.)
|
|
390
|
+
|
|
391
|
+
avatar : typing.Optional[core.File]
|
|
392
|
+
See core.File for more documentation
|
|
393
|
+
|
|
394
|
+
request_options : typing.Optional[RequestOptions]
|
|
395
|
+
Request-specific configuration.
|
|
396
|
+
|
|
397
|
+
Returns
|
|
398
|
+
-------
|
|
399
|
+
CreatedVoice
|
|
400
|
+
A created voice
|
|
401
|
+
|
|
402
|
+
Examples
|
|
403
|
+
--------
|
|
404
|
+
import asyncio
|
|
405
|
+
|
|
406
|
+
from speechifyinc import AsyncSpeechify
|
|
407
|
+
|
|
408
|
+
client = AsyncSpeechify(
|
|
409
|
+
token="YOUR_TOKEN",
|
|
410
|
+
)
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
async def main() -> None:
|
|
414
|
+
await client.tts.voices.create(
|
|
415
|
+
name="name",
|
|
416
|
+
gender="male",
|
|
417
|
+
consent="consent",
|
|
418
|
+
)
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
asyncio.run(main())
|
|
422
|
+
"""
|
|
423
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
424
|
+
"v1/voices",
|
|
425
|
+
method="POST",
|
|
426
|
+
data={
|
|
427
|
+
"name": name,
|
|
428
|
+
"locale": locale,
|
|
429
|
+
"gender": gender,
|
|
430
|
+
"consent": consent,
|
|
431
|
+
},
|
|
432
|
+
files={
|
|
433
|
+
"sample": sample,
|
|
434
|
+
"avatar": avatar,
|
|
435
|
+
},
|
|
436
|
+
request_options=request_options,
|
|
437
|
+
omit=OMIT,
|
|
438
|
+
)
|
|
439
|
+
try:
|
|
440
|
+
if 200 <= _response.status_code < 300:
|
|
441
|
+
return typing.cast(
|
|
442
|
+
CreatedVoice,
|
|
443
|
+
parse_obj_as(
|
|
444
|
+
type_=CreatedVoice, # type: ignore
|
|
445
|
+
object_=_response.json(),
|
|
446
|
+
),
|
|
447
|
+
)
|
|
448
|
+
if _response.status_code == 400:
|
|
449
|
+
raise BadRequestError(
|
|
450
|
+
typing.cast(
|
|
451
|
+
typing.Optional[typing.Any],
|
|
452
|
+
parse_obj_as(
|
|
453
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
454
|
+
object_=_response.json(),
|
|
455
|
+
),
|
|
456
|
+
)
|
|
457
|
+
)
|
|
458
|
+
if _response.status_code == 402:
|
|
459
|
+
raise PaymentRequiredError(
|
|
460
|
+
typing.cast(
|
|
461
|
+
typing.Optional[typing.Any],
|
|
462
|
+
parse_obj_as(
|
|
463
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
464
|
+
object_=_response.json(),
|
|
465
|
+
),
|
|
466
|
+
)
|
|
467
|
+
)
|
|
468
|
+
if _response.status_code == 500:
|
|
469
|
+
raise InternalServerError(
|
|
470
|
+
typing.cast(
|
|
471
|
+
typing.Optional[typing.Any],
|
|
472
|
+
parse_obj_as(
|
|
473
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
474
|
+
object_=_response.json(),
|
|
475
|
+
),
|
|
476
|
+
)
|
|
477
|
+
)
|
|
478
|
+
_response_json = _response.json()
|
|
479
|
+
except JSONDecodeError:
|
|
480
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
481
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
482
|
+
|
|
483
|
+
async def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
484
|
+
"""
|
|
485
|
+
Delete a personal (cloned) voice
|
|
486
|
+
|
|
487
|
+
Parameters
|
|
488
|
+
----------
|
|
489
|
+
id : str
|
|
490
|
+
The ID of the voice to delete
|
|
491
|
+
|
|
492
|
+
request_options : typing.Optional[RequestOptions]
|
|
493
|
+
Request-specific configuration.
|
|
494
|
+
|
|
495
|
+
Returns
|
|
496
|
+
-------
|
|
497
|
+
None
|
|
498
|
+
|
|
499
|
+
Examples
|
|
500
|
+
--------
|
|
501
|
+
import asyncio
|
|
502
|
+
|
|
503
|
+
from speechifyinc import AsyncSpeechify
|
|
504
|
+
|
|
505
|
+
client = AsyncSpeechify(
|
|
506
|
+
token="YOUR_TOKEN",
|
|
507
|
+
)
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
async def main() -> None:
|
|
511
|
+
await client.tts.voices.delete(
|
|
512
|
+
id="id",
|
|
513
|
+
)
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
asyncio.run(main())
|
|
517
|
+
"""
|
|
518
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
519
|
+
f"v1/voices/{jsonable_encoder(id)}",
|
|
520
|
+
method="DELETE",
|
|
521
|
+
request_options=request_options,
|
|
522
|
+
)
|
|
523
|
+
try:
|
|
524
|
+
if 200 <= _response.status_code < 300:
|
|
525
|
+
return
|
|
526
|
+
if _response.status_code == 400:
|
|
527
|
+
raise BadRequestError(
|
|
528
|
+
typing.cast(
|
|
529
|
+
typing.Optional[typing.Any],
|
|
530
|
+
parse_obj_as(
|
|
531
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
532
|
+
object_=_response.json(),
|
|
533
|
+
),
|
|
534
|
+
)
|
|
535
|
+
)
|
|
536
|
+
if _response.status_code == 404:
|
|
537
|
+
raise NotFoundError(
|
|
538
|
+
typing.cast(
|
|
539
|
+
typing.Optional[typing.Any],
|
|
540
|
+
parse_obj_as(
|
|
541
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
542
|
+
object_=_response.json(),
|
|
543
|
+
),
|
|
544
|
+
)
|
|
545
|
+
)
|
|
546
|
+
if _response.status_code == 500:
|
|
547
|
+
raise InternalServerError(
|
|
548
|
+
typing.cast(
|
|
549
|
+
typing.Optional[typing.Any],
|
|
550
|
+
parse_obj_as(
|
|
551
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
552
|
+
object_=_response.json(),
|
|
553
|
+
),
|
|
554
|
+
)
|
|
555
|
+
)
|
|
556
|
+
_response_json = _response.json()
|
|
557
|
+
except JSONDecodeError:
|
|
558
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
559
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
speechifyinc/version.py
ADDED