cartesia 1.0.10__py2.py3-none-any.whl → 1.0.12__py2.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/client.py +39 -3
- cartesia/version.py +1 -1
- {cartesia-1.0.10.dist-info → cartesia-1.0.12.dist-info}/METADATA +7 -1
- {cartesia-1.0.10.dist-info → cartesia-1.0.12.dist-info}/RECORD +7 -7
- {cartesia-1.0.10.dist-info → cartesia-1.0.12.dist-info}/LICENSE.md +0 -0
- {cartesia-1.0.10.dist-info → cartesia-1.0.12.dist-info}/WHEEL +0 -0
- {cartesia-1.0.10.dist-info → cartesia-1.0.12.dist-info}/top_level.txt +0 -0
cartesia/client.py
CHANGED
@@ -32,7 +32,6 @@ except ImportError:
|
|
32
32
|
IS_WEBSOCKET_SYNC_AVAILABLE = False
|
33
33
|
|
34
34
|
from iterators import TimeoutIterator
|
35
|
-
from websockets.sync.client import connect
|
36
35
|
|
37
36
|
from cartesia._types import (
|
38
37
|
DeprecatedOutputFormatMapping,
|
@@ -261,6 +260,40 @@ class Voices(Resource):
|
|
261
260
|
|
262
261
|
return response.json()
|
263
262
|
|
263
|
+
def mix(self, voices: List[Dict[str, Union[str, float]]]) -> List[float]:
|
264
|
+
"""Mix multiple voices together.
|
265
|
+
|
266
|
+
Args:
|
267
|
+
voices: A list of dictionaries, each containing either:
|
268
|
+
- 'id': The ID of an existing voice
|
269
|
+
- 'embedding': A voice embedding
|
270
|
+
AND
|
271
|
+
- 'weight': The weight of the voice in the mix (0.0 to 1.0)
|
272
|
+
|
273
|
+
Returns:
|
274
|
+
The embedding of the mixed voice as a list of floats.
|
275
|
+
|
276
|
+
Raises:
|
277
|
+
ValueError: If the request fails or if the input is invalid.
|
278
|
+
"""
|
279
|
+
url = f"{self._http_url()}/voices/mix"
|
280
|
+
|
281
|
+
if not voices or not isinstance(voices, list):
|
282
|
+
raise ValueError("voices must be a non-empty list")
|
283
|
+
|
284
|
+
response = httpx.post(
|
285
|
+
url,
|
286
|
+
headers=self.headers,
|
287
|
+
json={"voices": voices},
|
288
|
+
timeout=self.timeout,
|
289
|
+
)
|
290
|
+
|
291
|
+
if not response.is_success:
|
292
|
+
raise ValueError(f"Failed to mix voices. Error: {response.text}")
|
293
|
+
|
294
|
+
result = response.json()
|
295
|
+
return result["embedding"]
|
296
|
+
|
264
297
|
|
265
298
|
class _TTSContext:
|
266
299
|
"""Manage a single context over a WebSocket.
|
@@ -294,6 +327,7 @@ class _TTSContext:
|
|
294
327
|
context_id: Optional[str] = None,
|
295
328
|
duration: Optional[int] = None,
|
296
329
|
language: Optional[str] = None,
|
330
|
+
add_timestamps: bool = False,
|
297
331
|
_experimental_voice_controls: Optional[VoiceControls] = None,
|
298
332
|
) -> Generator[bytes, None, None]:
|
299
333
|
"""Send audio generation requests to the WebSocket and yield responses.
|
@@ -307,6 +341,7 @@ class _TTSContext:
|
|
307
341
|
context_id: The context ID to use for the request. If not specified, a random context ID will be generated.
|
308
342
|
duration: The duration of the audio in seconds.
|
309
343
|
language: The language code for the audio request. This can only be used with `model_id = sonic-multilingual`
|
344
|
+
add_timestamps: Whether to return word-level timestamps.
|
310
345
|
_experimental_voice_controls: Experimental voice controls for controlling speed and emotion.
|
311
346
|
Note: This is an experimental feature and may change rapidly in future releases.
|
312
347
|
|
@@ -341,6 +376,7 @@ class _TTSContext:
|
|
341
376
|
},
|
342
377
|
"context_id": self._context_id,
|
343
378
|
"language": language,
|
379
|
+
"add_timestamps": add_timestamps,
|
344
380
|
}
|
345
381
|
|
346
382
|
if duration is not None:
|
@@ -858,9 +894,9 @@ class TTS(Resource):
|
|
858
894
|
raise ValueError("Only one of voice_id or voice_embedding should be specified.")
|
859
895
|
|
860
896
|
if voice_id:
|
861
|
-
voice = {"
|
897
|
+
voice = {"id": voice_id}
|
862
898
|
else:
|
863
|
-
voice = {"
|
899
|
+
voice = {"embedding": voice_embedding}
|
864
900
|
if experimental_voice_controls is not None:
|
865
901
|
voice["__experimental_controls"] = experimental_voice_controls
|
866
902
|
return voice
|
cartesia/version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "1.0.
|
1
|
+
__version__ = "1.0.12"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: cartesia
|
3
|
-
Version: 1.0.
|
3
|
+
Version: 1.0.12
|
4
4
|
Summary: The official Python library for the Cartesia API.
|
5
5
|
Home-page:
|
6
6
|
Author: Cartesia, Inc.
|
@@ -91,6 +91,11 @@ print("The embedding for", voice["name"], "is", voice["embedding"])
|
|
91
91
|
# Clone a voice using filepath
|
92
92
|
cloned_voice_embedding = client.voices.clone(filepath="path/to/voice")
|
93
93
|
|
94
|
+
# Mix voices together
|
95
|
+
mixed_voice_embedding = client.voices.mix(
|
96
|
+
[{ "id": "voice_id_1", "weight": 0.5 }, { "id": "voice_id_2", "weight": 0.25 }, { "id": "voice_id_3", "weight": 0.25 }]
|
97
|
+
)
|
98
|
+
|
94
99
|
# Create a new voice
|
95
100
|
new_voice = client.voices.create(
|
96
101
|
name="New Voice",
|
@@ -522,6 +527,7 @@ You can enhance the voice output by adjusting the `speed` and `emotion` paramete
|
|
522
527
|
|
523
528
|
Speed Options:
|
524
529
|
- `slowest`, `slow`, `normal`, `fast`, `fastest`
|
530
|
+
- Float values between -1.0 and 1.0, where -1.0 is the slowest speed and 1.0 is the fastest speed.
|
525
531
|
|
526
532
|
Emotion Options:
|
527
533
|
Use a list of tags in the format `emotion_name:level` where:
|
@@ -1,12 +1,12 @@
|
|
1
1
|
cartesia/__init__.py,sha256=E4w7psbAwx8X6Iri3W8jGeo11gIlhr3mSU33zChipmI,93
|
2
2
|
cartesia/_types.py,sha256=pkFJmsO-OWAJNtqxV80-YcR8KWWLhIwLFejzDjBewbw,4428
|
3
|
-
cartesia/client.py,sha256=
|
4
|
-
cartesia/version.py,sha256=
|
3
|
+
cartesia/client.py,sha256=bYUk-P7QlPNNDhQaI5fldkDZAC8vVVUuHrgRHOq_V78,52818
|
4
|
+
cartesia/version.py,sha256=bQ8TKIXU3qSGr-K-gVtWDgjDfBlCgBju76OGKtY9tS8,23
|
5
5
|
cartesia/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
6
|
cartesia/utils/deprecated.py,sha256=2cXvGtrxhPeUZA5LWy2n_U5OFLDv7SHeFtzqhjSJGyk,1674
|
7
7
|
cartesia/utils/retry.py,sha256=O6fyVWpH9Su8c0Fwupl57xMt6JrwJ52txBwP3faUL7k,3339
|
8
|
-
cartesia-1.0.
|
9
|
-
cartesia-1.0.
|
10
|
-
cartesia-1.0.
|
11
|
-
cartesia-1.0.
|
12
|
-
cartesia-1.0.
|
8
|
+
cartesia-1.0.12.dist-info/LICENSE.md,sha256=PT2YG5wEtEX1TNDn5sXkUXqbn-neyr7cZenTxd40ql4,1074
|
9
|
+
cartesia-1.0.12.dist-info/METADATA,sha256=3jeDZosoKAHVx9hcLjE9iZsggAvpR_L2iX3hnP_UFd4,21413
|
10
|
+
cartesia-1.0.12.dist-info/WHEEL,sha256=fS9sRbCBHs7VFcwJLnLXN1MZRR0_TVTxvXKzOnaSFs8,110
|
11
|
+
cartesia-1.0.12.dist-info/top_level.txt,sha256=rTX4HnnCegMxl1FK9czpVC7GAvf3SwDzPG65qP-BS4w,9
|
12
|
+
cartesia-1.0.12.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|