cartesia 1.0.8__tar.gz → 1.0.9__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.
- {cartesia-1.0.8 → cartesia-1.0.9}/PKG-INFO +1 -1
- cartesia-1.0.9/cartesia/__init__.py +3 -0
- {cartesia-1.0.8 → cartesia-1.0.9}/cartesia/_types.py +1 -0
- {cartesia-1.0.8 → cartesia-1.0.9}/cartesia/client.py +14 -12
- cartesia-1.0.9/cartesia/version.py +1 -0
- {cartesia-1.0.8 → cartesia-1.0.9}/cartesia.egg-info/PKG-INFO +1 -1
- {cartesia-1.0.8 → cartesia-1.0.9}/pyproject.toml +11 -11
- {cartesia-1.0.8 → cartesia-1.0.9}/tests/test_deprecated.py +2 -3
- {cartesia-1.0.8 → cartesia-1.0.9}/tests/test_tts.py +12 -5
- cartesia-1.0.8/cartesia/__init__.py +0 -3
- cartesia-1.0.8/cartesia/version.py +0 -1
- {cartesia-1.0.8 → cartesia-1.0.9}/LICENSE.md +0 -0
- {cartesia-1.0.8 → cartesia-1.0.9}/README.md +0 -0
- {cartesia-1.0.8 → cartesia-1.0.9}/cartesia/utils/__init__.py +0 -0
- {cartesia-1.0.8 → cartesia-1.0.9}/cartesia/utils/deprecated.py +0 -0
- {cartesia-1.0.8 → cartesia-1.0.9}/cartesia/utils/retry.py +3 -3
- {cartesia-1.0.8 → cartesia-1.0.9}/cartesia.egg-info/SOURCES.txt +0 -0
- {cartesia-1.0.8 → cartesia-1.0.9}/cartesia.egg-info/dependency_links.txt +0 -0
- {cartesia-1.0.8 → cartesia-1.0.9}/cartesia.egg-info/requires.txt +0 -0
- {cartesia-1.0.8 → cartesia-1.0.9}/cartesia.egg-info/top_level.txt +0 -0
- {cartesia-1.0.8 → cartesia-1.0.9}/setup.cfg +0 -0
- {cartesia-1.0.8 → cartesia-1.0.9}/setup.py +0 -0
@@ -1,46 +1,47 @@
|
|
1
1
|
import asyncio
|
2
2
|
import base64
|
3
|
-
from collections import defaultdict
|
4
3
|
import json
|
4
|
+
import logging
|
5
5
|
import os
|
6
6
|
import uuid
|
7
|
+
from collections import defaultdict
|
7
8
|
from types import TracebackType
|
8
9
|
from typing import (
|
9
10
|
Any,
|
10
11
|
AsyncGenerator,
|
11
|
-
|
12
|
+
Callable,
|
12
13
|
Dict,
|
13
14
|
Generator,
|
15
|
+
Iterator,
|
14
16
|
List,
|
15
17
|
Optional,
|
18
|
+
Set,
|
16
19
|
Tuple,
|
17
20
|
Union,
|
18
|
-
Callable,
|
19
|
-
Set,
|
20
21
|
)
|
21
22
|
|
22
23
|
import aiohttp
|
23
24
|
import httpx
|
24
|
-
import logging
|
25
25
|
import requests
|
26
|
+
|
26
27
|
try:
|
27
28
|
from websockets.sync.client import connect
|
29
|
+
|
28
30
|
IS_WEBSOCKET_SYNC_AVAILABLE = True
|
29
31
|
except ImportError:
|
30
32
|
IS_WEBSOCKET_SYNC_AVAILABLE = False
|
31
33
|
|
32
|
-
from iterators import TimeoutIterator
|
33
|
-
|
34
|
-
from cartesia.utils.retry import retry_on_connection_error, retry_on_connection_error_async
|
35
34
|
from cartesia._types import (
|
35
|
+
DeprecatedOutputFormatMapping,
|
36
36
|
EventType,
|
37
37
|
OutputFormat,
|
38
38
|
OutputFormatMapping,
|
39
|
-
DeprecatedOutputFormatMapping,
|
40
39
|
VoiceControls,
|
41
40
|
VoiceMetadata,
|
42
41
|
)
|
43
|
-
|
42
|
+
from cartesia.utils.retry import retry_on_connection_error, retry_on_connection_error_async
|
43
|
+
from iterators import TimeoutIterator
|
44
|
+
from websockets.sync.client import connect
|
44
45
|
|
45
46
|
DEFAULT_MODEL_ID = "sonic-english" # latest default model
|
46
47
|
MULTILINGUAL_MODEL_ID = "sonic-multilingual" # latest multilingual model
|
@@ -212,21 +213,22 @@ class Voices(Resource):
|
|
212
213
|
|
213
214
|
return response.json()
|
214
215
|
|
215
|
-
def clone(self, filepath: Optional[str] = None,
|
216
|
+
def clone(self, filepath: Optional[str] = None, enhance: str = True) -> List[float]:
|
216
217
|
"""Clone a voice from a clip.
|
217
218
|
|
218
219
|
Args:
|
219
220
|
filepath: The path to the clip file.
|
221
|
+
enhance: Whether to enhance the clip before cloning the voice (highly recommended). Defaults to True.
|
220
222
|
|
221
223
|
Returns:
|
222
224
|
The embedding of the cloned voice as a list of floats.
|
223
225
|
"""
|
224
|
-
# TODO: Python has a bytes object, use that instead of a filepath
|
225
226
|
if not filepath:
|
226
227
|
raise ValueError("Filepath must be specified.")
|
227
228
|
url = f"{self._http_url()}/voices/clone/clip"
|
228
229
|
with open(filepath, "rb") as file:
|
229
230
|
files = {"clip": file}
|
231
|
+
files["enhance"] = str(enhance).lower()
|
230
232
|
headers = self.headers.copy()
|
231
233
|
headers.pop("Content-Type", None)
|
232
234
|
response = httpx.post(url, headers=headers, files=files, timeout=self.timeout)
|
@@ -0,0 +1 @@
|
|
1
|
+
__version__ = "1.0.9"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[tool.ruff]
|
2
2
|
# Add more rule codes as needed
|
3
|
-
extend-select = [
|
3
|
+
lint.extend-select = [
|
4
4
|
"D", # pydocstyle - to replace docformatter
|
5
5
|
]
|
6
6
|
|
@@ -43,14 +43,14 @@ line-length = 100
|
|
43
43
|
# Enable the count of violations
|
44
44
|
output-format = "full"
|
45
45
|
|
46
|
-
[tool.ruff.
|
47
|
-
force-wrap-aliases = true
|
48
|
-
combine-as-imports = true
|
49
|
-
force-sort-within-sections = true
|
50
|
-
known-first-party = []
|
51
|
-
known-third-party = []
|
52
|
-
known-local-folder = []
|
53
|
-
lines-after-imports = 2
|
54
|
-
|
55
|
-
[tool.ruff.pydocstyle]
|
46
|
+
[tool.ruff.lint.pydocstyle]
|
56
47
|
convention = "google"
|
48
|
+
|
49
|
+
[tool.isort]
|
50
|
+
profile = "black"
|
51
|
+
multi_line_output = 3
|
52
|
+
include_trailing_comma = true
|
53
|
+
force_grid_wrap = 0
|
54
|
+
use_parentheses = true
|
55
|
+
ensure_newline_before_comments = true
|
56
|
+
line_length = 100
|
@@ -1,8 +1,7 @@
|
|
1
|
-
from packaging.version import Version
|
2
|
-
|
3
1
|
import cartesia as Cartesia
|
4
|
-
from cartesia.utils.deprecated import _DEPRECATED_FUNCTION_STATS
|
5
2
|
import cartesia.version as version
|
3
|
+
from cartesia.utils.deprecated import _DEPRECATED_FUNCTION_STATS
|
4
|
+
from packaging.version import Version
|
6
5
|
|
7
6
|
|
8
7
|
def test_deprecated_to_remove_by_version():
|
@@ -5,17 +5,18 @@ different results. Therefore, we cannot test for complete correctness but rather
|
|
5
5
|
general correctness.
|
6
6
|
"""
|
7
7
|
|
8
|
+
import asyncio
|
8
9
|
import logging
|
9
10
|
import os
|
10
11
|
import sys
|
11
|
-
|
12
|
-
from cartesia.client import DEFAULT_MODEL_ID, MULTILINGUAL_MODEL_ID
|
13
|
-
from cartesia._types import VoiceControls, VoiceMetadata
|
12
|
+
import uuid
|
14
13
|
from typing import AsyncGenerator, Generator, List
|
14
|
+
|
15
15
|
import numpy as np
|
16
16
|
import pytest
|
17
|
-
import
|
18
|
-
import
|
17
|
+
from cartesia import AsyncCartesia, Cartesia
|
18
|
+
from cartesia._types import VoiceControls, VoiceMetadata
|
19
|
+
from cartesia.client import DEFAULT_MODEL_ID, MULTILINGUAL_MODEL_ID
|
19
20
|
|
20
21
|
THISDIR = os.path.dirname(__file__)
|
21
22
|
sys.path.insert(0, os.path.dirname(THISDIR))
|
@@ -84,6 +85,12 @@ def test_clone_voice_with_file(client: Cartesia):
|
|
84
85
|
output = client.voices.clone(filepath=os.path.join(RESOURCES_DIR, "sample-speech-4s.wav"))
|
85
86
|
assert isinstance(output, list)
|
86
87
|
|
88
|
+
@pytest.mark.parametrize("enhance", [True, False])
|
89
|
+
def test_clone_voice_with_file_enhance(client: Cartesia, enhance: bool):
|
90
|
+
logger.info("Testing voices.clone with file")
|
91
|
+
output = client.voices.clone(filepath=os.path.join(RESOURCES_DIR, "sample-speech-4s.wav"), enhance=enhance)
|
92
|
+
assert isinstance(output, list)
|
93
|
+
|
87
94
|
def test_create_voice(client: Cartesia):
|
88
95
|
logger.info("Testing voices.create")
|
89
96
|
embedding = np.ones(192).tolist()
|
@@ -1 +0,0 @@
|
|
1
|
-
__version__ = "1.0.8"
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import time
|
2
|
-
|
3
|
-
from aiohttp.client_exceptions import ServerDisconnectedError
|
4
1
|
import asyncio
|
2
|
+
import time
|
5
3
|
from functools import wraps
|
6
4
|
from http.client import RemoteDisconnected
|
5
|
+
|
6
|
+
from aiohttp.client_exceptions import ServerDisconnectedError
|
7
7
|
from httpx import TimeoutException
|
8
8
|
from requests.exceptions import ConnectionError
|
9
9
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|