cartesia 2.0.0b2__py3-none-any.whl → 2.0.0b7__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.
Files changed (42) hide show
  1. cartesia/__init__.py +8 -4
  2. cartesia/base_client.py +0 -4
  3. cartesia/core/__init__.py +3 -0
  4. cartesia/core/client_wrapper.py +2 -2
  5. cartesia/core/pagination.py +88 -0
  6. cartesia/infill/client.py +4 -4
  7. cartesia/tts/_async_websocket.py +48 -1
  8. cartesia/tts/_websocket.py +44 -3
  9. cartesia/tts/client.py +4 -4
  10. cartesia/tts/requests/generation_request.py +5 -0
  11. cartesia/tts/requests/web_socket_chunk_response.py +3 -0
  12. cartesia/tts/requests/web_socket_response.py +2 -1
  13. cartesia/tts/requests/web_socket_tts_request.py +1 -0
  14. cartesia/tts/types/emotion.py +5 -0
  15. cartesia/tts/types/generation_request.py +5 -0
  16. cartesia/tts/types/web_socket_chunk_response.py +3 -1
  17. cartesia/tts/types/web_socket_response.py +2 -1
  18. cartesia/tts/types/web_socket_tts_output.py +2 -0
  19. cartesia/tts/types/web_socket_tts_request.py +1 -0
  20. cartesia/tts/utils/constants.py +2 -2
  21. cartesia/voice_changer/requests/streaming_response.py +2 -0
  22. cartesia/voice_changer/types/streaming_response.py +2 -0
  23. cartesia/voices/__init__.py +8 -4
  24. cartesia/voices/client.py +285 -169
  25. cartesia/voices/requests/__init__.py +2 -0
  26. cartesia/voices/requests/create_voice_request.py +0 -2
  27. cartesia/voices/requests/get_voices_response.py +24 -0
  28. cartesia/voices/requests/localize_dialect.py +1 -3
  29. cartesia/voices/requests/voice.py +13 -9
  30. cartesia/voices/types/__init__.py +6 -4
  31. cartesia/voices/types/create_voice_request.py +0 -2
  32. cartesia/voices/types/gender_presentation.py +5 -0
  33. cartesia/voices/types/get_voices_response.py +34 -0
  34. cartesia/voices/types/localize_dialect.py +1 -3
  35. cartesia/voices/types/voice.py +13 -9
  36. cartesia/voices/types/voice_expand_options.py +5 -0
  37. {cartesia-2.0.0b2.dist-info → cartesia-2.0.0b7.dist-info}/METADATA +85 -14
  38. {cartesia-2.0.0b2.dist-info → cartesia-2.0.0b7.dist-info}/RECORD +39 -37
  39. cartesia/datasets/client.py +0 -392
  40. cartesia/voices/types/localize_portuguese_dialect.py +0 -5
  41. cartesia/voices/types/localize_spanish_dialect.py +0 -5
  42. {cartesia-2.0.0b2.dist-info → cartesia-2.0.0b7.dist-info}/WHEEL +0 -0
