cartesia 1.0.11__tar.gz → 1.0.12__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cartesia
3
- Version: 1.0.11
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.
@@ -73,6 +73,11 @@ print("The embedding for", voice["name"], "is", voice["embedding"])
73
73
  # Clone a voice using filepath
74
74
  cloned_voice_embedding = client.voices.clone(filepath="path/to/voice")
75
75
 
76
+ # Mix voices together
77
+ mixed_voice_embedding = client.voices.mix(
78
+ [{ "id": "voice_id_1", "weight": 0.5 }, { "id": "voice_id_2", "weight": 0.25 }, { "id": "voice_id_3", "weight": 0.25 }]
79
+ )
80
+
76
81
  # Create a new voice
77
82
  new_voice = client.voices.create(
78
83
  name="New Voice",
@@ -504,6 +509,7 @@ You can enhance the voice output by adjusting the `speed` and `emotion` paramete
504
509
 
505
510
  Speed Options:
506
511
  - `slowest`, `slow`, `normal`, `fast`, `fastest`
512
+ - Float values between -1.0 and 1.0, where -1.0 is the slowest speed and 1.0 is the fastest speed.
507
513
 
508
514
  Emotion Options:
509
515
  Use a list of tags in the format `emotion_name:level` where:
@@ -56,6 +56,11 @@ print("The embedding for", voice["name"], "is", voice["embedding"])
56
56
  # Clone a voice using filepath
57
57
  cloned_voice_embedding = client.voices.clone(filepath="path/to/voice")
58
58
 
59
+ # Mix voices together
60
+ mixed_voice_embedding = client.voices.mix(
61
+ [{ "id": "voice_id_1", "weight": 0.5 }, { "id": "voice_id_2", "weight": 0.25 }, { "id": "voice_id_3", "weight": 0.25 }]
62
+ )
63
+
59
64
  # Create a new voice
60
65
  new_voice = client.voices.create(
61
66
  name="New Voice",
@@ -487,6 +492,7 @@ You can enhance the voice output by adjusting the `speed` and `emotion` paramete
487
492
 
488
493
  Speed Options:
489
494
  - `slowest`, `slow`, `normal`, `fast`, `fastest`
495
+ - Float values between -1.0 and 1.0, where -1.0 is the slowest speed and 1.0 is the fastest speed.
490
496
 
491
497
  Emotion Options:
492
498
  Use a list of tags in the format `emotion_name:level` where:
@@ -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.
@@ -861,9 +894,9 @@ class TTS(Resource):
861
894
  raise ValueError("Only one of voice_id or voice_embedding should be specified.")
862
895
 
863
896
  if voice_id:
864
- voice = {"mode": "id", "id": voice_id}
897
+ voice = {"id": voice_id}
865
898
  else:
866
- voice = {"mode": "embedding", "embedding": voice_embedding}
899
+ voice = {"embedding": voice_embedding}
867
900
  if experimental_voice_controls is not None:
868
901
  voice["__experimental_controls"] = experimental_voice_controls
869
902
  return voice
@@ -0,0 +1 @@
1
+ __version__ = "1.0.12"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cartesia
3
- Version: 1.0.11
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.
@@ -73,6 +73,11 @@ print("The embedding for", voice["name"], "is", voice["embedding"])
73
73
  # Clone a voice using filepath
74
74
  cloned_voice_embedding = client.voices.clone(filepath="path/to/voice")
75
75
 
76
+ # Mix voices together
77
+ mixed_voice_embedding = client.voices.mix(
78
+ [{ "id": "voice_id_1", "weight": 0.5 }, { "id": "voice_id_2", "weight": 0.25 }, { "id": "voice_id_3", "weight": 0.25 }]
79
+ )
80
+
76
81
  # Create a new voice
77
82
  new_voice = client.voices.create(
78
83
  name="New Voice",
@@ -504,6 +509,7 @@ You can enhance the voice output by adjusting the `speed` and `emotion` paramete
504
509
 
505
510
  Speed Options:
506
511
  - `slowest`, `slow`, `normal`, `fast`, `fastest`
512
+ - Float values between -1.0 and 1.0, where -1.0 is the slowest speed and 1.0 is the fastest speed.
507
513
 
508
514
  Emotion Options:
509
515
  Use a list of tags in the format `emotion_name:level` where:
@@ -102,6 +102,11 @@ def test_create_voice(client: Cartesia):
102
102
  assert voice["is_public"] is False
103
103
  voices = client.voices.list()
104
104
  assert voice in voices
105
+
106
+ def test_mix_voice(client: Cartesia):
107
+ logger.info("Testing voices.mix")
108
+ output = client.voices.mix(voices = [{"id": SAMPLE_VOICE_ID, "weight": 0.1}, {"id": SAMPLE_VOICE_ID, "weight": 0.9}])
109
+ assert isinstance(output, list)
105
110
 
106
111
  @pytest.mark.parametrize("stream", [True, False])
107
112
  @pytest.mark.parametrize("_experimental_voice_controls", [None, EXPERIMENTAL_VOICE_CONTROLS, EXPERIMENTAL_VOICE_CONTROLS_2])
@@ -1 +0,0 @@
1
- __version__ = "1.0.11"
File without changes
File without changes
File without changes
File without changes
File without changes