livekit-plugins-aws 0.1.0__tar.gz → 0.1.1__tar.gz

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.

Potentially problematic release.


This version of livekit-plugins-aws might be problematic. Click here for more details.

Files changed (19) hide show
  1. {livekit_plugins_aws-0.1.0 → livekit_plugins_aws-0.1.1}/PKG-INFO +2 -2
  2. {livekit_plugins_aws-0.1.0 → livekit_plugins_aws-0.1.1}/livekit/plugins/aws/models.py +1 -1
  3. {livekit_plugins_aws-0.1.0 → livekit_plugins_aws-0.1.1}/livekit/plugins/aws/tts.py +32 -34
  4. {livekit_plugins_aws-0.1.0 → livekit_plugins_aws-0.1.1}/livekit/plugins/aws/version.py +1 -1
  5. {livekit_plugins_aws-0.1.0 → livekit_plugins_aws-0.1.1}/livekit_plugins_aws.egg-info/PKG-INFO +2 -2
  6. {livekit_plugins_aws-0.1.0 → livekit_plugins_aws-0.1.1}/livekit_plugins_aws.egg-info/requires.txt +1 -1
  7. {livekit_plugins_aws-0.1.0 → livekit_plugins_aws-0.1.1}/setup.py +1 -1
  8. {livekit_plugins_aws-0.1.0 → livekit_plugins_aws-0.1.1}/README.md +0 -0
  9. {livekit_plugins_aws-0.1.0 → livekit_plugins_aws-0.1.1}/livekit/plugins/aws/__init__.py +0 -0
  10. {livekit_plugins_aws-0.1.0 → livekit_plugins_aws-0.1.1}/livekit/plugins/aws/_utils.py +0 -0
  11. {livekit_plugins_aws-0.1.0 → livekit_plugins_aws-0.1.1}/livekit/plugins/aws/llm.py +0 -0
  12. {livekit_plugins_aws-0.1.0 → livekit_plugins_aws-0.1.1}/livekit/plugins/aws/log.py +0 -0
  13. {livekit_plugins_aws-0.1.0 → livekit_plugins_aws-0.1.1}/livekit/plugins/aws/py.typed +0 -0
  14. {livekit_plugins_aws-0.1.0 → livekit_plugins_aws-0.1.1}/livekit/plugins/aws/stt.py +0 -0
  15. {livekit_plugins_aws-0.1.0 → livekit_plugins_aws-0.1.1}/livekit_plugins_aws.egg-info/SOURCES.txt +0 -0
  16. {livekit_plugins_aws-0.1.0 → livekit_plugins_aws-0.1.1}/livekit_plugins_aws.egg-info/dependency_links.txt +0 -0
  17. {livekit_plugins_aws-0.1.0 → livekit_plugins_aws-0.1.1}/livekit_plugins_aws.egg-info/top_level.txt +0 -0
  18. {livekit_plugins_aws-0.1.0 → livekit_plugins_aws-0.1.1}/pyproject.toml +0 -0
  19. {livekit_plugins_aws-0.1.0 → livekit_plugins_aws-0.1.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: livekit-plugins-aws
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: LiveKit Agents Plugin for services from AWS
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>=0.12.0
22
+ Requires-Dist: livekit-agents[codecs]<1.0.0,>=0.12.16
23
23
  Requires-Dist: aiobotocore==2.19.0
24
24
  Requires-Dist: boto3==1.36.3
25
25
  Requires-Dist: amazon-transcribe>=0.6.2
@@ -45,4 +45,4 @@ TTS_LANGUAGE = Literal[
45
45
  "de-CH",
46
46
  ]
47
47
 
48
- TTS_OUTPUT_FORMAT = Literal["pcm", "mp3"]
48
+ TTS_OUTPUT_FORMAT = Literal["mp3"]
@@ -18,7 +18,6 @@ from typing import Any, Callable, Optional
18
18
 
19
19
  import aiohttp
20
20
  from aiobotocore.session import AioSession, get_session
21
- from livekit import rtc
22
21
  from livekit.agents import (
23
22
  APIConnectionError,
24
23
  APIConnectOptions,
@@ -29,10 +28,9 @@ from livekit.agents import (
29
28
  )
30
29
 
31
30
  from ._utils import _get_aws_credentials
32
- from .models import TTS_LANGUAGE, TTS_OUTPUT_FORMAT, TTS_SPEECH_ENGINE
31
+ from .models import TTS_LANGUAGE, TTS_SPEECH_ENGINE
33
32
 
34
33
  TTS_NUM_CHANNELS: int = 1
35
- DEFAULT_OUTPUT_FORMAT: TTS_OUTPUT_FORMAT = "pcm"
36
34
  DEFAULT_SPEECH_ENGINE: TTS_SPEECH_ENGINE = "generative"
37
35
  DEFAULT_SPEECH_REGION = "us-east-1"
38
36
  DEFAULT_VOICE = "Ruth"
@@ -43,7 +41,6 @@ DEFAULT_SAMPLE_RATE = 16000
43
41
  class _TTSOptions:
44
42
  # https://docs.aws.amazon.com/polly/latest/dg/API_SynthesizeSpeech.html
45
43
  voice: str | None
46
- output_format: TTS_OUTPUT_FORMAT
47
44
  speech_engine: TTS_SPEECH_ENGINE
48
45
  speech_region: str
49
46
  sample_rate: int
@@ -56,7 +53,6 @@ class TTS(tts.TTS):
56
53
  *,
57
54
  voice: str | None = DEFAULT_VOICE,
58
55
  language: TTS_LANGUAGE | str | None = None,
59
- output_format: TTS_OUTPUT_FORMAT = DEFAULT_OUTPUT_FORMAT,
60
56
  speech_engine: TTS_SPEECH_ENGINE = DEFAULT_SPEECH_ENGINE,
61
57
  sample_rate: int = DEFAULT_SAMPLE_RATE,
62
58
  speech_region: str = DEFAULT_SPEECH_REGION,
@@ -75,7 +71,6 @@ class TTS(tts.TTS):
75
71
  Args:
76
72
  Voice (TTSModels, optional): Voice ID to use for the synthesis. Defaults to "Ruth".
77
73
  language (TTS_LANGUAGE, optional): language code for the Synthesize Speech request. This is only necessary if using a bilingual voice, such as Aditi, which can be used for either Indian English (en-IN) or Hindi (hi-IN).
78
- output_format(TTS_OUTPUT_FORMAT, optional): The format in which the returned output will be encoded. Defaults to "pcm".
79
74
  sample_rate(int, optional): The audio frequency specified in Hz. Defaults to 16000.
80
75
  speech_engine(TTS_SPEECH_ENGINE, optional): The engine to use for the synthesis. Defaults to "generative".
81
76
  speech_region(str, optional): The region to use for the synthesis. Defaults to "us-east-1".
@@ -96,7 +91,6 @@ class TTS(tts.TTS):
96
91
 
97
92
  self._opts = _TTSOptions(
98
93
  voice=voice,
99
- output_format=output_format,
100
94
  speech_engine=speech_engine,
101
95
  speech_region=speech_region,
102
96
  language=language,
@@ -149,7 +143,7 @@ class ChunkedStream(tts.ChunkedStream):
149
143
  async with self._get_client() as client:
150
144
  params = {
151
145
  "Text": self._input_text,
152
- "OutputFormat": self._opts.output_format,
146
+ "OutputFormat": "mp3",
153
147
  "Engine": self._opts.speech_engine,
154
148
  "VoiceId": self._opts.voice,
155
149
  "TextType": "text",
@@ -158,32 +152,36 @@ class ChunkedStream(tts.ChunkedStream):
158
152
  }
159
153
  response = await client.synthesize_speech(**_strip_nones(params))
160
154
  if "AudioStream" in response:
161
- decoder = utils.codecs.Mp3StreamDecoder()
162
- async with response["AudioStream"] as resp:
163
- async for data, _ in resp.content.iter_chunks():
164
- if self._opts.output_format == "mp3":
165
- frames = decoder.decode_chunk(data)
166
- for frame in frames:
167
- self._event_ch.send_nowait(
168
- tts.SynthesizedAudio(
169
- request_id=request_id,
170
- segment_id=self._segment_id,
171
- frame=frame,
172
- )
173
- )
174
- else:
175
- self._event_ch.send_nowait(
176
- tts.SynthesizedAudio(
177
- request_id=request_id,
178
- segment_id=self._segment_id,
179
- frame=rtc.AudioFrame(
180
- data=data,
181
- sample_rate=self._opts.sample_rate,
182
- num_channels=1,
183
- samples_per_channel=len(data) // 2,
184
- ),
185
- )
186
- )
155
+ decoder = utils.codecs.AudioStreamDecoder(
156
+ sample_rate=self._opts.sample_rate,
157
+ num_channels=1,
158
+ )
159
+
160
+ # Create a task to push data to the decoder
161
+ async def push_data():
162
+ try:
163
+ async with response["AudioStream"] as resp:
164
+ async for data, _ in resp.content.iter_chunks():
165
+ decoder.push(data)
166
+ finally:
167
+ decoder.end_input()
168
+
169
+ # Start pushing data to the decoder
170
+ push_task = asyncio.create_task(push_data())
171
+
172
+ try:
173
+ # Create emitter and process decoded frames
174
+ emitter = tts.SynthesizedAudioEmitter(
175
+ event_ch=self._event_ch,
176
+ request_id=request_id,
177
+ segment_id=self._segment_id,
178
+ )
179
+ async for frame in decoder:
180
+ emitter.push(frame)
181
+ emitter.flush()
182
+ await push_task
183
+ finally:
184
+ await utils.aio.gracefully_cancel(push_task)
187
185
 
188
186
  except asyncio.TimeoutError as e:
189
187
  raise APITimeoutError() from e
@@ -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.1.0"
15
+ __version__ = "0.1.1"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: livekit-plugins-aws
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: LiveKit Agents Plugin for services from AWS
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>=0.12.0
22
+ Requires-Dist: livekit-agents[codecs]<1.0.0,>=0.12.16
23
23
  Requires-Dist: aiobotocore==2.19.0
24
24
  Requires-Dist: boto3==1.36.3
25
25
  Requires-Dist: amazon-transcribe>=0.6.2
@@ -1,4 +1,4 @@
1
- livekit-agents>=0.12.0
1
+ livekit-agents[codecs]<1.0.0,>=0.12.16
2
2
  aiobotocore==2.19.0
3
3
  boto3==1.36.3
4
4
  amazon-transcribe>=0.6.2
@@ -48,7 +48,7 @@ setuptools.setup(
48
48
  packages=setuptools.find_namespace_packages(include=["livekit.*"]),
49
49
  python_requires=">=3.9.0",
50
50
  install_requires=[
51
- "livekit-agents>=0.12.0",
51
+ "livekit-agents[codecs]>=0.12.16,<1.0.0",
52
52
  "aiobotocore==2.19.0",
53
53
  "boto3==1.36.3",
54
54
  "amazon-transcribe>=0.6.2",