livekit-plugins-elevenlabs 1.0.0rc9__py3-none-any.whl → 1.0.2__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.
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
 
15
15
  from .models import TTSEncoding, TTSModels
16
- from .tts import DEFAULT_VOICE, TTS, Voice, VoiceSettings
16
+ from .tts import DEFAULT_VOICE_ID, TTS, Voice, VoiceSettings
17
17
  from .version import __version__
18
18
 
19
19
  __all__ = [
@@ -22,7 +22,7 @@ __all__ = [
22
22
  "VoiceSettings",
23
23
  "TTSEncoding",
24
24
  "TTSModels",
25
- "DEFAULT_VOICE",
25
+ "DEFAULT_VOICE_ID",
26
26
  "__version__",
27
27
  ]
28
28
 
@@ -68,22 +68,9 @@ class Voice:
68
68
  id: str
69
69
  name: str
70
70
  category: str
71
- settings: NotGivenOr[VoiceSettings] = NOT_GIVEN
72
-
73
-
74
- DEFAULT_VOICE = Voice(
75
- id="EXAVITQu4vr4xnSDxMaL",
76
- name="Bella",
77
- category="premade",
78
- settings=VoiceSettings(
79
- stability=0.71,
80
- speed=1.0,
81
- similarity_boost=0.5,
82
- style=0.0,
83
- use_speaker_boost=True,
84
- ),
85
- )
86
71
 
72
+
73
+ DEFAULT_VOICE_ID = "EXAVITQu4vr4xnSDxMaL"
87
74
  API_BASE_URL_V1 = "https://api.elevenlabs.io/v1"
88
75
  AUTHORIZATION_HEADER = "xi-api-key"
89
76
  WS_INACTIVITY_TIMEOUT = 300
@@ -92,7 +79,8 @@ WS_INACTIVITY_TIMEOUT = 300
92
79
  @dataclass
93
80
  class _TTSOptions:
94
81
  api_key: str
95
- voice: Voice
82
+ voice_id: str
83
+ voice_settings: NotGivenOr[VoiceSettings]
96
84
  model: TTSModels | str
97
85
  language: NotGivenOr[str]
98
86
  base_url: str
@@ -109,7 +97,8 @@ class TTS(tts.TTS):
109
97
  def __init__(
110
98
  self,
111
99
  *,
112
- voice: Voice = DEFAULT_VOICE,
100
+ voice_id: str = DEFAULT_VOICE_ID,
101
+ voice_settings: NotGivenOr[VoiceSettings] = NOT_GIVEN,
113
102
  model: TTSModels | str = "eleven_flash_v2_5",
114
103
  encoding: NotGivenOr[TTSEncoding] = NOT_GIVEN,
115
104
  api_key: NotGivenOr[str] = NOT_GIVEN,
@@ -126,15 +115,16 @@ class TTS(tts.TTS):
126
115
  Create a new instance of ElevenLabs TTS.
127
116
 
128
117
  Args:
129
- voice (Voice): Voice configuration. Defaults to `DEFAULT_VOICE`.
118
+ voice_id (str): Voice ID. Defaults to `DEFAULT_VOICE_ID`.
119
+ voice_settings (NotGivenOr[VoiceSettings]): Voice settings.
130
120
  model (TTSModels | str): TTS model to use. Defaults to "eleven_turbo_v2_5".
131
- api_key (str | None): ElevenLabs API key. Can be set via argument or `ELEVEN_API_KEY` environment variable.
132
- base_url (str | None): Custom base URL for the API. Optional.
133
- streaming_latency (int): Optimize for streaming latency, defaults to 0 - disabled. 4 for max latency optimizations. deprecated
121
+ api_key (NotGivenOr[str]): ElevenLabs API key. Can be set via argument or `ELEVEN_API_KEY` environment variable.
122
+ base_url (NotGivenOr[str]): Custom base URL for the API. Optional.
123
+ streaming_latency (NotGivenOr[int]): Optimize for streaming latency, defaults to 0 - disabled. 4 for max latency optimizations. deprecated
134
124
  inactivity_timeout (int): Inactivity timeout in seconds for the websocket connection. Defaults to 300.
135
- word_tokenizer (tokenize.WordTokenizer): Tokenizer for processing text. Defaults to basic WordTokenizer.
125
+ word_tokenizer (NotGivenOr[tokenize.WordTokenizer]): Tokenizer for processing text. Defaults to basic WordTokenizer.
136
126
  enable_ssml_parsing (bool): Enable SSML parsing for input text. Defaults to False.
137
- chunk_length_schedule (list[int]): Schedule for chunk lengths, ranging from 50 to 500. Defaults to [80, 120, 200, 260].
127
+ chunk_length_schedule (NotGivenOr[list[int]]): Schedule for chunk lengths, ranging from 50 to 500. Defaults to [80, 120, 200, 260].
138
128
  http_session (aiohttp.ClientSession | None): Custom HTTP session for API requests. Optional.
139
129
  language (NotGivenOr[str]): Language code for the TTS model, as of 10/24/24 only valid for "eleven_turbo_v2_5".
140
130
  """ # noqa: E501
@@ -165,7 +155,8 @@ class TTS(tts.TTS):
165
155
  )
166
156
 
167
157
  self._opts = _TTSOptions(
168
- voice=voice,
158
+ voice_id=voice_id,
159
+ voice_settings=voice_settings,
169
160
  model=model,
170
161
  api_key=elevenlabs_api_key,
171
162
  base_url=base_url if is_given(base_url) else API_BASE_URL_V1,
@@ -197,20 +188,24 @@ class TTS(tts.TTS):
197
188
  def update_options(
198
189
  self,
199
190
  *,
200
- voice: NotGivenOr[Voice] = NOT_GIVEN,
191
+ voice_id: NotGivenOr[str] = NOT_GIVEN,
192
+ voice_settings: NotGivenOr[VoiceSettings] = NOT_GIVEN,
201
193
  model: NotGivenOr[TTSModels | str] = NOT_GIVEN,
202
194
  language: NotGivenOr[str] = NOT_GIVEN,
203
195
  ) -> None:
204
196
  """
205
197
  Args:
206
- voice (NotGivenOr[Voice]): Voice configuration.
198
+ voice_id (NotGivenOr[str]): Voice ID.
199
+ voice_settings (NotGivenOr[VoiceSettings]): Voice settings.
207
200
  model (NotGivenOr[TTSModels | str]): TTS model to use.
208
201
  language (NotGivenOr[str]): Language code for the TTS model.
209
202
  """
210
203
  if is_given(model):
211
204
  self._opts.model = model
212
- if is_given(voice):
213
- self._opts.voice = voice
205
+ if is_given(voice_id):
206
+ self._opts.voice_id = voice_id
207
+ if is_given(voice_settings):
208
+ self._opts.voice_settings = voice_settings
214
209
  if is_given(language):
215
210
  self._opts.language = language
216
211
 
@@ -265,8 +260,8 @@ class ChunkedStream(tts.ChunkedStream):
265
260
  async def _run(self) -> None:
266
261
  request_id = utils.shortuuid()
267
262
  voice_settings = (
268
- _strip_nones(dataclasses.asdict(self._opts.voice.settings))
269
- if is_given(self._opts.voice.settings)
263
+ _strip_nones(dataclasses.asdict(self._opts.voice_settings))
264
+ if is_given(self._opts.voice_settings)
270
265
  else None
271
266
  )
272
267
  data = {
@@ -405,8 +400,8 @@ class SynthesizeStream(tts.SynthesizeStream):
405
400
  # 11labs protocol expects the first message to be an "init msg"
406
401
  init_pkt = {
407
402
  "text": " ",
408
- "voice_settings": _strip_nones(dataclasses.asdict(self._opts.voice.settings))
409
- if is_given(self._opts.voice.settings)
403
+ "voice_settings": _strip_nones(dataclasses.asdict(self._opts.voice_settings))
404
+ if is_given(self._opts.voice_settings)
410
405
  else None,
411
406
  "generation_config": {"chunk_length_schedule": self._opts.chunk_length_schedule},
412
407
  }
@@ -536,7 +531,6 @@ def _dict_to_voices_list(data: dict[str, Any]):
536
531
  id=voice["voice_id"],
537
532
  name=voice["name"],
538
533
  category=voice["category"],
539
- settings=None,
540
534
  )
541
535
  )
542
536
  return voices
@@ -548,7 +542,7 @@ def _strip_nones(data: dict[str, Any]):
548
542
 
549
543
  def _synthesize_url(opts: _TTSOptions) -> str:
550
544
  base_url = opts.base_url
551
- voice_id = opts.voice.id
545
+ voice_id = opts.voice_id
552
546
  model_id = opts.model
553
547
  output_format = opts.encoding
554
548
  url = (
@@ -562,7 +556,7 @@ def _synthesize_url(opts: _TTSOptions) -> str:
562
556
 
563
557
  def _stream_url(opts: _TTSOptions) -> str:
564
558
  base_url = opts.base_url
565
- voice_id = opts.voice.id
559
+ voice_id = opts.voice_id
566
560
  model_id = opts.model
567
561
  output_format = opts.encoding
568
562
  enable_ssml = str(opts.enable_ssml_parsing).lower()
@@ -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__ = '1.0.0.rc9'
15
+ __version__ = '1.0.2'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: livekit-plugins-elevenlabs
3
- Version: 1.0.0rc9
3
+ Version: 1.0.2
4
4
  Summary: Agent Framework plugin for voice synthesis with ElevenLabs' API.
5
5
  Project-URL: Documentation, https://docs.livekit.io
6
6
  Project-URL: Website, https://livekit.io/
@@ -18,7 +18,7 @@ Classifier: Topic :: Multimedia :: Sound/Audio
18
18
  Classifier: Topic :: Multimedia :: Video
19
19
  Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
20
  Requires-Python: >=3.9.0
21
- Requires-Dist: livekit-agents[codecs]>=1.0.0.rc9
21
+ Requires-Dist: livekit-agents[codecs]>=1.0.2
22
22
  Description-Content-Type: text/markdown
23
23
 
24
24
  # LiveKit Plugins Elevenlabs
@@ -0,0 +1,9 @@
1
+ livekit/plugins/elevenlabs/__init__.py,sha256=Va24UYTuuosmRuTcuzd_DIHYQOgV-wSYKJIXmOSB2Go,1255
2
+ livekit/plugins/elevenlabs/log.py,sha256=hIuXqDsEB5GBa7rQY3z4Uqi1oCqc_lRmCHZEmXz0LHw,73
3
+ livekit/plugins/elevenlabs/models.py,sha256=p_wHEz15bdsNEqwzN831ysm70PNWQ-xeN__BKvGPZxA,401
4
+ livekit/plugins/elevenlabs/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ livekit/plugins/elevenlabs/tts.py,sha256=gs9p4TwBAYX3vlsNn2XQ-oyPNUGcuvgix8K7vChRMmc,19985
6
+ livekit/plugins/elevenlabs/version.py,sha256=VAosEGj0ByVVgOD0nuevp_anp63XZCFxkxz7t-41kg8,600
7
+ livekit_plugins_elevenlabs-1.0.2.dist-info/METADATA,sha256=xVEr_6v6LpXB4u7r9wGJGsmvU6Wb2tmWCFd3jVwoD9I,1312
8
+ livekit_plugins_elevenlabs-1.0.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
+ livekit_plugins_elevenlabs-1.0.2.dist-info/RECORD,,
@@ -1,9 +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=p_wHEz15bdsNEqwzN831ysm70PNWQ-xeN__BKvGPZxA,401
4
- livekit/plugins/elevenlabs/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- livekit/plugins/elevenlabs/tts.py,sha256=rrCtSEJT9MUk1wb-xJLcbmDmJNyXVOn8WN6eS8ATYRA,19783
6
- livekit/plugins/elevenlabs/version.py,sha256=5bk2f3atP67YoCoyxLdm3aJrB_QkLXroUSkhYmjhT1o,604
7
- livekit_plugins_elevenlabs-1.0.0rc9.dist-info/METADATA,sha256=Uoggnb_Y9ZPG3-H7s3IO-6PWMDrVbhzXpCHX4AXhl3Q,1319
8
- livekit_plugins_elevenlabs-1.0.0rc9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
- livekit_plugins_elevenlabs-1.0.0rc9.dist-info/RECORD,,