cartesia 1.4.0__py3-none-any.whl → 2.0.0__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.
- cartesia/__init__.py +302 -3
- cartesia/api_status/__init__.py +6 -0
- cartesia/api_status/client.py +104 -0
- cartesia/api_status/requests/__init__.py +5 -0
- cartesia/api_status/requests/api_info.py +8 -0
- cartesia/api_status/types/__init__.py +5 -0
- cartesia/api_status/types/api_info.py +20 -0
- cartesia/base_client.py +156 -0
- cartesia/client.py +163 -40
- cartesia/core/__init__.py +50 -0
- cartesia/core/api_error.py +15 -0
- cartesia/core/client_wrapper.py +55 -0
- cartesia/core/datetime_utils.py +28 -0
- cartesia/core/file.py +67 -0
- cartesia/core/http_client.py +499 -0
- cartesia/core/jsonable_encoder.py +101 -0
- cartesia/core/pagination.py +88 -0
- cartesia/core/pydantic_utilities.py +296 -0
- cartesia/core/query_encoder.py +58 -0
- cartesia/core/remove_none_from_dict.py +11 -0
- cartesia/core/request_options.py +35 -0
- cartesia/core/serialization.py +272 -0
- cartesia/datasets/__init__.py +24 -0
- cartesia/datasets/requests/__init__.py +15 -0
- cartesia/datasets/requests/create_dataset_request.py +7 -0
- cartesia/datasets/requests/dataset.py +9 -0
- cartesia/datasets/requests/dataset_file.py +9 -0
- cartesia/datasets/requests/paginated_dataset_files.py +10 -0
- cartesia/datasets/requests/paginated_datasets.py +10 -0
- cartesia/datasets/types/__init__.py +17 -0
- cartesia/datasets/types/create_dataset_request.py +19 -0
- cartesia/datasets/types/dataset.py +21 -0
- cartesia/datasets/types/dataset_file.py +21 -0
- cartesia/datasets/types/file_purpose.py +5 -0
- cartesia/datasets/types/paginated_dataset_files.py +21 -0
- cartesia/datasets/types/paginated_datasets.py +21 -0
- cartesia/embedding/__init__.py +5 -0
- cartesia/embedding/types/__init__.py +5 -0
- cartesia/embedding/types/embedding.py +201 -0
- cartesia/environment.py +7 -0
- cartesia/infill/__init__.py +2 -0
- cartesia/infill/client.py +318 -0
- cartesia/tts/__init__.py +167 -0
- cartesia/{_async_websocket.py → tts/_async_websocket.py} +212 -85
- cartesia/tts/_websocket.py +479 -0
- cartesia/tts/client.py +407 -0
- cartesia/tts/requests/__init__.py +76 -0
- cartesia/tts/requests/cancel_context_request.py +17 -0
- cartesia/tts/requests/controls.py +11 -0
- cartesia/tts/requests/generation_request.py +58 -0
- cartesia/tts/requests/mp_3_output_format.py +11 -0
- cartesia/tts/requests/output_format.py +30 -0
- cartesia/tts/requests/phoneme_timestamps.py +10 -0
- cartesia/tts/requests/raw_output_format.py +11 -0
- cartesia/tts/requests/speed.py +7 -0
- cartesia/tts/requests/tts_request.py +24 -0
- cartesia/tts/requests/tts_request_embedding_specifier.py +16 -0
- cartesia/tts/requests/tts_request_id_specifier.py +16 -0
- cartesia/tts/requests/tts_request_voice_specifier.py +7 -0
- cartesia/tts/requests/wav_output_format.py +7 -0
- cartesia/tts/requests/web_socket_base_response.py +11 -0
- cartesia/tts/requests/web_socket_chunk_response.py +11 -0
- cartesia/tts/requests/web_socket_done_response.py +7 -0
- cartesia/tts/requests/web_socket_error_response.py +7 -0
- cartesia/tts/requests/web_socket_flush_done_response.py +9 -0
- cartesia/tts/requests/web_socket_phoneme_timestamps_response.py +9 -0
- cartesia/tts/requests/web_socket_raw_output_format.py +11 -0
- cartesia/tts/requests/web_socket_request.py +7 -0
- cartesia/tts/requests/web_socket_response.py +70 -0
- cartesia/tts/requests/web_socket_stream_options.py +8 -0
- cartesia/tts/requests/web_socket_timestamps_response.py +9 -0
- cartesia/tts/requests/web_socket_tts_output.py +18 -0
- cartesia/tts/requests/web_socket_tts_request.py +25 -0
- cartesia/tts/requests/word_timestamps.py +10 -0
- cartesia/tts/socket_client.py +302 -0
- cartesia/tts/types/__init__.py +90 -0
- cartesia/tts/types/cancel_context_request.py +28 -0
- cartesia/tts/types/context_id.py +3 -0
- cartesia/tts/types/controls.py +22 -0
- cartesia/tts/types/emotion.py +34 -0
- cartesia/tts/types/flush_id.py +3 -0
- cartesia/tts/types/generation_request.py +71 -0
- cartesia/tts/types/mp_3_output_format.py +23 -0
- cartesia/tts/types/natural_specifier.py +5 -0
- cartesia/tts/types/numerical_specifier.py +3 -0
- cartesia/tts/types/output_format.py +58 -0
- cartesia/tts/types/phoneme_timestamps.py +21 -0
- cartesia/tts/types/raw_encoding.py +5 -0
- cartesia/tts/types/raw_output_format.py +22 -0
- cartesia/tts/types/speed.py +7 -0
- cartesia/tts/types/supported_language.py +7 -0
- cartesia/tts/types/tts_request.py +35 -0
- cartesia/tts/types/tts_request_embedding_specifier.py +27 -0
- cartesia/tts/types/tts_request_id_specifier.py +27 -0
- cartesia/tts/types/tts_request_voice_specifier.py +7 -0
- cartesia/tts/types/wav_output_format.py +17 -0
- cartesia/tts/types/web_socket_base_response.py +22 -0
- cartesia/tts/types/web_socket_chunk_response.py +22 -0
- cartesia/tts/types/web_socket_done_response.py +17 -0
- cartesia/tts/types/web_socket_error_response.py +19 -0
- cartesia/tts/types/web_socket_flush_done_response.py +21 -0
- cartesia/tts/types/web_socket_phoneme_timestamps_response.py +20 -0
- cartesia/tts/types/web_socket_raw_output_format.py +22 -0
- cartesia/tts/types/web_socket_request.py +7 -0
- cartesia/tts/types/web_socket_response.py +125 -0
- cartesia/tts/types/web_socket_stream_options.py +19 -0
- cartesia/tts/types/web_socket_timestamps_response.py +20 -0
- cartesia/tts/types/web_socket_tts_output.py +29 -0
- cartesia/tts/types/web_socket_tts_request.py +37 -0
- cartesia/tts/types/word_timestamps.py +21 -0
- cartesia/{_constants.py → tts/utils/constants.py} +2 -2
- cartesia/tts/utils/tts.py +64 -0
- cartesia/tts/utils/types.py +70 -0
- cartesia/version.py +3 -1
- cartesia/voice_changer/__init__.py +27 -0
- cartesia/voice_changer/client.py +395 -0
- cartesia/voice_changer/requests/__init__.py +15 -0
- cartesia/voice_changer/requests/streaming_response.py +38 -0
- cartesia/voice_changer/types/__init__.py +17 -0
- cartesia/voice_changer/types/output_format_container.py +5 -0
- cartesia/voice_changer/types/streaming_response.py +64 -0
- cartesia/voices/__init__.py +81 -0
- cartesia/voices/client.py +1218 -0
- cartesia/voices/requests/__init__.py +29 -0
- cartesia/voices/requests/create_voice_request.py +23 -0
- cartesia/voices/requests/embedding_response.py +8 -0
- cartesia/voices/requests/embedding_specifier.py +10 -0
- cartesia/voices/requests/get_voices_response.py +24 -0
- cartesia/voices/requests/id_specifier.py +10 -0
- cartesia/voices/requests/localize_dialect.py +11 -0
- cartesia/voices/requests/localize_voice_request.py +28 -0
- cartesia/voices/requests/mix_voice_specifier.py +7 -0
- cartesia/voices/requests/mix_voices_request.py +9 -0
- cartesia/voices/requests/update_voice_request.py +15 -0
- cartesia/voices/requests/voice.py +43 -0
- cartesia/voices/requests/voice_metadata.py +36 -0
- cartesia/voices/types/__init__.py +53 -0
- cartesia/voices/types/base_voice_id.py +5 -0
- cartesia/voices/types/clone_mode.py +5 -0
- cartesia/voices/types/create_voice_request.py +34 -0
- cartesia/voices/types/embedding_response.py +20 -0
- cartesia/voices/types/embedding_specifier.py +22 -0
- cartesia/voices/types/gender.py +5 -0
- cartesia/voices/types/gender_presentation.py +5 -0
- cartesia/voices/types/get_voices_response.py +34 -0
- cartesia/voices/types/id_specifier.py +22 -0
- cartesia/voices/types/localize_dialect.py +11 -0
- cartesia/voices/types/localize_english_dialect.py +5 -0
- cartesia/voices/types/localize_french_dialect.py +5 -0
- cartesia/voices/types/localize_portuguese_dialect.py +5 -0
- cartesia/voices/types/localize_spanish_dialect.py +5 -0
- cartesia/voices/types/localize_target_language.py +7 -0
- cartesia/voices/types/localize_voice_request.py +39 -0
- cartesia/voices/types/mix_voice_specifier.py +7 -0
- cartesia/voices/types/mix_voices_request.py +20 -0
- cartesia/voices/types/update_voice_request.py +27 -0
- cartesia/voices/types/voice.py +54 -0
- cartesia/voices/types/voice_expand_options.py +5 -0
- cartesia/voices/types/voice_id.py +3 -0
- cartesia/voices/types/voice_metadata.py +48 -0
- cartesia/voices/types/weight.py +3 -0
- cartesia-2.0.0.dist-info/METADATA +414 -0
- cartesia-2.0.0.dist-info/RECORD +165 -0
- {cartesia-1.4.0.dist-info → cartesia-2.0.0.dist-info}/WHEEL +1 -1
- cartesia/_async_sse.py +0 -95
- cartesia/_logger.py +0 -3
- cartesia/_sse.py +0 -143
- cartesia/_types.py +0 -70
- cartesia/_websocket.py +0 -358
- cartesia/async_client.py +0 -82
- cartesia/async_tts.py +0 -176
- cartesia/resource.py +0 -44
- cartesia/tts.py +0 -292
- cartesia/utils/deprecated.py +0 -55
- cartesia/utils/retry.py +0 -87
- cartesia/utils/tts.py +0 -78
- cartesia/voices.py +0 -204
- cartesia-1.4.0.dist-info/METADATA +0 -663
- cartesia-1.4.0.dist-info/RECORD +0 -23
- cartesia-1.4.0.dist-info/licenses/LICENSE.md +0 -21
- /cartesia/{utils/__init__.py → py.typed} +0 -0
cartesia/voices.py
DELETED
@@ -1,204 +0,0 @@
|
|
1
|
-
from typing import Dict, List, Optional, Union
|
2
|
-
|
3
|
-
import httpx
|
4
|
-
|
5
|
-
from cartesia._types import VoiceMetadata
|
6
|
-
from cartesia.resource import Resource
|
7
|
-
|
8
|
-
|
9
|
-
class Voices(Resource):
|
10
|
-
"""This resource contains methods to list, get, clone, and create voices in your Cartesia voice library.
|
11
|
-
|
12
|
-
Usage:
|
13
|
-
>>> client = Cartesia(api_key="your_api_key")
|
14
|
-
>>> voices = client.voices.list()
|
15
|
-
>>> voice = client.voices.get(id="a0e99841-438c-4a64-b679-ae501e7d6091")
|
16
|
-
>>> print("Voice Name:", voice["name"], "Voice Description:", voice["description"])
|
17
|
-
>>> embedding = client.voices.clone(filepath="path/to/clip.wav")
|
18
|
-
>>> new_voice = client.voices.create(
|
19
|
-
... name="My Voice", description="A new voice", embedding=embedding
|
20
|
-
... )
|
21
|
-
"""
|
22
|
-
|
23
|
-
def list(self) -> List[VoiceMetadata]:
|
24
|
-
"""List all voices in your voice library.
|
25
|
-
|
26
|
-
Returns:
|
27
|
-
This method returns a list of VoiceMetadata objects.
|
28
|
-
"""
|
29
|
-
response = httpx.get(
|
30
|
-
f"{self._http_url()}/voices",
|
31
|
-
headers=self.headers,
|
32
|
-
timeout=self.timeout,
|
33
|
-
)
|
34
|
-
|
35
|
-
if not response.is_success:
|
36
|
-
raise ValueError(f"Failed to get voices. Error: {response.text}")
|
37
|
-
|
38
|
-
voices = response.json()
|
39
|
-
return voices
|
40
|
-
|
41
|
-
def get(self, id: str) -> VoiceMetadata:
|
42
|
-
"""Get a voice by its ID.
|
43
|
-
|
44
|
-
Args:
|
45
|
-
id: The ID of the voice.
|
46
|
-
|
47
|
-
Returns:
|
48
|
-
A VoiceMetadata object containing the voice metadata.
|
49
|
-
"""
|
50
|
-
url = f"{self._http_url()}/voices/{id}"
|
51
|
-
response = httpx.get(url, headers=self.headers, timeout=self.timeout)
|
52
|
-
|
53
|
-
if not response.is_success:
|
54
|
-
raise ValueError(
|
55
|
-
f"Failed to get voice. Status Code: {response.status_code}\nError: {response.text}"
|
56
|
-
)
|
57
|
-
|
58
|
-
return response.json()
|
59
|
-
|
60
|
-
def clone(
|
61
|
-
self,
|
62
|
-
filepath: Optional[str] = None,
|
63
|
-
enhance: str = True,
|
64
|
-
mode: str = "clip",
|
65
|
-
language: str = "en",
|
66
|
-
name: Optional[str] = None,
|
67
|
-
description: Optional[str] = None,
|
68
|
-
transcript: Optional[str] = None,
|
69
|
-
) -> Union[List[float], VoiceMetadata]:
|
70
|
-
"""Clone a voice from a clip.
|
71
|
-
|
72
|
-
Args:
|
73
|
-
filepath: The path to the clip file.
|
74
|
-
enhance: Whether to enhance the clip before cloning the voice (highly recommended). Defaults to True.
|
75
|
-
mode: The mode to use for cloning. Either "similarity" or "stability".
|
76
|
-
language: The language code of the language spoken in the clip. Defaults to "en".
|
77
|
-
name: The name of the cloned voice.
|
78
|
-
description: The description of the cloned voice.
|
79
|
-
transcript: The transcript of the clip. Only used if mode is "similarity".
|
80
|
-
|
81
|
-
Returns:
|
82
|
-
The embedding of the cloned voice as a list of floats.
|
83
|
-
"""
|
84
|
-
if not filepath:
|
85
|
-
raise ValueError("Filepath must be specified.")
|
86
|
-
headers = self.headers.copy()
|
87
|
-
headers.pop("Content-Type", None)
|
88
|
-
|
89
|
-
with open(filepath, "rb") as file:
|
90
|
-
files = {"clip": file}
|
91
|
-
data = {
|
92
|
-
"enhance": str(enhance).lower(),
|
93
|
-
"mode": mode,
|
94
|
-
}
|
95
|
-
if mode == "clip":
|
96
|
-
url = f"{self._http_url()}/voices/clone/clip"
|
97
|
-
response = httpx.post(
|
98
|
-
url, headers=headers, files=files, data=data, timeout=self.timeout
|
99
|
-
)
|
100
|
-
if not response.is_success:
|
101
|
-
raise ValueError(f"Failed to clone voice from clip. Error: {response.text}")
|
102
|
-
return response.json()["embedding"]
|
103
|
-
else:
|
104
|
-
data["name"] = name
|
105
|
-
data["description"] = description
|
106
|
-
data["language"] = language
|
107
|
-
if mode == "similarity" and transcript:
|
108
|
-
data["transcript"] = transcript
|
109
|
-
url = f"{self._http_url()}/voices/clone"
|
110
|
-
response = httpx.post(
|
111
|
-
url, headers=headers, files=files, data=data, timeout=self.timeout
|
112
|
-
)
|
113
|
-
if not response.is_success:
|
114
|
-
raise ValueError(
|
115
|
-
f"Failed to clone voice. Status Code: {response.status_code}\n"
|
116
|
-
f"Error: {response.text}"
|
117
|
-
)
|
118
|
-
return response.json()
|
119
|
-
|
120
|
-
def create(
|
121
|
-
self,
|
122
|
-
name: str,
|
123
|
-
description: str,
|
124
|
-
embedding: List[float],
|
125
|
-
language: str = "en",
|
126
|
-
) -> VoiceMetadata:
|
127
|
-
"""Create a new voice.
|
128
|
-
|
129
|
-
Args:
|
130
|
-
name: The name of the voice.
|
131
|
-
description: The description of the voice.
|
132
|
-
embedding: The embedding of the voice. This should be generated with :meth:`clone`.
|
133
|
-
|
134
|
-
Returns:
|
135
|
-
A dictionary containing the voice metadata.
|
136
|
-
"""
|
137
|
-
response = httpx.post(
|
138
|
-
f"{self._http_url()}/voices",
|
139
|
-
headers=self.headers,
|
140
|
-
json={
|
141
|
-
"name": name,
|
142
|
-
"description": description,
|
143
|
-
"embedding": embedding,
|
144
|
-
"language": language,
|
145
|
-
},
|
146
|
-
timeout=self.timeout,
|
147
|
-
)
|
148
|
-
|
149
|
-
if not response.is_success:
|
150
|
-
raise ValueError(f"Failed to create voice. Error: {response.text}")
|
151
|
-
|
152
|
-
return response.json()
|
153
|
-
|
154
|
-
def delete(self, id: str) -> bool:
|
155
|
-
"""Delete a voice by its ID.
|
156
|
-
|
157
|
-
Args:
|
158
|
-
id: The ID of the voice.
|
159
|
-
|
160
|
-
Raises:
|
161
|
-
ValueError: If the request fails.
|
162
|
-
"""
|
163
|
-
response = httpx.delete(
|
164
|
-
f"{self._http_url()}/voices/{id}",
|
165
|
-
headers=self.headers,
|
166
|
-
timeout=self.timeout,
|
167
|
-
)
|
168
|
-
|
169
|
-
if not response.is_success:
|
170
|
-
raise ValueError(f"Failed to delete voice. Error: {response.text}")
|
171
|
-
|
172
|
-
def mix(self, voices: List[Dict[str, Union[str, float]]]) -> List[float]:
|
173
|
-
"""Mix multiple voices together.
|
174
|
-
|
175
|
-
Args:
|
176
|
-
voices: A list of dictionaries, each containing either:
|
177
|
-
- 'id': The ID of an existing voice
|
178
|
-
- 'embedding': A voice embedding
|
179
|
-
AND
|
180
|
-
- 'weight': The weight of the voice in the mix (0.0 to 1.0)
|
181
|
-
|
182
|
-
Returns:
|
183
|
-
The embedding of the mixed voice as a list of floats.
|
184
|
-
|
185
|
-
Raises:
|
186
|
-
ValueError: If the request fails or if the input is invalid.
|
187
|
-
"""
|
188
|
-
url = f"{self._http_url()}/voices/mix"
|
189
|
-
|
190
|
-
if not voices or not isinstance(voices, list):
|
191
|
-
raise ValueError("voices must be a non-empty list")
|
192
|
-
|
193
|
-
response = httpx.post(
|
194
|
-
url,
|
195
|
-
headers=self.headers,
|
196
|
-
json={"voices": voices},
|
197
|
-
timeout=self.timeout,
|
198
|
-
)
|
199
|
-
|
200
|
-
if not response.is_success:
|
201
|
-
raise ValueError(f"Failed to mix voices. Error: {response.text}")
|
202
|
-
|
203
|
-
result = response.json()
|
204
|
-
return result["embedding"]
|