livekit-plugins-cartesia 0.4.8__py3-none-any.whl → 0.4.9__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.
- livekit/plugins/cartesia/tts.py +20 -32
- livekit/plugins/cartesia/version.py +1 -1
- {livekit_plugins_cartesia-0.4.8.dist-info → livekit_plugins_cartesia-0.4.9.dist-info}/METADATA +2 -2
- livekit_plugins_cartesia-0.4.9.dist-info/RECORD +10 -0
- livekit_plugins_cartesia-0.4.8.dist-info/RECORD +0 -10
- {livekit_plugins_cartesia-0.4.8.dist-info → livekit_plugins_cartesia-0.4.9.dist-info}/WHEEL +0 -0
- {livekit_plugins_cartesia-0.4.8.dist-info → livekit_plugins_cartesia-0.4.9.dist-info}/top_level.txt +0 -0
livekit/plugins/cartesia/tts.py
CHANGED
@@ -23,7 +23,6 @@ from dataclasses import dataclass
|
|
23
23
|
from typing import Any, Optional
|
24
24
|
|
25
25
|
import aiohttp
|
26
|
-
from livekit import rtc
|
27
26
|
from livekit.agents import (
|
28
27
|
APIConnectionError,
|
29
28
|
APIConnectOptions,
|
@@ -128,6 +127,8 @@ class TTS(tts.TTS):
|
|
128
127
|
self._pool = utils.ConnectionPool[aiohttp.ClientWebSocketResponse](
|
129
128
|
connect_cb=self._connect_ws,
|
130
129
|
close_cb=self._close_ws,
|
130
|
+
max_session_duration=300,
|
131
|
+
mark_refreshed_on_get=True,
|
131
132
|
)
|
132
133
|
self._streams = weakref.WeakSet[SynthesizeStream]()
|
133
134
|
|
@@ -149,6 +150,9 @@ class TTS(tts.TTS):
|
|
149
150
|
|
150
151
|
return self._session
|
151
152
|
|
153
|
+
def prewarm(self) -> None:
|
154
|
+
self._pool.prewarm()
|
155
|
+
|
152
156
|
def update_options(
|
153
157
|
self,
|
154
158
|
*,
|
@@ -251,19 +255,17 @@ class ChunkedStream(tts.ChunkedStream):
|
|
251
255
|
),
|
252
256
|
) as resp:
|
253
257
|
resp.raise_for_status()
|
258
|
+
emitter = tts.SynthesizedAudioEmitter(
|
259
|
+
event_ch=self._event_ch,
|
260
|
+
request_id=request_id,
|
261
|
+
)
|
254
262
|
async for data, _ in resp.content.iter_chunks():
|
255
263
|
for frame in bstream.write(data):
|
256
|
-
|
257
|
-
tts.SynthesizedAudio(
|
258
|
-
request_id=request_id,
|
259
|
-
frame=frame,
|
260
|
-
)
|
261
|
-
)
|
264
|
+
emitter.push(frame)
|
262
265
|
|
263
266
|
for frame in bstream.flush():
|
264
|
-
|
265
|
-
|
266
|
-
)
|
267
|
+
emitter.push(frame)
|
268
|
+
emitter.flush()
|
267
269
|
except asyncio.TimeoutError as e:
|
268
270
|
raise APITimeoutError() from e
|
269
271
|
except aiohttp.ClientResponseError as e:
|
@@ -323,22 +325,10 @@ class SynthesizeStream(tts.SynthesizeStream):
|
|
323
325
|
sample_rate=self._opts.sample_rate,
|
324
326
|
num_channels=NUM_CHANNELS,
|
325
327
|
)
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
nonlocal last_frame
|
331
|
-
if last_frame is not None:
|
332
|
-
self._event_ch.send_nowait(
|
333
|
-
tts.SynthesizedAudio(
|
334
|
-
request_id=request_id,
|
335
|
-
segment_id=segment_id,
|
336
|
-
frame=last_frame,
|
337
|
-
is_final=is_final,
|
338
|
-
)
|
339
|
-
)
|
340
|
-
|
341
|
-
last_frame = None
|
328
|
+
emitter = tts.SynthesizedAudioEmitter(
|
329
|
+
event_ch=self._event_ch,
|
330
|
+
request_id=request_id,
|
331
|
+
)
|
342
332
|
|
343
333
|
while True:
|
344
334
|
msg = await ws.receive()
|
@@ -358,18 +348,16 @@ class SynthesizeStream(tts.SynthesizeStream):
|
|
358
348
|
|
359
349
|
data = json.loads(msg.data)
|
360
350
|
segment_id = data.get("context_id")
|
351
|
+
emitter._segment_id = segment_id
|
361
352
|
|
362
353
|
if data.get("data"):
|
363
354
|
b64data = base64.b64decode(data["data"])
|
364
355
|
for frame in audio_bstream.write(b64data):
|
365
|
-
|
366
|
-
last_frame = frame
|
356
|
+
emitter.push(frame)
|
367
357
|
elif data.get("done"):
|
368
358
|
for frame in audio_bstream.flush():
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
_send_last_frame(segment_id=segment_id, is_final=True)
|
359
|
+
emitter.push(frame)
|
360
|
+
emitter.flush()
|
373
361
|
if segment_id == request_id:
|
374
362
|
# we're not going to receive more frames, end stream
|
375
363
|
break
|
{livekit_plugins_cartesia-0.4.8.dist-info → livekit_plugins_cartesia-0.4.9.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: livekit-plugins-cartesia
|
3
|
-
Version: 0.4.
|
3
|
+
Version: 0.4.9
|
4
4
|
Summary: LiveKit Agents Plugin for Cartesia
|
5
5
|
Home-page: https://github.com/livekit/agents
|
6
6
|
License: Apache-2.0
|
@@ -19,7 +19,7 @@ Classifier: Programming Language :: Python :: 3.10
|
|
19
19
|
Classifier: Programming Language :: Python :: 3 :: Only
|
20
20
|
Requires-Python: >=3.9.0
|
21
21
|
Description-Content-Type: text/markdown
|
22
|
-
Requires-Dist: livekit-agents
|
22
|
+
Requires-Dist: livekit-agents<1.0.0,>=0.12.16
|
23
23
|
Dynamic: classifier
|
24
24
|
Dynamic: description
|
25
25
|
Dynamic: description-content-type
|
@@ -0,0 +1,10 @@
|
|
1
|
+
livekit/plugins/cartesia/__init__.py,sha256=UTa6Q7IxhRBCwPftowHEUDvmBg99J_UjGS_yxTzKD7g,1095
|
2
|
+
livekit/plugins/cartesia/log.py,sha256=4Mnhjng_DU1dIWP9IWjIQGZ67EV3LnQhWMWCHVudJbo,71
|
3
|
+
livekit/plugins/cartesia/models.py,sha256=56CJgo7my-w-vpedir_ImV_aqKASeLihE5DbcCCgGJI,950
|
4
|
+
livekit/plugins/cartesia/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
|
+
livekit/plugins/cartesia/tts.py,sha256=C7R_Z2nmWK3V0bQ30Nl5lgRgIZTfCzb7hiYWfBohGQs,14138
|
6
|
+
livekit/plugins/cartesia/version.py,sha256=IgraxfFuS50xVM2gugcS0QqKE5YXL-FzFLco3Ffq6BY,600
|
7
|
+
livekit_plugins_cartesia-0.4.9.dist-info/METADATA,sha256=P-63JHYrrl1DtEUBVVCnSPeS2vnws2dIdTPclQNG4ow,1470
|
8
|
+
livekit_plugins_cartesia-0.4.9.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
|
9
|
+
livekit_plugins_cartesia-0.4.9.dist-info/top_level.txt,sha256=OoDok3xUmXbZRvOrfvvXB-Juu4DX79dlq188E19YHoo,8
|
10
|
+
livekit_plugins_cartesia-0.4.9.dist-info/RECORD,,
|
@@ -1,10 +0,0 @@
|
|
1
|
-
livekit/plugins/cartesia/__init__.py,sha256=UTa6Q7IxhRBCwPftowHEUDvmBg99J_UjGS_yxTzKD7g,1095
|
2
|
-
livekit/plugins/cartesia/log.py,sha256=4Mnhjng_DU1dIWP9IWjIQGZ67EV3LnQhWMWCHVudJbo,71
|
3
|
-
livekit/plugins/cartesia/models.py,sha256=56CJgo7my-w-vpedir_ImV_aqKASeLihE5DbcCCgGJI,950
|
4
|
-
livekit/plugins/cartesia/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
|
-
livekit/plugins/cartesia/tts.py,sha256=UUnGrqizmnyHhA-rmbtVD6-pYCMEWozbZxlVRe0HFw4,14747
|
6
|
-
livekit/plugins/cartesia/version.py,sha256=1PUjLiYcL1-nwBUG1EXqZsTfF_WQI8KxpzCeCIZHeLc,600
|
7
|
-
livekit_plugins_cartesia-0.4.8.dist-info/METADATA,sha256=sJRr9rLGGOUcOonnwQX6xxbKu1Ag-DFWrxjBf4uhDtw,1463
|
8
|
-
livekit_plugins_cartesia-0.4.8.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
|
9
|
-
livekit_plugins_cartesia-0.4.8.dist-info/top_level.txt,sha256=OoDok3xUmXbZRvOrfvvXB-Juu4DX79dlq188E19YHoo,8
|
10
|
-
livekit_plugins_cartesia-0.4.8.dist-info/RECORD,,
|
File without changes
|
{livekit_plugins_cartesia-0.4.8.dist-info → livekit_plugins_cartesia-0.4.9.dist-info}/top_level.txt
RENAMED
File without changes
|