livekit-plugins-elevenlabs 0.7.7__py3-none-any.whl → 0.7.10__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.
@@ -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,
@@ -187,34 +189,61 @@ class TTS(tts.TTS):
187
189
  *,
188
190
  voice: Voice = DEFAULT_VOICE,
189
191
  model: TTSModels | str = "eleven_turbo_v2_5",
192
+ language: str | None = None,
190
193
  ) -> None:
191
194
  """
192
195
  Args:
193
196
  voice (Voice): Voice configuration. Defaults to `DEFAULT_VOICE`.
194
197
  model (TTSModels | str): TTS model to use. Defaults to "eleven_turbo_v2_5".
198
+ language (str | None): Language code for the TTS model. Optional.
195
199
  """
196
200
  self._opts.model = model or self._opts.model
197
201
  self._opts.voice = voice or self._opts.voice
202
+ self._opts.language = language or self._opts.language
198
203
 
199
- def synthesize(self, text: str) -> "ChunkedStream":
200
- return ChunkedStream(self, text, self._opts, self._ensure_session())
204
+ def synthesize(
205
+ self,
206
+ text: str,
207
+ *,
208
+ conn_options: APIConnectOptions = DEFAULT_API_CONNECT_OPTIONS,
209
+ ) -> "ChunkedStream":
210
+ return ChunkedStream(
211
+ tts=self,
212
+ input_text=text,
213
+ conn_options=conn_options,
214
+ opts=self._opts,
215
+ session=self._ensure_session(),
216
+ )
201
217
 
202
- def stream(self) -> "SynthesizeStream":
203
- return SynthesizeStream(self, self._ensure_session(), self._opts)
218
+ def stream(
219
+ self, *, conn_options: APIConnectOptions = DEFAULT_API_CONNECT_OPTIONS
220
+ ) -> "SynthesizeStream":
221
+ return SynthesizeStream(
222
+ tts=self,
223
+ conn_options=conn_options,
224
+ opts=self._opts,
225
+ session=self._ensure_session(),
226
+ )
204
227
 
205
228
 
206
229
  class ChunkedStream(tts.ChunkedStream):
207
230
  """Synthesize using the chunked api endpoint"""
208
231
 
209
232
  def __init__(
210
- self, tts: TTS, text: str, opts: _TTSOptions, session: aiohttp.ClientSession
233
+ self,
234
+ *,
235
+ tts: TTS,
236
+ input_text: str,
237
+ opts: _TTSOptions,
238
+ conn_options: APIConnectOptions,
239
+ session: aiohttp.ClientSession,
211
240
  ) -> None:
212
- super().__init__(tts, text)
241
+ super().__init__(tts=tts, input_text=input_text, conn_options=conn_options)
213
242
  self._opts, self._session = opts, session
214
243
  if _encoding_from_format(self._opts.encoding) == "mp3":
215
244
  self._mp3_decoder = utils.codecs.Mp3StreamDecoder()
216
245
 
217
- async def _main_task(self) -> None:
246
+ async def _run(self) -> None:
218
247
  request_id = utils.shortuuid()
219
248
  bstream = utils.audio.AudioByteStream(
220
249
  sample_rate=self._opts.sample_rate, num_channels=1
@@ -286,16 +315,17 @@ class SynthesizeStream(tts.SynthesizeStream):
286
315
 
287
316
  def __init__(
288
317
  self,
318
+ *,
289
319
  tts: TTS,
290
320
  session: aiohttp.ClientSession,
321
+ conn_options: APIConnectOptions,
291
322
  opts: _TTSOptions,
292
323
  ):
293
- super().__init__(tts)
324
+ super().__init__(tts=tts, conn_options=conn_options)
294
325
  self._opts, self._session = opts, session
295
326
  self._mp3_decoder = utils.codecs.Mp3StreamDecoder()
296
327
 
297
- @utils.log_exceptions(logger=logger)
298
- async def _main_task(self) -> None:
328
+ async def _run(self) -> None:
299
329
  self._segments_ch = utils.aio.Chan[tokenize.WordStream]()
300
330
 
301
331
  @utils.log_exceptions(logger=logger)
@@ -442,8 +472,9 @@ class SynthesizeStream(tts.SynthesizeStream):
442
472
  aiohttp.WSMsgType.CLOSING,
443
473
  ):
444
474
  if not eos_sent:
445
- raise Exception(
446
- "11labs connection closed unexpectedly, not all tokens have been consumed"
475
+ raise APIStatusError(
476
+ "11labs connection closed unexpectedly, not all tokens have been consumed",
477
+ request_id=request_id,
447
478
  )
448
479
  return
449
480
 
@@ -12,4 +12,4 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- __version__ = "0.7.7"
15
+ __version__ = "0.7.10"
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: livekit-plugins-elevenlabs
3
- Version: 0.7.7
3
+ Version: 0.7.10
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,17 @@ 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] >=0.11
22
+ Requires-Dist: livekit-agents[codecs]>=0.12.3
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
23
33
 
24
34
  # LiveKit Plugins Elevenlabs
25
35
 
@@ -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=--2jLJcuWu49VhnogsyCQa3rufA33i-J763HSnmWPeQ,19633
6
+ livekit/plugins/elevenlabs/version.py,sha256=evm-fOLpHjdPwMzoYxCaNWj71Gwec6OKZFHBuyqYa-I,601
7
+ livekit_plugins_elevenlabs-0.7.10.dist-info/METADATA,sha256=h6B9H1DdF0NXtQRm3jNxfeso8lJkrFwn0ZOyoC_8mVU,1522
8
+ livekit_plugins_elevenlabs-0.7.10.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
9
+ livekit_plugins_elevenlabs-0.7.10.dist-info/top_level.txt,sha256=OoDok3xUmXbZRvOrfvvXB-Juu4DX79dlq188E19YHoo,8
10
+ livekit_plugins_elevenlabs-0.7.10.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.3.0)
2
+ Generator: setuptools (75.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -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=GgpXXBumLW2r1vKGZ_k-k8rYCQJVahioPMr2aJeSWwk,18760
6
- livekit/plugins/elevenlabs/version.py,sha256=78n--2R9Gwuh35Oy92hkYHXCMK_Er2s6VCfDuPQa2Ic,600
7
- livekit_plugins_elevenlabs-0.7.7.dist-info/METADATA,sha256=nTXxc7ODYH7VljmXYPAeNUjMRTE20XB7fBl0micpQQ4,1305
8
- livekit_plugins_elevenlabs-0.7.7.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
9
- livekit_plugins_elevenlabs-0.7.7.dist-info/top_level.txt,sha256=OoDok3xUmXbZRvOrfvvXB-Juu4DX79dlq188E19YHoo,8
10
- livekit_plugins_elevenlabs-0.7.7.dist-info/RECORD,,