livekit-plugins-elevenlabs 0.7.6__py3-none-any.whl → 0.7.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/elevenlabs/tts.py +46 -11
- livekit/plugins/elevenlabs/version.py +1 -1
- {livekit_plugins_elevenlabs-0.7.6.dist-info → livekit_plugins_elevenlabs-0.7.9.dist-info}/METADATA +2 -2
- livekit_plugins_elevenlabs-0.7.9.dist-info/RECORD +10 -0
- {livekit_plugins_elevenlabs-0.7.6.dist-info → livekit_plugins_elevenlabs-0.7.9.dist-info}/WHEEL +1 -1
- livekit_plugins_elevenlabs-0.7.6.dist-info/RECORD +0 -10
- {livekit_plugins_elevenlabs-0.7.6.dist-info → livekit_plugins_elevenlabs-0.7.9.dist-info}/top_level.txt +0 -0
@@ -25,7 +25,9 @@ from typing import Any, List, Literal
|
|
25
25
|
import aiohttp
|
26
26
|
from livekit import rtc
|
27
27
|
from livekit.agents import (
|
28
|
+
DEFAULT_API_CONNECT_OPTIONS,
|
28
29
|
APIConnectionError,
|
30
|
+
APIConnectOptions,
|
29
31
|
APIStatusError,
|
30
32
|
APITimeoutError,
|
31
33
|
tokenize,
|
@@ -87,6 +89,7 @@ class _TTSOptions:
|
|
87
89
|
api_key: str
|
88
90
|
voice: Voice
|
89
91
|
model: TTSModels | str
|
92
|
+
language: str | None
|
90
93
|
base_url: str
|
91
94
|
encoding: TTSEncoding
|
92
95
|
sample_rate: int
|
@@ -114,6 +117,7 @@ class TTS(tts.TTS):
|
|
114
117
|
http_session: aiohttp.ClientSession | None = None,
|
115
118
|
# deprecated
|
116
119
|
model_id: TTSModels | str | None = None,
|
120
|
+
language: str | None = None,
|
117
121
|
) -> None:
|
118
122
|
"""
|
119
123
|
Create a new instance of ElevenLabs TTS.
|
@@ -129,6 +133,7 @@ class TTS(tts.TTS):
|
|
129
133
|
enable_ssml_parsing (bool): Enable SSML parsing for input text. Defaults to False.
|
130
134
|
chunk_length_schedule (list[int]): Schedule for chunk lengths, ranging from 50 to 500. Defaults to [80, 120, 200, 260].
|
131
135
|
http_session (aiohttp.ClientSession | None): Custom HTTP session for API requests. Optional.
|
136
|
+
language (str | None): Language code for the TTS model, as of 10/24/24 only valid for "eleven_turbo_v2_5". Optional.
|
132
137
|
"""
|
133
138
|
|
134
139
|
super().__init__(
|
@@ -162,6 +167,7 @@ class TTS(tts.TTS):
|
|
162
167
|
word_tokenizer=word_tokenizer,
|
163
168
|
chunk_length_schedule=chunk_length_schedule,
|
164
169
|
enable_ssml_parsing=enable_ssml_parsing,
|
170
|
+
language=language,
|
165
171
|
)
|
166
172
|
self._session = http_session
|
167
173
|
|
@@ -192,25 +198,49 @@ class TTS(tts.TTS):
|
|
192
198
|
self._opts.model = model or self._opts.model
|
193
199
|
self._opts.voice = voice or self._opts.voice
|
194
200
|
|
195
|
-
def synthesize(
|
196
|
-
|
201
|
+
def synthesize(
|
202
|
+
self,
|
203
|
+
text: str,
|
204
|
+
*,
|
205
|
+
conn_options: APIConnectOptions = DEFAULT_API_CONNECT_OPTIONS,
|
206
|
+
) -> "ChunkedStream":
|
207
|
+
return ChunkedStream(
|
208
|
+
tts=self,
|
209
|
+
input_text=text,
|
210
|
+
conn_options=conn_options,
|
211
|
+
opts=self._opts,
|
212
|
+
session=self._ensure_session(),
|
213
|
+
)
|
197
214
|
|
198
|
-
def stream(
|
199
|
-
|
215
|
+
def stream(
|
216
|
+
self, *, conn_options: APIConnectOptions = DEFAULT_API_CONNECT_OPTIONS
|
217
|
+
) -> "SynthesizeStream":
|
218
|
+
return SynthesizeStream(
|
219
|
+
tts=self,
|
220
|
+
conn_options=conn_options,
|
221
|
+
opts=self._opts,
|
222
|
+
session=self._ensure_session(),
|
223
|
+
)
|
200
224
|
|
201
225
|
|
202
226
|
class ChunkedStream(tts.ChunkedStream):
|
203
227
|
"""Synthesize using the chunked api endpoint"""
|
204
228
|
|
205
229
|
def __init__(
|
206
|
-
self,
|
230
|
+
self,
|
231
|
+
*,
|
232
|
+
tts: TTS,
|
233
|
+
input_text: str,
|
234
|
+
opts: _TTSOptions,
|
235
|
+
conn_options: APIConnectOptions,
|
236
|
+
session: aiohttp.ClientSession,
|
207
237
|
) -> None:
|
208
|
-
super().__init__(tts,
|
238
|
+
super().__init__(tts=tts, input_text=input_text, conn_options=conn_options)
|
209
239
|
self._opts, self._session = opts, session
|
210
240
|
if _encoding_from_format(self._opts.encoding) == "mp3":
|
211
241
|
self._mp3_decoder = utils.codecs.Mp3StreamDecoder()
|
212
242
|
|
213
|
-
async def
|
243
|
+
async def _run(self) -> None:
|
214
244
|
request_id = utils.shortuuid()
|
215
245
|
bstream = utils.audio.AudioByteStream(
|
216
246
|
sample_rate=self._opts.sample_rate, num_channels=1
|
@@ -282,16 +312,17 @@ class SynthesizeStream(tts.SynthesizeStream):
|
|
282
312
|
|
283
313
|
def __init__(
|
284
314
|
self,
|
315
|
+
*,
|
285
316
|
tts: TTS,
|
286
317
|
session: aiohttp.ClientSession,
|
318
|
+
conn_options: APIConnectOptions,
|
287
319
|
opts: _TTSOptions,
|
288
320
|
):
|
289
|
-
super().__init__(tts)
|
321
|
+
super().__init__(tts=tts, conn_options=conn_options)
|
290
322
|
self._opts, self._session = opts, session
|
291
323
|
self._mp3_decoder = utils.codecs.Mp3StreamDecoder()
|
292
324
|
|
293
|
-
|
294
|
-
async def _main_task(self) -> None:
|
325
|
+
async def _run(self) -> None:
|
295
326
|
self._segments_ch = utils.aio.Chan[tokenize.WordStream]()
|
296
327
|
|
297
328
|
@utils.log_exceptions(logger=logger)
|
@@ -523,8 +554,12 @@ def _stream_url(opts: _TTSOptions) -> str:
|
|
523
554
|
output_format = opts.encoding
|
524
555
|
latency = opts.streaming_latency
|
525
556
|
enable_ssml = str(opts.enable_ssml_parsing).lower()
|
526
|
-
|
557
|
+
language = opts.language
|
558
|
+
url = (
|
527
559
|
f"{base_url}/text-to-speech/{voice_id}/stream-input?"
|
528
560
|
f"model_id={model_id}&output_format={output_format}&optimize_streaming_latency={latency}&"
|
529
561
|
f"enable_ssml_parsing={enable_ssml}"
|
530
562
|
)
|
563
|
+
if language is not None:
|
564
|
+
url += f"&language_code={language}"
|
565
|
+
return url
|
{livekit_plugins_elevenlabs-0.7.6.dist-info → livekit_plugins_elevenlabs-0.7.9.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: livekit-plugins-elevenlabs
|
3
|
-
Version: 0.7.
|
3
|
+
Version: 0.7.9
|
4
4
|
Summary: Agent Framework plugin for voice synthesis with ElevenLabs' API.
|
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[codecs]
|
22
|
+
Requires-Dist: livekit-agents[codecs]>=0.11
|
23
23
|
|
24
24
|
# LiveKit Plugins Elevenlabs
|
25
25
|
|
@@ -0,0 +1,10 @@
|
|
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=ddBUlDT4707f64WDJASR0B60X0yQ-LRHK1ZpTuBJXK8,387
|
4
|
+
livekit/plugins/elevenlabs/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
|
+
livekit/plugins/elevenlabs/tts.py,sha256=ZiBgBjHpTXQmvZ2QWV-P2lqfG8kqRzaTZI7DHqrx-sk,19399
|
6
|
+
livekit/plugins/elevenlabs/version.py,sha256=Y-buDizIIkRMlhoxXYRvGcLWsb-FeH9R4TA8h7gN-vQ,600
|
7
|
+
livekit_plugins_elevenlabs-0.7.9.dist-info/METADATA,sha256=YnE6bivP8gz9ONqCzmD64hprpV26iuLJRBNVG005lB8,1304
|
8
|
+
livekit_plugins_elevenlabs-0.7.9.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
9
|
+
livekit_plugins_elevenlabs-0.7.9.dist-info/top_level.txt,sha256=OoDok3xUmXbZRvOrfvvXB-Juu4DX79dlq188E19YHoo,8
|
10
|
+
livekit_plugins_elevenlabs-0.7.9.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=ddBUlDT4707f64WDJASR0B60X0yQ-LRHK1ZpTuBJXK8,387
|
4
|
-
livekit/plugins/elevenlabs/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
|
-
livekit/plugins/elevenlabs/tts.py,sha256=mxdypC-zSbS1R15FmztT49ssk_arkKGUPe_d5uVqOUk,18422
|
6
|
-
livekit/plugins/elevenlabs/version.py,sha256=vOFNGWowZUhIrmyHBGtCx5dGhCp1T2FPt0h7KU_XKJg,600
|
7
|
-
livekit_plugins_elevenlabs-0.7.6.dist-info/METADATA,sha256=DY1JbHdgfNivv0p0xA5ZRenYUGEYC33yX4TcNh__srg,1305
|
8
|
-
livekit_plugins_elevenlabs-0.7.6.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
|
9
|
-
livekit_plugins_elevenlabs-0.7.6.dist-info/top_level.txt,sha256=OoDok3xUmXbZRvOrfvvXB-Juu4DX79dlq188E19YHoo,8
|
10
|
-
livekit_plugins_elevenlabs-0.7.6.dist-info/RECORD,,
|
File without changes
|