cartesia 1.1.0.dev0__tar.gz → 1.2.0__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.
Files changed (32) hide show
  1. {cartesia-1.1.0.dev0 → cartesia-1.2.0}/PKG-INFO +1 -3
  2. {cartesia-1.1.0.dev0 → cartesia-1.2.0}/README.md +0 -2
  3. {cartesia-1.1.0.dev0 → cartesia-1.2.0}/cartesia/_types.py +0 -33
  4. {cartesia-1.1.0.dev0 → cartesia-1.2.0}/cartesia/tts.py +0 -9
  5. cartesia-1.2.0/cartesia/version.py +1 -0
  6. {cartesia-1.1.0.dev0 → cartesia-1.2.0}/cartesia/voices.py +48 -10
  7. {cartesia-1.1.0.dev0 → cartesia-1.2.0}/cartesia.egg-info/PKG-INFO +1 -3
  8. {cartesia-1.1.0.dev0 → cartesia-1.2.0}/pyproject.toml +1 -1
  9. {cartesia-1.1.0.dev0 → cartesia-1.2.0}/tests/test_tts.py +0 -11
  10. cartesia-1.1.0.dev0/cartesia/version.py +0 -1
  11. {cartesia-1.1.0.dev0 → cartesia-1.2.0}/LICENSE.md +0 -0
  12. {cartesia-1.1.0.dev0 → cartesia-1.2.0}/cartesia/__init__.py +0 -0
  13. {cartesia-1.1.0.dev0 → cartesia-1.2.0}/cartesia/_async_sse.py +0 -0
  14. {cartesia-1.1.0.dev0 → cartesia-1.2.0}/cartesia/_async_websocket.py +0 -0
  15. {cartesia-1.1.0.dev0 → cartesia-1.2.0}/cartesia/_constants.py +0 -0
  16. {cartesia-1.1.0.dev0 → cartesia-1.2.0}/cartesia/_logger.py +0 -0
  17. {cartesia-1.1.0.dev0 → cartesia-1.2.0}/cartesia/_sse.py +0 -0
  18. {cartesia-1.1.0.dev0 → cartesia-1.2.0}/cartesia/_websocket.py +0 -0
  19. {cartesia-1.1.0.dev0 → cartesia-1.2.0}/cartesia/async_client.py +0 -0
  20. {cartesia-1.1.0.dev0 → cartesia-1.2.0}/cartesia/async_tts.py +0 -0
  21. {cartesia-1.1.0.dev0 → cartesia-1.2.0}/cartesia/client.py +0 -0
  22. {cartesia-1.1.0.dev0 → cartesia-1.2.0}/cartesia/resource.py +0 -0
  23. {cartesia-1.1.0.dev0 → cartesia-1.2.0}/cartesia/utils/__init__.py +0 -0
  24. {cartesia-1.1.0.dev0 → cartesia-1.2.0}/cartesia/utils/deprecated.py +0 -0
  25. {cartesia-1.1.0.dev0 → cartesia-1.2.0}/cartesia/utils/retry.py +0 -0
  26. {cartesia-1.1.0.dev0 → cartesia-1.2.0}/cartesia/utils/tts.py +0 -0
  27. {cartesia-1.1.0.dev0 → cartesia-1.2.0}/cartesia.egg-info/SOURCES.txt +0 -0
  28. {cartesia-1.1.0.dev0 → cartesia-1.2.0}/cartesia.egg-info/dependency_links.txt +0 -0
  29. {cartesia-1.1.0.dev0 → cartesia-1.2.0}/cartesia.egg-info/requires.txt +0 -0
  30. {cartesia-1.1.0.dev0 → cartesia-1.2.0}/cartesia.egg-info/top_level.txt +0 -0
  31. {cartesia-1.1.0.dev0 → cartesia-1.2.0}/setup.cfg +0 -0
  32. {cartesia-1.1.0.dev0 → cartesia-1.2.0}/tests/test_deprecated.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cartesia
3
- Version: 1.1.0.dev0
3
+ Version: 1.2.0
4
4
  Summary: The official Python library for the Cartesia API.
