cartesia 1.0.7__py2.py3-none-any.whl → 1.0.8__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 CHANGED
@@ -23,7 +23,12 @@ import aiohttp
23
23
  import httpx
24
24
  import logging
25
25
  import requests
26
- from websockets.sync.client import connect
26
+ try:
27
+ from websockets.sync.client import connect
28
+ IS_WEBSOCKET_SYNC_AVAILABLE = True
29
+ except ImportError:
30
+ IS_WEBSOCKET_SYNC_AVAILABLE = False
31
+
27
32
  from iterators import TimeoutIterator
28
33
 
29
34
  from cartesia.utils.retry import retry_on_connection_error, retry_on_connection_error_async
@@ -208,37 +213,25 @@ class Voices(Resource):
208
213
  return response.json()
209
214
 
210
215
  def clone(self, filepath: Optional[str] = None, link: Optional[str] = None) -> List[float]:
211
- """Clone a voice from a clip or a URL.
216
+ """Clone a voice from a clip.
212
217
 
213
218
  Args:
214
219
  filepath: The path to the clip file.
215
- link: The URL to the clip
216
220
 
217
221
  Returns:
218
222
  The embedding of the cloned voice as a list of floats.
219
223
  """
220
224
  # TODO: Python has a bytes object, use that instead of a filepath
221
- if not filepath and not link:
222
- raise ValueError("At least one of 'filepath' or 'link' must be specified.")
223
- if filepath and link:
224
- raise ValueError("Only one of 'filepath' or 'link' should be specified.")
225
- if filepath:
226
- url = f"{self._http_url()}/voices/clone/clip"
227
- with open(filepath, "rb") as file:
228
- files = {"clip": file}
229
- headers = self.headers.copy()
230
- headers.pop("Content-Type", None)
231
- response = httpx.post(url, headers=headers, files=files, timeout=self.timeout)
232
- if not response.is_success:
233
- raise ValueError(f"Failed to clone voice from clip. Error: {response.text}")
234
- elif link:
235
- url = f"{self._http_url()}/voices/clone/url"
236
- params = {"link": link}
225
+ if not filepath:
226
+ raise ValueError("Filepath must be specified.")
227
+ url = f"{self._http_url()}/voices/clone/clip"
228
+ with open(filepath, "rb") as file:
229
+ files = {"clip": file}
237
230
  headers = self.headers.copy()
238
- headers.pop("Content-Type") # The content type header is not required for URLs
239
- response = httpx.post(url, headers=self.headers, params=params, timeout=self.timeout)
231
+ headers.pop("Content-Type", None)
232
+ response = httpx.post(url, headers=headers, files=files, timeout=self.timeout)
240
233
  if not response.is_success:
241
- raise ValueError(f"Failed to clone voice from URL. Error: {response.text}")
234
+ raise ValueError(f"Failed to clone voice from clip. Error: {response.text}")
242
235
 
243
236
  return response.json()["embedding"]
244
237
 
@@ -469,6 +462,10 @@ class _WebSocket:
469
462
  Raises:
470
463
  RuntimeError: If the connection to the WebSocket fails.
471
464
  """
465
+ if not IS_WEBSOCKET_SYNC_AVAILABLE:
466
+ raise ImportError(
467
+ "The synchronous WebSocket client is not available. Please ensure that you have 'websockets>=12.0' or compatible version installed."
468
+ )
472
469
  if self.websocket is None or self._is_websocket_closed():
473
470
  route = "tts/websocket"
474
471
  try:
cartesia/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "1.0.7"
1
+ __version__ = "1.0.8"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cartesia
3
- Version: 1.0.7
3
+ Version: 1.0.8
4
4
  Summary: The official Python library for the Cartesia API.
5
5
  Home-page:
6
6
  Author: Cartesia, Inc.
@@ -43,6 +43,22 @@ The official Cartesia Python library which provides convenient access to the Car
43
43
  > [!IMPORTANT]