@@ -1,392 +0,0 @@
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.paginated_datasets import PaginatedDatasets
7
- from ..core.pydantic_utilities import parse_obj_as
8
- from json.decoder import JSONDecodeError
9
- from ..core.api_error import ApiError
10
- from .types.dataset import Dataset
11
- from .types.paginated_dataset_files import PaginatedDatasetFiles
12
- from ..core.jsonable_encoder import jsonable_encoder
13
- from .. import core
14
- from .types.file_purpose import FilePurpose
15
- from ..core.client_wrapper import AsyncClientWrapper
16
-
17
- # this is used as the default value for optional parameters
18
- OMIT = typing.cast(typing.Any, ...)
19
-
20
-
21
- class DatasetsClient:
22
- def __init__(self, *, client_wrapper: SyncClientWrapper):
23
- self._client_wrapper = client_wrapper
24
-
25
- def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> PaginatedDatasets:
26
- """
27
- Parameters
28
- ----------
29
- request_options : typing.Optional[RequestOptions]
30
- Request-specific configuration.
31
-
32
- Returns
33
- -------
34
- PaginatedDatasets
35
-
36
- Examples
37
- --------
38
- from cartesia import Cartesia
39
-
40
- client = Cartesia(
41
- api_key="YOUR_API_KEY",
42
- )
43
- client.datasets.list()
44
- """
45
- _response = self._client_wrapper.httpx_client.request(
46
- "datasets/",
47
- method="GET",
48
- request_options=request_options,
49
- )
50
- try:
51
- if 200 <= _response.status_code < 300:
52
- return typing.cast(
53
- PaginatedDatasets,
54
- parse_obj_as(
55
- type_=PaginatedDatasets, # type: ignore
56
- object_=_response.json(),
57
- ),
58
- )
59
- _response_json = _response.json()
60
- except JSONDecodeError:
61
- raise ApiError(status_code=_response.status_code, body=_response.text)
62
- raise ApiError(status_code=_response.status_code, body=_response_json)
63
-
64
- def create(self, *, name: str, request_options: typing.Optional[RequestOptions] = None) -> Dataset:
65
- """
66
- Parameters
67
- ----------
68
- name : str
69
-
70
- request_options : typing.Optional[RequestOptions]
71
- Request-specific configuration.
72
-
73
- Returns
74
- -------
75
- Dataset
76
-
77
- Examples
78
- --------
79
- from cartesia import Cartesia
80
-
81
- client = Cartesia(
82
- api_key="YOUR_API_KEY",
83
- )
84
- client.datasets.create(
85
- name="name",
86
- )
87
- """
88
- _response = self._client_wrapper.httpx_client.request(
89
- "datasets/",
90
- method="POST",
91
- json={
92
- "name": name,
93
- },
94
- request_options=request_options,
95
- omit=OMIT,
96
- )
97
- try:
98
- if 200 <= _response.status_code < 300:
99
- return typing.cast(
100
- Dataset,
101
- parse_obj_as(
102
- type_=Dataset, # type: ignore
103
- object_=_response.json(),
104
- ),
105
- )
106
- _response_json = _response.json()
107
- except JSONDecodeError:
108
- raise ApiError(status_code=_response.status_code, body=_response.text)
109
- raise ApiError(status_code=_response.status_code, body=_response_json)
110
-
111
- def list_files(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> PaginatedDatasetFiles:
112
- """
113
- Parameters
114
- ----------
115
- id : str
116
-
117
- request_options : typing.Optional[RequestOptions]
118
- Request-specific configuration.
119
-
120
- Returns
121
- -------
122
- PaginatedDatasetFiles
123
-
124
- Examples
125
- --------
126
- from cartesia import Cartesia
127
-
128
- client = Cartesia(
129
- api_key="YOUR_API_KEY",
130
- )
131
- client.datasets.list_files(
132
- id="id",
133
- )
134
- """
135
- _response = self._client_wrapper.httpx_client.request(
136
- f"datasets/{jsonable_encoder(id)}/files",
137
- method="GET",
138
- request_options=request_options,
139
- )
140
- try:
141
- if 200 <= _response.status_code < 300:
142
- return typing.cast(
143
- PaginatedDatasetFiles,
144
- parse_obj_as(
145
- type_=PaginatedDatasetFiles, # type: ignore
146
- object_=_response.json(),
147
- ),
148
- )
149
- _response_json = _response.json()
150
- except JSONDecodeError:
151
- raise ApiError(status_code=_response.status_code, body=_response.text)
152
- raise ApiError(status_code=_response.status_code, body=_response_json)
153
-
154
- def upload_file(
155
- self, id: str, *, file: core.File, purpose: FilePurpose, request_options: typing.Optional[RequestOptions] = None
156
- ) -> None:
157
- """
158
- Parameters
159
- ----------
160
- id : str
161
-
162
- file : core.File
163
- See core.File for more documentation
164
-
165
- purpose : FilePurpose
166
-
167
- request_options : typing.Optional[RequestOptions]
168
- Request-specific configuration.
169
-
170
- Returns
171
- -------
172
- None
173
- """
174
- _response = self._client_wrapper.httpx_client.request(
175
- f"datasets/{jsonable_encoder(id)}/files",
176
- method="POST",
177
- data={
178
- "purpose": purpose,
179
- },
180
- files={
181
- "file": file,
182
- },
183
- request_options=request_options,
184
- omit=OMIT,
185
- )
186
- try:
187
- if 200 <= _response.status_code < 300:
188
- return
189
- _response_json = _response.json()
190
- except JSONDecodeError:
191
- raise ApiError(status_code=_response.status_code, body=_response.text)
192
- raise ApiError(status_code=_response.status_code, body=_response_json)
193
-
194
-
195
- class AsyncDatasetsClient:
196
- def __init__(self, *, client_wrapper: AsyncClientWrapper):
197
- self._client_wrapper = client_wrapper
198
-
199
- async def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> PaginatedDatasets:
200
- """
201
- Parameters
202
- ----------
203
- request_options : typing.Optional[RequestOptions]
204
- Request-specific configuration.
205
-
206
- Returns
207
- -------
208
- PaginatedDatasets
209
-
210
- Examples
211
- --------
212
- import asyncio
213
-
214
- from cartesia import AsyncCartesia
215
-
216
- client = AsyncCartesia(
217
- api_key="YOUR_API_KEY",
218
- )
219
-
220
-
221
- async def main() -> None:
222
- await client.datasets.list()
223
-
224
-
225
- asyncio.run(main())
226
- """
227
- _response = await self._client_wrapper.httpx_client.request(
228
- "datasets/",
229
- method="GET",
230
- request_options=request_options,
231
- )
232
- try:
233
- if 200 <= _response.status_code < 300:
234
- return typing.cast(
235
- PaginatedDatasets,
236
- parse_obj_as(
237
- type_=PaginatedDatasets, # type: ignore
238
- object_=_response.json(),
239
- ),
240
- )
241
- _response_json = _response.json()
242
- except JSONDecodeError:
243
- raise ApiError(status_code=_response.status_code, body=_response.text)
244
- raise ApiError(status_code=_response.status_code, body=_response_json)
245
-
246
- async def create(self, *, name: str, request_options: typing.Optional[RequestOptions] = None) -> Dataset:
247
- """
248
- Parameters
249
- ----------
250
- name : str
251
-
252
- request_options : typing.Optional[RequestOptions]
253
- Request-specific configuration.
254
-
255
- Returns
256
- -------
257
- Dataset
258
-
259
- Examples
260
- --------
261
- import asyncio
262
-
263
- from cartesia import AsyncCartesia
264
-
265
- client = AsyncCartesia(
266
- api_key="YOUR_API_KEY",
267
- )
268
-
269
-
270
- async def main() -> None:
271
- await client.datasets.create(
272
- name="name",
273
- )
274
-
275
-
276
- asyncio.run(main())
277
- """
278
- _response = await self._client_wrapper.httpx_client.request(
279
- "datasets/",
280
- method="POST",
281
- json={
282
- "name": name,
283
- },
284
- request_options=request_options,
285
- omit=OMIT,
286
- )
287
- try:
288
- if 200 <= _response.status_code < 300:
289
- return typing.cast(
290
- Dataset,
291
- parse_obj_as(
292
- type_=Dataset, # type: ignore
293
- object_=_response.json(),
294
- ),
295
- )
296
- _response_json = _response.json()
297
- except JSONDecodeError:
298
- raise ApiError(status_code=_response.status_code, body=_response.text)
299
- raise ApiError(status_code=_response.status_code, body=_response_json)
300
-
301
- async def list_files(
302
- self, id: str, *, request_options: typing.Optional[RequestOptions] = None
303
- ) -> PaginatedDatasetFiles:
304
- """
305
- Parameters
306
- ----------
307
- id : str
308
-
309
- request_options : typing.Optional[RequestOptions]
310
- Request-specific configuration.
311
-
312
- Returns
313
- -------
314
- PaginatedDatasetFiles
315
-
316
- Examples
317
- --------
318
- import asyncio
319
-
320
- from cartesia import AsyncCartesia
321
-
322
- client = AsyncCartesia(
323
- api_key="YOUR_API_KEY",
324
- )
325
-
326
-
327
- async def main() -> None:
328
- await client.datasets.list_files(
329
- id="id",
330
- )
331
-
332
-
333
- asyncio.run(main())
334
- """
335
- _response = await self._client_wrapper.httpx_client.request(
336
- f"datasets/{jsonable_encoder(id)}/files",
337
- method="GET",
338
- request_options=request_options,
339
- )
340
- try:
341
- if 200 <= _response.status_code < 300:
342
- return typing.cast(
343
- PaginatedDatasetFiles,
344
- parse_obj_as(
345
- type_=PaginatedDatasetFiles, # type: ignore
346
- object_=_response.json(),
347
- ),
348
- )
349
- _response_json = _response.json()
350
- except JSONDecodeError:
351
- raise ApiError(status_code=_response.status_code, body=_response.text)
352
- raise ApiError(status_code=_response.status_code, body=_response_json)
353
-
354
- async def upload_file(
355
- self, id: str, *, file: core.File, purpose: FilePurpose, request_options: typing.Optional[RequestOptions] = None
356
- ) -> None:
357
- """
358
- Parameters
359
- ----------
360
- id : str
361
-
362
- file : core.File
363
- See core.File for more documentation
364
-
365
- purpose : FilePurpose
366
-
367
- request_options : typing.Optional[RequestOptions]
368
- Request-specific configuration.
369
-
370
- Returns
371
- -------
372
- None
373
- """
374
- _response = await self._client_wrapper.httpx_client.request(
375
- f"datasets/{jsonable_encoder(id)}/files",
376
- method="POST",
377
- data={
378
- "purpose": purpose,
379
- },
380
- files={
381
- "file": file,
382
- },
383
- request_options=request_options,
384
- omit=OMIT,
385
- )
386
- try:
387
- if 200 <= _response.status_code < 300:
388
- return
389
- _response_json = _response.json()
390
- except JSONDecodeError:
391
- raise ApiError(status_code=_response.status_code, body=_response.text)
392
- raise ApiError(status_code=_response.status_code, body=_response_json)
@@ -1,5 +0,0 @@
1
- # This file was auto-generated by Fern from our API Definition.
2
-
3
- import typing
4
-
5
- LocalizePortugueseDialect = typing.Union[typing.Literal["br", "eu"], typing.Any]
@@ -1,5 +0,0 @@
1
- # This file was auto-generated by Fern from our API Definition.
2
-
3
- import typing
4
-
5
- LocalizeSpanishDialect = typing.Union[typing.Literal["mx", "pe"], typing.Any]