livekit-plugins-elevenlabs 0.7.2__py3-none-any.whl → 0.7.4__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 +28 -4
- livekit/plugins/elevenlabs/version.py +1 -1
- {livekit_plugins_elevenlabs-0.7.2.dist-info → livekit_plugins_elevenlabs-0.7.4.dist-info}/METADATA +1 -1
- livekit_plugins_elevenlabs-0.7.4.dist-info/RECORD +10 -0
- {livekit_plugins_elevenlabs-0.7.2.dist-info → livekit_plugins_elevenlabs-0.7.4.dist-info}/WHEEL +1 -1
- livekit_plugins_elevenlabs-0.7.2.dist-info/RECORD +0 -10
- {livekit_plugins_elevenlabs-0.7.2.dist-info → livekit_plugins_elevenlabs-0.7.4.dist-info}/top_level.txt +0 -0
@@ -86,6 +86,7 @@ class _TTSOptions:
|
|
86
86
|
streaming_latency: int
|
87
87
|
word_tokenizer: tokenize.WordTokenizer
|
88
88
|
chunk_length_schedule: list[int]
|
89
|
+
enable_ssml_parsing: bool
|
89
90
|
|
90
91
|
|
91
92
|
class TTS(tts.TTS):
|
@@ -101,9 +102,17 @@ class TTS(tts.TTS):
|
|
101
102
|
word_tokenizer: tokenize.WordTokenizer = tokenize.basic.WordTokenizer(
|
102
103
|
ignore_punctuation=False # punctuation can help for intonation
|
103
104
|
),
|
105
|
+
enable_ssml_parsing: bool = False,
|
104
106
|
chunk_length_schedule: list[int] = [80, 120, 200, 260], # range is [50, 500]
|
105
107
|
http_session: aiohttp.ClientSession | None = None,
|
106
108
|
) -> None:
|
109
|
+
"""
|
110
|
+
Create a new instance of ElevenLabs TTS.
|
111
|
+
|
112
|
+
``api_key`` must be set to your ElevenLabs API key, either using the argument or by setting
|
113
|
+
the ``ELEVEN_API_KEY`` environmental variable.
|
114
|
+
"""
|
115
|
+
|
107
116
|
super().__init__(
|
108
117
|
capabilities=tts.TTSCapabilities(
|
109
118
|
streaming=True,
|
@@ -125,6 +134,7 @@ class TTS(tts.TTS):
|
|
125
134
|
streaming_latency=streaming_latency,
|
126
135
|
word_tokenizer=word_tokenizer,
|
127
136
|
chunk_length_schedule=chunk_length_schedule,
|
137
|
+
enable_ssml_parsing=enable_ssml_parsing,
|
128
138
|
)
|
129
139
|
self._session = http_session
|
130
140
|
|
@@ -168,7 +178,7 @@ class ChunkedStream(tts.ChunkedStream):
|
|
168
178
|
segment_id = utils.shortuuid()
|
169
179
|
|
170
180
|
voice_settings = (
|
171
|
-
dataclasses.asdict(self._opts.voice.settings)
|
181
|
+
_strip_nones(dataclasses.asdict(self._opts.voice.settings))
|
172
182
|
if self._opts.voice.settings
|
173
183
|
else None
|
174
184
|
)
|
@@ -300,7 +310,7 @@ class SynthesizeStream(tts.SynthesizeStream):
|
|
300
310
|
init_pkt = dict(
|
301
311
|
text=" ",
|
302
312
|
try_trigger_generation=True,
|
303
|
-
voice_settings=dataclasses.asdict(self._opts.voice.settings)
|
313
|
+
voice_settings=_strip_nones(dataclasses.asdict(self._opts.voice.settings))
|
304
314
|
if self._opts.voice.settings
|
305
315
|
else None,
|
306
316
|
generation_config=dict(
|
@@ -353,7 +363,15 @@ class SynthesizeStream(tts.SynthesizeStream):
|
|
353
363
|
segment_id=segment_id,
|
354
364
|
)
|
355
365
|
|
356
|
-
|
366
|
+
tasks = [
|
367
|
+
asyncio.create_task(send_task()),
|
368
|
+
asyncio.create_task(recv_task()),
|
369
|
+
]
|
370
|
+
|
371
|
+
try:
|
372
|
+
await asyncio.gather(*tasks)
|
373
|
+
finally:
|
374
|
+
await utils.aio.gracefully_cancel(*tasks)
|
357
375
|
|
358
376
|
def _process_stream_event(
|
359
377
|
self, *, data: dict, request_id: str, segment_id: str
|
@@ -404,6 +422,10 @@ def _dict_to_voices_list(data: dict[str, Any]):
|
|
404
422
|
return voices
|
405
423
|
|
406
424
|
|
425
|
+
def _strip_nones(data: dict[str, Any]):
|
426
|
+
return {k: v for k, v in data.items() if v is not None}
|
427
|
+
|
428
|
+
|
407
429
|
def _synthesize_url(opts: _TTSOptions) -> str:
|
408
430
|
base_url = opts.base_url
|
409
431
|
voice_id = opts.voice.id
|
@@ -422,7 +444,9 @@ def _stream_url(opts: _TTSOptions) -> str:
|
|
422
444
|
model_id = opts.model_id
|
423
445
|
output_format = opts.encoding
|
424
446
|
latency = opts.streaming_latency
|
447
|
+
enable_ssml = str(opts.enable_ssml_parsing).lower()
|
425
448
|
return (
|
426
449
|
f"{base_url}/text-to-speech/{voice_id}/stream-input?"
|
427
|
-
f"model_id={model_id}&output_format={output_format}&optimize_streaming_latency={latency}"
|
450
|
+
f"model_id={model_id}&output_format={output_format}&optimize_streaming_latency={latency}&"
|
451
|
+
f"enable_ssml_parsing={enable_ssml}"
|
428
452
|
)
|
@@ -0,0 +1,10 @@
|
|
1
|
+
livekit/plugins/elevenlabs/__init__.py,sha256=cYRVIPXkRvB3-jK9bKZ9rYiMBACytWlCSq6yoZXaSgA,1080
|
2
|
+
livekit/plugins/elevenlabs/log.py,sha256=hIuXqDsEB5GBa7rQY3z4Uqi1oCqc_lRmCHZEmXz0LHw,73
|
3
|
+
livekit/plugins/elevenlabs/models.py,sha256=ddBUlDT4707f64WDJASR0B60X0yQ-LRHK1ZpTuBJXK8,387
|
4
|
+
livekit/plugins/elevenlabs/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
|
+
livekit/plugins/elevenlabs/tts.py,sha256=D0NXdOU94vFkYznWkx-tDRi8eBBSj-uMtv-E6s4abds,15099
|
6
|
+
livekit/plugins/elevenlabs/version.py,sha256=UblqPqnLJ1iqLGElaqb_uNunR14phGN2btPpCGRFrYk,600
|
7
|
+
livekit_plugins_elevenlabs-0.7.4.dist-info/METADATA,sha256=v69Po6l03UZl89vzcNhM3Wd2yezLTHjcN1q5I-sbfgg,1311
|
8
|
+
livekit_plugins_elevenlabs-0.7.4.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
|
9
|
+
livekit_plugins_elevenlabs-0.7.4.dist-info/top_level.txt,sha256=OoDok3xUmXbZRvOrfvvXB-Juu4DX79dlq188E19YHoo,8
|
10
|
+
livekit_plugins_elevenlabs-0.7.4.dist-info/RECORD,,
|
@@ -1,10 +0,0 @@
|
|
1
|
-
livekit/plugins/elevenlabs/__init__.py,sha256=cYRVIPXkRvB3-jK9bKZ9rYiMBACytWlCSq6yoZXaSgA,1080
|
2
|
-
livekit/plugins/elevenlabs/log.py,sha256=hIuXqDsEB5GBa7rQY3z4Uqi1oCqc_lRmCHZEmXz0LHw,73
|
3
|
-
livekit/plugins/elevenlabs/models.py,sha256=ddBUlDT4707f64WDJASR0B60X0yQ-LRHK1ZpTuBJXK8,387
|
4
|
-
livekit/plugins/elevenlabs/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
|
-
livekit/plugins/elevenlabs/tts.py,sha256=g5w__bq5OdtZDjjclw3zYq4mAPMpkVgWPqlhkb_qpBg,14320
|
6
|
-
livekit/plugins/elevenlabs/version.py,sha256=wNTnO8L3jrMdUjS-xAEFoMTKPaPYiFY9Kxnvzm4hTBc,600
|
7
|
-
livekit_plugins_elevenlabs-0.7.2.dist-info/METADATA,sha256=WdOaTQBGsLgrjKQIM2_pgXLyPUqzBfTml14OFRv2qLQ,1311
|
8
|
-
livekit_plugins_elevenlabs-0.7.2.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
|
9
|
-
livekit_plugins_elevenlabs-0.7.2.dist-info/top_level.txt,sha256=OoDok3xUmXbZRvOrfvvXB-Juu4DX79dlq188E19YHoo,8
|
10
|
-
livekit_plugins_elevenlabs-0.7.2.dist-info/RECORD,,
|
File without changes
|