cartesia 1.1.0.dev0__py3-none-any.whl → 1.2.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/_types.py +0 -33
- cartesia/tts.py +0 -9
- cartesia/version.py +1 -1
- cartesia/voices.py +48 -10
- {cartesia-1.1.0.dev0.dist-info → cartesia-1.2.0.dist-info}/METADATA +1 -3
- {cartesia-1.1.0.dev0.dist-info → cartesia-1.2.0.dist-info}/RECORD +9 -9
- {cartesia-1.1.0.dev0.dist-info → cartesia-1.2.0.dist-info}/WHEEL +1 -1
- {cartesia-1.1.0.dev0.dist-info → cartesia-1.2.0.dist-info}/LICENSE.md +0 -0
- {cartesia-1.1.0.dev0.dist-info → cartesia-1.2.0.dist-info}/top_level.txt +0 -0
cartesia/_types.py
CHANGED
@@ -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
|
cartesia/tts.py
CHANGED
@@ -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
|
|
cartesia/version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "1.
|
1
|
+
__version__ = "1.2.0"
|
cartesia/voices.py
CHANGED
@@ -58,29 +58,65 @@ class Voices(Resource):
|
|
58
58
|
|
59
59
|
return response.json()
|
60
60
|
|
61
|
-
def clone(
|
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
|
-
|
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
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
if
|
81
|
-
|
82
|
-
|
83
|
-
|
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.
|
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")
|
@@ -4,21 +4,21 @@ cartesia/_async_websocket.py,sha256=Gy0nK3g2HKIBwh-PP1AunEBj83kgFpTGCvrq6tnwg9c,
|
|
4
4
|
cartesia/_constants.py,sha256=lquaYIg7IThdmC1fCklnWC8EM7stbSeVCDwRqCzPq-U,389
|
5
5
|
cartesia/_logger.py,sha256=vU7QiGSy_AJuJFmClUocqIJ-Ltku_8C24ZU8L6fLJR0,53
|
6
6
|
cartesia/_sse.py,sha256=CugabGUAUM-N2BruxNFxDB20HyxDlRdbN-J_yAzvBMY,5667
|
7
|
-
cartesia/_types.py,sha256=
|
7
|
+
cartesia/_types.py,sha256=gixQbKbX-H8xbD7jxHmc02KXLyjEaup19lh_57_YBl8,2570
|
8
8
|
cartesia/_websocket.py,sha256=CpqkShdl4qBjCGMR8s6dEBHK0LJxkrG-FjbPLhjOP-U,14735
|
9
9
|
cartesia/async_client.py,sha256=y_K_Yuv0weA4k9ZYD0M9bNM3x3frsq07tqkg7R9h0-o,2714
|
10
10
|
cartesia/async_tts.py,sha256=IbWVRKklNClXASR6ylHaukcMRR304LUguqc4yMopbDU,2076
|
11
11
|
cartesia/client.py,sha256=OS1ORUSlR8Jg-em1imeTAFfwkC85AQFnw8PYtTdUuC8,2364
|
12
12
|
cartesia/resource.py,sha256=wpnB3IPcTdxYSp0vxSkpntp4NSvqvnwUWF-0ZpgWV9o,1585
|
13
|
-
cartesia/tts.py,sha256=
|
14
|
-
cartesia/version.py,sha256=
|
15
|
-
cartesia/voices.py,sha256=
|
13
|
+
cartesia/tts.py,sha256=kWvqce9K3gZ4QrWD-ciYdK29n49SNkxhd2A7ueTOwMY,4878
|
14
|
+
cartesia/version.py,sha256=MpAT5hgNoHnTtG1XRD_GV_A7QrHVU6vJjGSw_8qMGA4,22
|
15
|
+
cartesia/voices.py,sha256=bDYbs0KoikAROJlmbnLdo4TrW0YwzjMvp70uKG6Alp0,7180
|
16
16
|
cartesia/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
17
17
|
cartesia/utils/deprecated.py,sha256=2cXvGtrxhPeUZA5LWy2n_U5OFLDv7SHeFtzqhjSJGyk,1674
|
18
18
|
cartesia/utils/retry.py,sha256=O6fyVWpH9Su8c0Fwupl57xMt6JrwJ52txBwP3faUL7k,3339
|
19
19
|
cartesia/utils/tts.py,sha256=7tJmdyOYwe2QIav5d1UZxhpbcHaYqf7A77bBOlb4U_g,2100
|
20
|
-
cartesia-1.
|
21
|
-
cartesia-1.
|
22
|
-
cartesia-1.
|
23
|
-
cartesia-1.
|
24
|
-
cartesia-1.
|
20
|
+
cartesia-1.2.0.dist-info/LICENSE.md,sha256=PT2YG5wEtEX1TNDn5sXkUXqbn-neyr7cZenTxd40ql4,1074
|
21
|
+
cartesia-1.2.0.dist-info/METADATA,sha256=XkVlNno4gSjSecAC0fBIqcvRP_YUAYs6D6dzIdk-c7w,21006
|
22
|
+
cartesia-1.2.0.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
|
23
|
+
cartesia-1.2.0.dist-info/top_level.txt,sha256=rTX4HnnCegMxl1FK9czpVC7GAvf3SwDzPG65qP-BS4w,9
|
24
|
+
cartesia-1.2.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|