livekit-plugins-elevenlabs 0.8.0__py3-none-any.whl → 1.0.0.dev4__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/elevenlabs/tts.py +19 -24
- livekit/plugins/elevenlabs/version.py +1 -1
- {livekit_plugins_elevenlabs-0.8.0.dist-info → livekit_plugins_elevenlabs-1.0.0.dev4.dist-info}/METADATA +10 -20
- livekit_plugins_elevenlabs-1.0.0.dev4.dist-info/RECORD +9 -0
- {livekit_plugins_elevenlabs-0.8.0.dist-info → livekit_plugins_elevenlabs-1.0.0.dev4.dist-info}/WHEEL +1 -2
- livekit_plugins_elevenlabs-0.8.0.dist-info/RECORD +0 -10
- livekit_plugins_elevenlabs-0.8.0.dist-info/top_level.txt +0 -1
@@ -21,9 +21,10 @@ import json
|
|
21
21
|
import os
|
22
22
|
import weakref
|
23
23
|
from dataclasses import dataclass
|
24
|
-
from typing import Any
|
24
|
+
from typing import Any
|
25
25
|
|
26
26
|
import aiohttp
|
27
|
+
|
27
28
|
from livekit.agents import (
|
28
29
|
APIConnectionError,
|
29
30
|
APIConnectOptions,
|
@@ -106,9 +107,9 @@ class TTS(tts.TTS):
|
|
106
107
|
base_url: str | None = None,
|
107
108
|
streaming_latency: int = 0,
|
108
109
|
inactivity_timeout: int = WS_INACTIVITY_TIMEOUT,
|
109
|
-
word_tokenizer:
|
110
|
+
word_tokenizer: tokenize.WordTokenizer | None = None,
|
110
111
|
enable_ssml_parsing: bool = False,
|
111
|
-
chunk_length_schedule: list[int] =
|
112
|
+
chunk_length_schedule: list[int] = None, # range is [50, 500]
|
112
113
|
http_session: aiohttp.ClientSession | None = None,
|
113
114
|
# deprecated
|
114
115
|
model_id: TTSModels | str | None = None,
|
@@ -131,6 +132,8 @@ class TTS(tts.TTS):
|
|
131
132
|
language (str | None): Language code for the TTS model, as of 10/24/24 only valid for "eleven_turbo_v2_5". Optional.
|
132
133
|
"""
|
133
134
|
|
135
|
+
if chunk_length_schedule is None:
|
136
|
+
chunk_length_schedule = [80, 120, 200, 260]
|
134
137
|
super().__init__(
|
135
138
|
capabilities=tts.TTSCapabilities(
|
136
139
|
streaming=True,
|
@@ -201,7 +204,7 @@ class TTS(tts.TTS):
|
|
201
204
|
def prewarm(self) -> None:
|
202
205
|
self._pool.prewarm()
|
203
206
|
|
204
|
-
async def list_voices(self) ->
|
207
|
+
async def list_voices(self) -> list[Voice]:
|
205
208
|
async with self._ensure_session().get(
|
206
209
|
f"{self._opts.base_url}/voices",
|
207
210
|
headers={AUTHORIZATION_HEADER: self._opts.api_key},
|
@@ -229,8 +232,8 @@ class TTS(tts.TTS):
|
|
229
232
|
self,
|
230
233
|
text: str,
|
231
234
|
*,
|
232
|
-
conn_options:
|
233
|
-
) ->
|
235
|
+
conn_options: APIConnectOptions | None = None,
|
236
|
+
) -> ChunkedStream:
|
234
237
|
return ChunkedStream(
|
235
238
|
tts=self,
|
236
239
|
input_text=text,
|
@@ -239,9 +242,7 @@ class TTS(tts.TTS):
|
|
239
242
|
session=self._ensure_session(),
|
240
243
|
)
|
241
244
|
|
242
|
-
def stream(
|
243
|
-
self, *, conn_options: Optional[APIConnectOptions] = None
|
244
|
-
) -> "SynthesizeStream":
|
245
|
+
def stream(self, *, conn_options: APIConnectOptions | None = None) -> SynthesizeStream:
|
245
246
|
stream = SynthesizeStream(tts=self, pool=self._pool, opts=self._opts)
|
246
247
|
self._streams.add(stream)
|
247
248
|
return stream
|
@@ -263,7 +264,7 @@ class ChunkedStream(tts.ChunkedStream):
|
|
263
264
|
tts: TTS,
|
264
265
|
input_text: str,
|
265
266
|
opts: _TTSOptions,
|
266
|
-
conn_options:
|
267
|
+
conn_options: APIConnectOptions | None = None,
|
267
268
|
session: aiohttp.ClientSession,
|
268
269
|
) -> None:
|
269
270
|
super().__init__(tts=tts, input_text=input_text, conn_options=conn_options)
|
@@ -407,17 +408,13 @@ class SynthesizeStream(tts.SynthesizeStream):
|
|
407
408
|
)
|
408
409
|
|
409
410
|
# 11labs protocol expects the first message to be an "init msg"
|
410
|
-
init_pkt =
|
411
|
-
text
|
412
|
-
voice_settings
|
413
|
-
dataclasses.asdict(self._opts.voice.settings)
|
414
|
-
)
|
411
|
+
init_pkt = {
|
412
|
+
"text": " ",
|
413
|
+
"voice_settings": _strip_nones(dataclasses.asdict(self._opts.voice.settings))
|
415
414
|
if self._opts.voice.settings
|
416
415
|
else None,
|
417
|
-
generation_config
|
418
|
-
|
419
|
-
),
|
420
|
-
)
|
416
|
+
"generation_config": {"chunk_length_schedule": self._opts.chunk_length_schedule},
|
417
|
+
}
|
421
418
|
await ws_conn.send_str(json.dumps(init_pkt))
|
422
419
|
|
423
420
|
@utils.log_exceptions(logger=logger)
|
@@ -440,7 +437,7 @@ class SynthesizeStream(tts.SynthesizeStream):
|
|
440
437
|
else:
|
441
438
|
continue
|
442
439
|
|
443
|
-
data_pkt =
|
440
|
+
data_pkt = {"text": f"{text} "} # must always end with a space
|
444
441
|
self._mark_started()
|
445
442
|
await ws_conn.send_str(json.dumps(data_pkt))
|
446
443
|
if xml_content:
|
@@ -487,9 +484,7 @@ class SynthesizeStream(tts.SynthesizeStream):
|
|
487
484
|
decoder.push(b64data)
|
488
485
|
|
489
486
|
if alignment := data.get("normalizedAlignment"):
|
490
|
-
received_text += "".join(
|
491
|
-
alignment.get("chars", [])
|
492
|
-
).replace(" ", "")
|
487
|
+
received_text += "".join(alignment.get("chars", [])).replace(" ", "")
|
493
488
|
if received_text == expected_text:
|
494
489
|
decoder.end_input()
|
495
490
|
break
|
@@ -534,7 +529,7 @@ class SynthesizeStream(tts.SynthesizeStream):
|
|
534
529
|
|
535
530
|
|
536
531
|
def _dict_to_voices_list(data: dict[str, Any]):
|
537
|
-
voices:
|
532
|
+
voices: list[Voice] = []
|
538
533
|
for voice in data["voices"]:
|
539
534
|
voices.append(
|
540
535
|
Voice(
|
@@ -1,35 +1,25 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: livekit-plugins-elevenlabs
|
3
|
-
Version: 0.
|
3
|
+
Version: 1.0.0.dev4
|
4
4
|
Summary: Agent Framework plugin for voice synthesis with ElevenLabs' API.
|
5
|
-
Home-page: https://github.com/livekit/agents
|
6
|
-
License: Apache-2.0
|
7
5
|
Project-URL: Documentation, https://docs.livekit.io
|
8
6
|
Project-URL: Website, https://livekit.io/
|
9
7
|
Project-URL: Source, https://github.com/livekit/agents
|
10
|
-
|
8
|
+
Author-email: LiveKit <support@livekit.io>
|
9
|
+
License-Expression: Apache-2.0
|
10
|
+
Keywords: audio,elevenlabs,livekit,realtime,video,webrtc
|
11
11
|
Classifier: Intended Audience :: Developers
|
12
12
|
Classifier: License :: OSI Approved :: Apache Software License
|
13
|
-
Classifier: Topic :: Multimedia :: Sound/Audio
|
14
|
-
Classifier: Topic :: Multimedia :: Video
|
15
|
-
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
16
13
|
Classifier: Programming Language :: Python :: 3
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
17
15
|
Classifier: Programming Language :: Python :: 3.9
|
18
16
|
Classifier: Programming Language :: Python :: 3.10
|
19
|
-
Classifier:
|
17
|
+
Classifier: Topic :: Multimedia :: Sound/Audio
|
18
|
+
Classifier: Topic :: Multimedia :: Video
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
20
20
|
Requires-Python: >=3.9.0
|
21
|
+
Requires-Dist: livekit-agents>=1.0.0.dev4
|
21
22
|
Description-Content-Type: text/markdown
|
22
|
-
Requires-Dist: livekit-agents[codecs]<1.0.0,>=0.12.16
|
23
|
-
Dynamic: classifier
|
24
|
-
Dynamic: description
|
25
|
-
Dynamic: description-content-type
|
26
|
-
Dynamic: home-page
|
27
|
-
Dynamic: keywords
|
28
|
-
Dynamic: license
|
29
|
-
Dynamic: project-url
|
30
|
-
Dynamic: requires-dist
|
31
|
-
Dynamic: requires-python
|
32
|
-
Dynamic: summary
|
33
23
|
|
34
24
|
# LiveKit Plugins Elevenlabs
|
35
25
|
|
@@ -0,0 +1,9 @@
|
|
1
|
+
livekit/plugins/elevenlabs/__init__.py,sha256=YZVadomFq3JWiZN6GWXJbuE4vaNNWq1CmdH25du8qwg,1249
|
2
|
+
livekit/plugins/elevenlabs/log.py,sha256=hIuXqDsEB5GBa7rQY3z4Uqi1oCqc_lRmCHZEmXz0LHw,73
|
3
|
+
livekit/plugins/elevenlabs/models.py,sha256=nB43wLS1ilzS7IxLYVSQxBjKPnbiPl4AHpHAOlG2i00,273
|
4
|
+
livekit/plugins/elevenlabs/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
|
+
livekit/plugins/elevenlabs/tts.py,sha256=eJ66yP3ta2FH0LgQ64wHdjOHEoavwguOg6GeaMIr9IU,20394
|
6
|
+
livekit/plugins/elevenlabs/version.py,sha256=koM_bT4QbztrKQ60Gjg7V4oe99CuxgGcpuUtWMOEKqU,605
|
7
|
+
livekit_plugins_elevenlabs-1.0.0.dev4.dist-info/METADATA,sha256=1YSGTLIaJURkWYEOIl2LqZLdgU3y1KFM4YvGvd8s4G8,1316
|
8
|
+
livekit_plugins_elevenlabs-1.0.0.dev4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
9
|
+
livekit_plugins_elevenlabs-1.0.0.dev4.dist-info/RECORD,,
|
@@ -1,10 +0,0 @@
|
|
1
|
-
livekit/plugins/elevenlabs/__init__.py,sha256=YZVadomFq3JWiZN6GWXJbuE4vaNNWq1CmdH25du8qwg,1249
|
2
|
-
livekit/plugins/elevenlabs/log.py,sha256=hIuXqDsEB5GBa7rQY3z4Uqi1oCqc_lRmCHZEmXz0LHw,73
|
3
|
-
livekit/plugins/elevenlabs/models.py,sha256=nB43wLS1ilzS7IxLYVSQxBjKPnbiPl4AHpHAOlG2i00,273
|
4
|
-
livekit/plugins/elevenlabs/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
|
-
livekit/plugins/elevenlabs/tts.py,sha256=KCZnuAngDZck4zIMMgp0BLV0GS31kKChMvdvXUVZ8vY,20491
|
6
|
-
livekit/plugins/elevenlabs/version.py,sha256=fObgfvFfJb5Vj0qY1hgEiVKSo6z6atjrJvwAVl4KvR4,600
|
7
|
-
livekit_plugins_elevenlabs-0.8.0.dist-info/METADATA,sha256=BwddENtvF9zqxTgjgIsHyavyRfA82TBISYEVwFfo2vs,1529
|
8
|
-
livekit_plugins_elevenlabs-0.8.0.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
|
9
|
-
livekit_plugins_elevenlabs-0.8.0.dist-info/top_level.txt,sha256=OoDok3xUmXbZRvOrfvvXB-Juu4DX79dlq188E19YHoo,8
|
10
|
-
livekit_plugins_elevenlabs-0.8.0.dist-info/RECORD,,
|
@@ -1 +0,0 @@
|
|
1
|
-
livekit
|