5
5
  Requires-Python: >=3.9
6
6
  Description-Content-Type: text/markdown
@@ -642,8 +642,6 @@ display(audio)
642
642
 
643
643
  You can use the `client.tts.get_output_format` method to convert string-based output format names into the `output_format` dictionary which is expected by the `output_format` parameter. You can see the `OutputFormatMapping` class in `cartesia._types` for the currently supported output format names. You can also view the currently supported `output_format`s in our [API Reference](https://docs.cartesia.ai/reference/api-reference/rest/stream-speech-server-sent-events).
644
644
 
645
- The previously used `output_format` strings are now deprecated and will be removed in v1.2.0. These are listed in the `DeprecatedOutputFormatMapping` class in `cartesia._types`.
646
-
647
645
  ```python
648
646
  # Get the output format dictionary from string name
649
647
  output_format = client.tts.get_output_format("raw_pcm_f32le_44100")
@@ -629,8 +629,6 @@ display(audio)
629
629
 
630
630
  You can use the `client.tts.get_output_format` method to convert string-based output format names into the `output_format` dictionary which is expected by the `output_format` parameter. You can see the `OutputFormatMapping` class in `cartesia._types` for the currently supported output format names. You can also view the currently supported `output_format`s in our [API Reference](https://docs.cartesia.ai/reference/api-reference/rest/stream-speech-server-sent-events).
631
631
 
632
- The previously used `output_format` strings are now deprecated and will be removed in v1.2.0. These are listed in the `DeprecatedOutputFormatMapping` class in `cartesia._types`.
633
-
634
632
  ```python
635
633
  # Get the output format dictionary from string name
636
634
  output_format = client.tts.get_output_format("raw_pcm_f32le_44100")
@@ -27,39 +27,6 @@ class OutputFormatMapping:
27
27
  raise ValueError(f"Unsupported format: {format_name}")
28
28
 
29
29
 
30
- class DeprecatedOutputFormatMapping:
31
- """Deprecated formats as of v1.0.1. These will be removed in v1.2.0. Use :class:`OutputFormatMapping` instead."""
32
-
33
- _format_mapping = {
34
- "fp32": {"container": "raw", "encoding": "pcm_f32le", "sample_rate": 44100},
35
- "pcm": {"container": "raw", "encoding": "pcm_s16le", "sample_rate": 44100},
36
- "fp32_8000": {"container": "raw", "encoding": "pcm_f32le", "sample_rate": 8000},
37
- "fp32_16000": {"container": "raw", "encoding": "pcm_f32le", "sample_rate": 16000},
38
- "fp32_22050": {"container": "raw", "encoding": "pcm_f32le", "sample_rate": 22050},
39
- "fp32_24000": {"container": "raw", "encoding": "pcm_f32le", "sample_rate": 24000},
40
- "fp32_44100": {"container": "raw", "encoding": "pcm_f32le", "sample_rate": 44100},
41
- "pcm_8000": {"container": "raw", "encoding": "pcm_s16le", "sample_rate": 8000},
42
- "pcm_16000": {"container": "raw", "encoding": "pcm_s16le", "sample_rate": 16000},
43
- "pcm_22050": {"container": "raw", "encoding": "pcm_s16le", "sample_rate": 22050},
44
- "pcm_24000": {"container": "raw", "encoding": "pcm_s16le", "sample_rate": 24000},
45
- "pcm_44100": {"container": "raw", "encoding": "pcm_s16le", "sample_rate": 44100},
46
- "mulaw_8000": {"container": "raw", "encoding": "pcm_mulaw", "sample_rate": 8000},
47
- "alaw_8000": {"container": "raw", "encoding": "pcm_alaw", "sample_rate": 8000},
48
- }
49
-
50
- @classmethod
51
- @deprecated(
52
- vdeprecated="1.0.1",
53
- vremove="1.2.0",
54
- reason="Old output format names are being deprecated in favor of names aligned with the Cartesia API. Use names from `OutputFormatMapping` instead.",
55
- )
56
- def get_format_deprecated(cls, format_name):
57
- if format_name in cls._format_mapping:
58
- return cls._format_mapping[format_name]
59
- else:
60
- raise ValueError(f"Unsupported format: {format_name}")
61
-
62
-
63
30
  class VoiceMetadata(TypedDict):
64
31
  id: str
65
32
  name: str
@@ -4,7 +4,6 @@ import httpx
4
4
 
5
5
  from cartesia._sse import _SSE
6
6
  from cartesia._types import (
7
- DeprecatedOutputFormatMapping,
8
7
  OutputFormat,
9
8
  OutputFormatMapping,
10
9
  VoiceControls,
@@ -86,10 +85,6 @@ class TTS(Resource):
86
85
  """
87
86
  if output_format_name in OutputFormatMapping._format_mapping:
88
87
  output_format_obj = OutputFormatMapping.get_format(output_format_name)
89
- elif output_format_name in DeprecatedOutputFormatMapping._format_mapping:
90
- output_format_obj = DeprecatedOutputFormatMapping.get_format_deprecated(
91
- output_format_name
92
- )
93
88
  else:
94
89
  raise ValueError(f"Unsupported format: {output_format_name}")
95
90
 
@@ -114,10 +109,6 @@ class TTS(Resource):
114
109
  """
115
110
  if output_format_name in OutputFormatMapping._format_mapping:
116
111
  output_format_obj = OutputFormatMapping.get_format(output_format_name)
117
- elif output_format_name in DeprecatedOutputFormatMapping._format_mapping:
118
- output_format_obj = DeprecatedOutputFormatMapping.get_format_deprecated(
119
- output_format_name
120
- )
121
112
  else:
122
113
  raise ValueError(f"Unsupported format: {output_format_name}")
123
114
 
@@ -0,0 +1 @@
1
+ __version__ = "1.2.0"
@@ -58,29 +58,65 @@ class Voices(Resource):
58
58
 
59
59
  return response.json()
60
60
 
61
- def clone(self, filepath: Optional[str] = None, enhance: str = True) -> List[float]:
61
+ def clone(
62
+ self,
63
+ filepath: Optional[str] = None,
64
+ enhance: str = True,
65
+ mode: str = "clip",
66
+ language: str = "en",
67
+ name: Optional[str] = None,
68
+ description: Optional[str] = None,
69
+ transcript: Optional[str] = None,
70
+ ) -> Union[List[float], VoiceMetadata]:
62
71
  """Clone a voice from a clip.
63
72
 
64
73
  Args:
65
74
  filepath: The path to the clip file.
66
75
  enhance: Whether to enhance the clip before cloning the voice (highly recommended). Defaults to True.
76
+ mode: The mode to use for cloning. Either "similarity" or "stability".
77
+ language: The language code of the language spoken in the clip. Defaults to "en".
78
+ name: The name of the cloned voice.
79
+ description: The description of the cloned voice.
80
+ transcript: The transcript of the clip. Only used if mode is "similarity".
67
81
 
68
82
  Returns:
69
83
  The embedding of the cloned voice as a list of floats.
70
84
  """
71
85
  if not filepath:
72
86
  raise ValueError("Filepath must be specified.")
73
- url = f"{self._http_url()}/voices/clone/clip"
87
+ headers = self.headers.copy()
88
+ headers.pop("Content-Type", None)
89
+
74
90
  with open(filepath, "rb") as file:
75
91
  files = {"clip": file}
76
- files["enhance"] = str(enhance).lower()
77
- headers = self.headers.copy()
78
- headers.pop("Content-Type", None)
79
- response = httpx.post(url, headers=headers, files=files, timeout=self.timeout)
80
- if not response.is_success:
81
- raise ValueError(f"Failed to clone voice from clip. Error: {response.text}")
82
-
83
- return response.json()["embedding"]
92
+ data = {
93
+ "enhance": str(enhance).lower(),
94
+ "mode": mode,
95
+ }
96
+ if mode == "clip":
97
+ url = f"{self._http_url()}/voices/clone/clip"
98
+ response = httpx.post(
99
+ url, headers=headers, files=files, data=data, timeout=self.timeout
100
+ )
101
+ if not response.is_success:
102
+ raise ValueError(f"Failed to clone voice from clip. Error: {response.text}")
103
+ return response.json()["embedding"]
104
+ else:
105
+ data["name"] = name
106
+ data["description"] = description
107
+ data["language"] = language
108
+ if mode == "similarity" and transcript:
109
+ data["transcript"] = transcript
110
+ url = f"{self._http_url()}/voices/clone"
111
+ response = httpx.post(
112
+ url, headers=headers, files=files, data=data, timeout=self.timeout
113
+ )
114
+ if not response.is_success:
115
+ raise ValueError(
116
+ f"Failed to clone voice. Status Code: {response.status_code}\n"
117
+ f"Error: {response.text}"
118
+ )
119
+ return response.json()
84
120
 
85
121
  def create(
86
122
  self,
@@ -88,6 +124,7 @@ class Voices(Resource):
88
124
  description: str,
89
125
  embedding: List[float],
90
126
  base_voice_id: Optional[str] = None,
127
+ language: str = "en",
91
128
  ) -> VoiceMetadata:
92
129
  """Create a new voice.
93
130
 
@@ -108,6 +145,7 @@ class Voices(Resource):
108
145
  "description": description,
109
146
  "embedding": embedding,
110
147
  "base_voice_id": base_voice_id,
148
+ "language": language,
111
149
  },
112
150
  timeout=self.timeout,
113
151
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cartesia
3
- Version: 1.1.0.dev0
3
+ Version: 1.2.0
4
4
  Summary: The official Python library for the Cartesia API.
5
5
  Requires-Python: >=3.9
6
6
  Description-Content-Type: text/markdown
@@ -642,8 +642,6 @@ display(audio)
642
642
 
643
643
  You can use the `client.tts.get_output_format` method to convert string-based output format names into the `output_format` dictionary which is expected by the `output_format` parameter. You can see the `OutputFormatMapping` class in `cartesia._types` for the currently supported output format names. You can also view the currently supported `output_format`s in our [API Reference](https://docs.cartesia.ai/reference/api-reference/rest/stream-speech-server-sent-events).
644
644
 
645
- The previously used `output_format` strings are now deprecated and will be removed in v1.2.0. These are listed in the `DeprecatedOutputFormatMapping` class in `cartesia._types`.
646
-
647
645
  ```python
648
646
  # Get the output format dictionary from string name
649
647
  output_format = client.tts.get_output_format("raw_pcm_f32le_44100")
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "cartesia"
3
- version = "1.1.0-dev0"
3
+ version = "1.2.0"
4
4
  description = "The official Python library for the Cartesia API."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.9"
@@ -1093,17 +1093,6 @@ def test_output_formats(resources: _Resources, output_format_name: str):
1093
1093
  assert output_format["encoding"] is not None, "Output format encoding is None"
1094
1094
  assert output_format["sample_rate"] is not None, "Output format sample rate is None"
1095
1095
 
1096
-
1097
- @pytest.mark.parametrize("output_format_name", deprecated_output_format_names)
1098
- def test_deprecated_output_formats(resources: _Resources, output_format_name: str):
1099
- logger.info(f"Testing deprecated output format: {output_format_name}")
1100
- output_format = resources.client.tts.get_output_format(output_format_name)
1101
- assert isinstance(output_format, dict), "Output is not of type dict"
1102
- assert output_format["container"] is not None, "Output format container is None"
1103
- assert output_format["encoding"] is not None, "Output format encoding is None"
1104
- assert output_format["sample_rate"] is not None, "Output format sample rate is None"
1105
-
1106
-
1107
1096
  def test_invalid_output_format(resources: _Resources):
1108
1097
  logger.info("Testing invalid output format")
1109
1098
  with pytest.raises(ValueError):
@@ -1 +0,0 @@
1
- __version__ = "1.1.0-dev0"
File without changes
File without changes
File without changes