44
44
  > The client library introduces breaking changes in v1.0.0, which was released on June 24th 2024. See the [release notes](https://github.com/cartesia-ai/cartesia-python/releases/tag/v1.0.0) and [migration guide](https://github.com/cartesia-ai/cartesia-python/discussions/44). Reach out to us on [Discord](https://discord.gg/ZVxavqHB9X) for any support requests!
45
45
 
46
+ - [Cartesia Python API Library](#cartesia-python-api-library)
47
+ - [Documentation](#documentation)
48
+ - [Installation](#installation)
49
+ - [Voices](#voices)
50
+ - [Text-to-Speech](#text-to-speech)
51
+ - [Server-Sent Events (SSE)](#server-sent-events-sse)
52
+ - [WebSocket](#websocket)
53
+ - [Conditioning speech on previous generations using WebSocket](#conditioning-speech-on-previous-generations-using-websocket)
54
+ - [Generating timestamps using WebSocket](#generating-timestamps-using-websocket)
55
+ - [Multilingual Text-to-Speech \[Alpha\]](#multilingual-text-to-speech-alpha)
56
+ - [Speed and Emotion Control \[Experimental\]](#speed-and-emotion-control-experimental)
57
+ - [Jupyter Notebook Usage](#jupyter-notebook-usage)
58
+ - [Utility methods](#utility-methods)
59
+ - [Output Formats](#output-formats)
60
+
61
+
46
62
  ## Documentation
47
63
 
48
64
  Our complete API documentation can be found [on docs.cartesia.ai](https://docs.cartesia.ai).
@@ -268,7 +284,7 @@ async def send_transcripts(ctx):
268
284
 
269
285
  # You can check out our models at https://docs.cartesia.ai/getting-started/available-models
270
286
  model_id = "sonic-english"
271
-
287
+
272
288
  # You can find the supported `output_format`s at https://docs.cartesia.ai/api-reference/endpoints/stream-speech-server-sent-events
273
289
  output_format = {
274
290
  "container": "raw",
@@ -284,7 +300,7 @@ async def send_transcripts(ctx):
284
300
  "As they near Eggman's lair, our heroes charge their abilities for an epic boss battle. ",
285
301
  "Get ready to spin, jump, and sound-blast your way to victory in this high-octane crossover!"
286
302
  ]
287
-
303
+
288
304
  for transcript in transcripts:
289
305
  # Send text inputs as they become available
290
306
  await ctx.send(
@@ -296,7 +312,7 @@ async def send_transcripts(ctx):
296
312
  )
297
313
 
298
314
  # Indicate that no more inputs will be sent. Otherwise, the context will close after 5 seconds of inactivity.
299
- await ctx.no_more_inputs()
315
+ await ctx.no_more_inputs()
300
316
 
301
317
  async def receive_and_play_audio(ctx):
302
318
  p = pyaudio.PyAudio()
@@ -402,7 +418,7 @@ output_stream = ctx.send(
402
418
  voice_id=voice_id,
403
419
  output_format=output_format,
404
420
  )
405
-
421
+
406
422
  for output in output_stream:
407
423
  buffer = output["audio"]
408
424
 
@@ -1,12 +1,12 @@
1
1
  cartesia/__init__.py,sha256=jMIf2O7dTGxvTA5AfXtmh1H_EGfMtQseR5wXrjNRbLs,93
2
2
  cartesia/_types.py,sha256=Lcp4GOot5UfI0EveDi2QdNALMo1rK4PwUrtMvW5P6vY,4406
3
- cartesia/client.py,sha256=1T_HboqHZO6wjUDYpuWI7igV-QF_cRL4DY7v4NDzApo,51871
4
- cartesia/version.py,sha256=BW7SWRpHoxuOQZ67pS20yog2LWYl-nK7-BEFBNrHGgA,22
3
+ cartesia/client.py,sha256=gOH3ddVI-epHbPGijM3jExSmMOZm8TiyOfZlLKWt89w,51485
4
+ cartesia/version.py,sha256=NND_6JDYnYnGzN3-RTpS5F7wzv62vDf7hAxiyTSBJfE,22
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=nuwWRfu3MOVTxIQMLjYf6WLaxSlnu_GdE3QjTV0zisQ,3339
8
- cartesia-1.0.7.dist-info/LICENSE.md,sha256=PT2YG5wEtEX1TNDn5sXkUXqbn-neyr7cZenTxd40ql4,1074
9
- cartesia-1.0.7.dist-info/METADATA,sha256=vvU7-K0raiw4hmotlST5wi6uSnGiXjMpHxd2CIzvbMc,20336
10
- cartesia-1.0.7.dist-info/WHEEL,sha256=DZajD4pwLWue70CAfc7YaxT1wLUciNBvN_TTcvXpltE,110
11
- cartesia-1.0.7.dist-info/top_level.txt,sha256=rTX4HnnCegMxl1FK9czpVC7GAvf3SwDzPG65qP-BS4w,9
12
- cartesia-1.0.7.dist-info/RECORD,,
8
+ cartesia-1.0.8.dist-info/LICENSE.md,sha256=PT2YG5wEtEX1TNDn5sXkUXqbn-neyr7cZenTxd40ql4,1074
9
+ cartesia-1.0.8.dist-info/METADATA,sha256=83WFXYyycaZfvqX_bdyctzx270x1PMYlC-5lUUcMVDs,21137
10
+ cartesia-1.0.8.dist-info/WHEEL,sha256=DZajD4pwLWue70CAfc7YaxT1wLUciNBvN_TTcvXpltE,110
11
+ cartesia-1.0.8.dist-info/top_level.txt,sha256=rTX4HnnCegMxl1FK9czpVC7GAvf3SwDzPG65qP-BS4w,9
12
+ cartesia-1.0.8.dist-info/RECORD,,