livekit-plugins-aws 1.0.0.dev5__py3-none-any.whl → 1.0.0rc1__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.
Potentially problematic release.
This version of livekit-plugins-aws might be problematic. Click here for more details.
- livekit/plugins/aws/llm.py +4 -4
- livekit/plugins/aws/stt.py +43 -39
- livekit/plugins/aws/tts.py +24 -20
- livekit/plugins/aws/utils.py +13 -7
- livekit/plugins/aws/version.py +1 -1
- {livekit_plugins_aws-1.0.0.dev5.dist-info → livekit_plugins_aws-1.0.0rc1.dist-info}/METADATA +2 -2
- livekit_plugins_aws-1.0.0rc1.dist-info/RECORD +12 -0
- livekit_plugins_aws-1.0.0.dev5.dist-info/RECORD +0 -12
- {livekit_plugins_aws-1.0.0.dev5.dist-info → livekit_plugins_aws-1.0.0rc1.dist-info}/WHEEL +0 -0
livekit/plugins/aws/llm.py
CHANGED
|
@@ -80,16 +80,16 @@ class LLM(llm.LLM):
|
|
|
80
80
|
top_p (float, optional): The nucleus sampling probability for response generation. Defaults to None.
|
|
81
81
|
tool_choice (ToolChoice or Literal["auto", "required", "none"], optional): Specifies whether to use tools during response generation. Defaults to "auto".
|
|
82
82
|
additional_request_fields (dict[str, Any], optional): Additional request fields to send to the AWS Bedrock Converse API. Defaults to None.
|
|
83
|
-
"""
|
|
83
|
+
""" # noqa: E501
|
|
84
84
|
super().__init__()
|
|
85
85
|
self._api_key, self._api_secret, self._region = get_aws_credentials(
|
|
86
86
|
api_key, api_secret, region
|
|
87
87
|
)
|
|
88
88
|
|
|
89
|
-
model = model
|
|
90
|
-
if not
|
|
89
|
+
model = model if is_given(model) else os.environ.get("BEDROCK_INFERENCE_PROFILE_ARN")
|
|
90
|
+
if not model:
|
|
91
91
|
raise ValueError(
|
|
92
|
-
"model or inference profile arn must be set using the argument or by setting the BEDROCK_INFERENCE_PROFILE_ARN environment variable."
|
|
92
|
+
"model or inference profile arn must be set using the argument or by setting the BEDROCK_INFERENCE_PROFILE_ARN environment variable." # noqa: E501
|
|
93
93
|
)
|
|
94
94
|
self._opts = _LLMOptions(
|
|
95
95
|
model=model,
|
livekit/plugins/aws/stt.py
CHANGED
|
@@ -20,6 +20,8 @@ from amazon_transcribe.model import Result, TranscriptEvent
|
|
|
20
20
|
|
|
21
21
|
from livekit import rtc
|
|
22
22
|
from livekit.agents import DEFAULT_API_CONNECT_OPTIONS, APIConnectOptions, stt, utils
|
|
23
|
+
from livekit.agents.types import NOT_GIVEN, NotGivenOr
|
|
24
|
+
from livekit.agents.utils import is_given
|
|
23
25
|
|
|
24
26
|
from .log import logger
|
|
25
27
|
from .utils import get_aws_credentials
|
|
@@ -31,16 +33,16 @@ class STTOptions:
|
|
|
31
33
|
sample_rate: int
|
|
32
34
|
language: str
|
|
33
35
|
encoding: str
|
|
34
|
-
vocabulary_name: str
|
|
35
|
-
session_id: str
|
|
36
|
-
vocab_filter_method: str
|
|
37
|
-
vocab_filter_name: str
|
|
38
|
-
show_speaker_label: bool
|
|
39
|
-
enable_channel_identification: bool
|
|
40
|
-
number_of_channels: int
|
|
41
|
-
enable_partial_results_stabilization: bool
|
|
42
|
-
partial_results_stability: str
|
|
43
|
-
language_model_name: str
|
|
36
|
+
vocabulary_name: NotGivenOr[str]
|
|
37
|
+
session_id: NotGivenOr[str]
|
|
38
|
+
vocab_filter_method: NotGivenOr[str]
|
|
39
|
+
vocab_filter_name: NotGivenOr[str]
|
|
40
|
+
show_speaker_label: NotGivenOr[bool]
|
|
41
|
+
enable_channel_identification: NotGivenOr[bool]
|
|
42
|
+
number_of_channels: NotGivenOr[int]
|
|
43
|
+
enable_partial_results_stabilization: NotGivenOr[bool]
|
|
44
|
+
partial_results_stability: NotGivenOr[str]
|
|
45
|
+
language_model_name: NotGivenOr[str]
|
|
44
46
|
|
|
45
47
|
|
|
46
48
|
class STT(stt.STT):
|
|
@@ -48,21 +50,21 @@ class STT(stt.STT):
|
|
|
48
50
|
self,
|
|
49
51
|
*,
|
|
50
52
|
speech_region: str = "us-east-1",
|
|
51
|
-
api_key: str
|
|
52
|
-
api_secret: str
|
|
53
|
+
api_key: NotGivenOr[str] = NOT_GIVEN,
|
|
54
|
+
api_secret: NotGivenOr[str] = NOT_GIVEN,
|
|
53
55
|
sample_rate: int = 48000,
|
|
54
56
|
language: str = "en-US",
|
|
55
57
|
encoding: str = "pcm",
|
|
56
|
-
vocabulary_name: str
|
|
57
|
-
session_id: str
|
|
58
|
-
vocab_filter_method: str
|
|
59
|
-
vocab_filter_name: str
|
|
60
|
-
show_speaker_label: bool
|
|
61
|
-
enable_channel_identification: bool
|
|
62
|
-
number_of_channels: int
|
|
63
|
-
enable_partial_results_stabilization: bool
|
|
64
|
-
partial_results_stability: str
|
|
65
|
-
language_model_name: str
|
|
58
|
+
vocabulary_name: NotGivenOr[str] = NOT_GIVEN,
|
|
59
|
+
session_id: NotGivenOr[str] = NOT_GIVEN,
|
|
60
|
+
vocab_filter_method: NotGivenOr[str] = NOT_GIVEN,
|
|
61
|
+
vocab_filter_name: NotGivenOr[str] = NOT_GIVEN,
|
|
62
|
+
show_speaker_label: NotGivenOr[bool] = NOT_GIVEN,
|
|
63
|
+
enable_channel_identification: NotGivenOr[bool] = NOT_GIVEN,
|
|
64
|
+
number_of_channels: NotGivenOr[int] = NOT_GIVEN,
|
|
65
|
+
enable_partial_results_stabilization: NotGivenOr[bool] = NOT_GIVEN,
|
|
66
|
+
partial_results_stability: NotGivenOr[str] = NOT_GIVEN,
|
|
67
|
+
language_model_name: NotGivenOr[str] = NOT_GIVEN,
|
|
66
68
|
):
|
|
67
69
|
super().__init__(capabilities=stt.STTCapabilities(streaming=True, interim_results=True))
|
|
68
70
|
|
|
@@ -90,7 +92,7 @@ class STT(stt.STT):
|
|
|
90
92
|
self,
|
|
91
93
|
buffer: utils.AudioBuffer,
|
|
92
94
|
*,
|
|
93
|
-
language: str
|
|
95
|
+
language: NotGivenOr[str] = NOT_GIVEN,
|
|
94
96
|
conn_options: APIConnectOptions,
|
|
95
97
|
) -> stt.SpeechEvent:
|
|
96
98
|
raise NotImplementedError("Amazon Transcribe does not support single frame recognition")
|
|
@@ -98,7 +100,7 @@ class STT(stt.STT):
|
|
|
98
100
|
def stream(
|
|
99
101
|
self,
|
|
100
102
|
*,
|
|
101
|
-
language: str
|
|
103
|
+
language: NotGivenOr[str] = NOT_GIVEN,
|
|
102
104
|
conn_options: APIConnectOptions = DEFAULT_API_CONNECT_OPTIONS,
|
|
103
105
|
) -> SpeechStream:
|
|
104
106
|
return SpeechStream(
|
|
@@ -120,21 +122,23 @@ class SpeechStream(stt.SpeechStream):
|
|
|
120
122
|
self._client = TranscribeStreamingClient(region=self._opts.speech_region)
|
|
121
123
|
|
|
122
124
|
async def _run(self) -> None:
|
|
123
|
-
|
|
124
|
-
language_code
|
|
125
|
-
media_sample_rate_hz
|
|
126
|
-
media_encoding
|
|
127
|
-
vocabulary_name
|
|
128
|
-
session_id
|
|
129
|
-
vocab_filter_method
|
|
130
|
-
vocab_filter_name
|
|
131
|
-
show_speaker_label
|
|
132
|
-
enable_channel_identification
|
|
133
|
-
number_of_channels
|
|
134
|
-
enable_partial_results_stabilization
|
|
135
|
-
partial_results_stability
|
|
136
|
-
language_model_name
|
|
137
|
-
|
|
125
|
+
live_config = {
|
|
126
|
+
"language_code": self._opts.language,
|
|
127
|
+
"media_sample_rate_hz": self._opts.sample_rate,
|
|
128
|
+
"media_encoding": self._opts.encoding,
|
|
129
|
+
"vocabulary_name": self._opts.vocabulary_name,
|
|
130
|
+
"session_id": self._opts.session_id,
|
|
131
|
+
"vocab_filter_method": self._opts.vocab_filter_method,
|
|
132
|
+
"vocab_filter_name": self._opts.vocab_filter_name,
|
|
133
|
+
"show_speaker_label": self._opts.show_speaker_label,
|
|
134
|
+
"enable_channel_identification": self._opts.enable_channel_identification,
|
|
135
|
+
"number_of_channels": self._opts.number_of_channels,
|
|
136
|
+
"enable_partial_results_stabilization": self._opts.enable_partial_results_stabilization,
|
|
137
|
+
"partial_results_stability": self._opts.partial_results_stability,
|
|
138
|
+
"language_model_name": self._opts.language_model_name,
|
|
139
|
+
}
|
|
140
|
+
filtered_config = {k: v for k, v in live_config.items() if is_given(v)}
|
|
141
|
+
stream = await self._client.start_stream_transcription(**filtered_config)
|
|
138
142
|
|
|
139
143
|
@utils.log_exceptions(logger=logger)
|
|
140
144
|
async def input_generator():
|
livekit/plugins/aws/tts.py
CHANGED
|
@@ -27,9 +27,15 @@ from livekit.agents import (
|
|
|
27
27
|
tts,
|
|
28
28
|
utils,
|
|
29
29
|
)
|
|
30
|
+
from livekit.agents.types import (
|
|
31
|
+
DEFAULT_API_CONNECT_OPTIONS,
|
|
32
|
+
NOT_GIVEN,
|
|
33
|
+
NotGivenOr,
|
|
34
|
+
)
|
|
35
|
+
from livekit.agents.utils import is_given
|
|
30
36
|
|
|
31
37
|
from .models import TTS_LANGUAGE, TTS_SPEECH_ENGINE
|
|
32
|
-
from .utils import get_aws_credentials
|
|
38
|
+
from .utils import _strip_nones, get_aws_credentials
|
|
33
39
|
|
|
34
40
|
TTS_NUM_CHANNELS: int = 1
|
|
35
41
|
DEFAULT_SPEECH_ENGINE: TTS_SPEECH_ENGINE = "generative"
|
|
@@ -41,24 +47,24 @@ DEFAULT_SAMPLE_RATE = 16000
|
|
|
41
47
|
@dataclass
|
|
42
48
|
class _TTSOptions:
|
|
43
49
|
# https://docs.aws.amazon.com/polly/latest/dg/API_SynthesizeSpeech.html
|
|
44
|
-
voice: str
|
|
45
|
-
speech_engine: TTS_SPEECH_ENGINE
|
|
50
|
+
voice: NotGivenOr[str]
|
|
51
|
+
speech_engine: NotGivenOr[TTS_SPEECH_ENGINE]
|
|
46
52
|
speech_region: str
|
|
47
53
|
sample_rate: int
|
|
48
|
-
language: TTS_LANGUAGE | str
|
|
54
|
+
language: NotGivenOr[TTS_LANGUAGE | str]
|
|
49
55
|
|
|
50
56
|
|
|
51
57
|
class TTS(tts.TTS):
|
|
52
58
|
def __init__(
|
|
53
59
|
self,
|
|
54
60
|
*,
|
|
55
|
-
voice: str
|
|
56
|
-
language: TTS_LANGUAGE | str
|
|
57
|
-
speech_engine: TTS_SPEECH_ENGINE =
|
|
61
|
+
voice: NotGivenOr[str] = NOT_GIVEN,
|
|
62
|
+
language: NotGivenOr[TTS_LANGUAGE | str] = NOT_GIVEN,
|
|
63
|
+
speech_engine: NotGivenOr[TTS_SPEECH_ENGINE] = NOT_GIVEN,
|
|
58
64
|
sample_rate: int = DEFAULT_SAMPLE_RATE,
|
|
59
|
-
speech_region: str = DEFAULT_SPEECH_REGION,
|
|
60
|
-
api_key: str
|
|
61
|
-
api_secret: str
|
|
65
|
+
speech_region: NotGivenOr[str] = DEFAULT_SPEECH_REGION,
|
|
66
|
+
api_key: NotGivenOr[str] = NOT_GIVEN,
|
|
67
|
+
api_secret: NotGivenOr[str] = NOT_GIVEN,
|
|
62
68
|
session: AioSession | None = None,
|
|
63
69
|
) -> None:
|
|
64
70
|
"""
|
|
@@ -77,7 +83,7 @@ class TTS(tts.TTS):
|
|
|
77
83
|
speech_region(str, optional): The region to use for the synthesis. Defaults to "us-east-1".
|
|
78
84
|
api_key(str, optional): AWS access key id.
|
|
79
85
|
api_secret(str, optional): AWS secret access key.
|
|
80
|
-
"""
|
|
86
|
+
""" # noqa: E501
|
|
81
87
|
super().__init__(
|
|
82
88
|
capabilities=tts.TTSCapabilities(
|
|
83
89
|
streaming=False,
|
|
@@ -111,7 +117,7 @@ class TTS(tts.TTS):
|
|
|
111
117
|
self,
|
|
112
118
|
text: str,
|
|
113
119
|
*,
|
|
114
|
-
conn_options: APIConnectOptions
|
|
120
|
+
conn_options: APIConnectOptions = DEFAULT_API_CONNECT_OPTIONS,
|
|
115
121
|
) -> ChunkedStream:
|
|
116
122
|
return ChunkedStream(
|
|
117
123
|
tts=self,
|
|
@@ -128,7 +134,7 @@ class ChunkedStream(tts.ChunkedStream):
|
|
|
128
134
|
*,
|
|
129
135
|
tts: TTS,
|
|
130
136
|
text: str,
|
|
131
|
-
conn_options: APIConnectOptions
|
|
137
|
+
conn_options: APIConnectOptions = DEFAULT_API_CONNECT_OPTIONS,
|
|
132
138
|
opts: _TTSOptions,
|
|
133
139
|
get_client: Callable[[], Any],
|
|
134
140
|
) -> None:
|
|
@@ -145,11 +151,13 @@ class ChunkedStream(tts.ChunkedStream):
|
|
|
145
151
|
params = {
|
|
146
152
|
"Text": self._input_text,
|
|
147
153
|
"OutputFormat": "mp3",
|
|
148
|
-
"Engine": self._opts.speech_engine
|
|
149
|
-
|
|
154
|
+
"Engine": self._opts.speech_engine
|
|
155
|
+
if is_given(self._opts.speech_engine)
|
|
156
|
+
else DEFAULT_SPEECH_ENGINE,
|
|
157
|
+
"VoiceId": self._opts.voice if is_given(self._opts.voice) else DEFAULT_VOICE,
|
|
150
158
|
"TextType": "text",
|
|
151
159
|
"SampleRate": str(self._opts.sample_rate),
|
|
152
|
-
"LanguageCode": self._opts.language,
|
|
160
|
+
"LanguageCode": self._opts.language if is_given(self._opts.language) else None,
|
|
153
161
|
}
|
|
154
162
|
response = await client.synthesize_speech(**_strip_nones(params))
|
|
155
163
|
if "AudioStream" in response:
|
|
@@ -195,7 +203,3 @@ class ChunkedStream(tts.ChunkedStream):
|
|
|
195
203
|
) from e
|
|
196
204
|
except Exception as e:
|
|
197
205
|
raise APIConnectionError() from e
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
def _strip_nones(d: dict[str, Any]) -> dict[str, Any]:
|
|
201
|
-
return {k: v for k, v in d.items() if v is not None}
|
livekit/plugins/aws/utils.py
CHANGED
|
@@ -8,25 +8,31 @@ import boto3
|
|
|
8
8
|
|
|
9
9
|
from livekit.agents import llm
|
|
10
10
|
from livekit.agents.llm import ChatContext, FunctionTool, ImageContent, utils
|
|
11
|
+
from livekit.agents.types import NotGivenOr
|
|
12
|
+
from livekit.agents.utils import is_given
|
|
11
13
|
|
|
12
14
|
__all__ = ["to_fnc_ctx", "to_chat_ctx", "get_aws_credentials"]
|
|
13
15
|
|
|
14
16
|
|
|
15
|
-
def get_aws_credentials(
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
def get_aws_credentials(
|
|
18
|
+
api_key: NotGivenOr[str],
|
|
19
|
+
api_secret: NotGivenOr[str],
|
|
20
|
+
region: NotGivenOr[str],
|
|
21
|
+
):
|
|
22
|
+
aws_region = region if is_given(region) else os.environ.get("AWS_DEFAULT_REGION")
|
|
23
|
+
if not aws_region:
|
|
18
24
|
raise ValueError(
|
|
19
|
-
"AWS_DEFAULT_REGION must be set via argument or the AWS_DEFAULT_REGION environment variable."
|
|
25
|
+
"AWS_DEFAULT_REGION must be set via argument or the AWS_DEFAULT_REGION environment variable." # noqa: E501
|
|
20
26
|
)
|
|
21
27
|
|
|
22
|
-
if api_key and api_secret:
|
|
28
|
+
if is_given(api_key) and is_given(api_secret):
|
|
23
29
|
session = boto3.Session(
|
|
24
30
|
aws_access_key_id=api_key,
|
|
25
31
|
aws_secret_access_key=api_secret,
|
|
26
|
-
region_name=
|
|
32
|
+
region_name=aws_region,
|
|
27
33
|
)
|
|
28
34
|
else:
|
|
29
|
-
session = boto3.Session(region_name=
|
|
35
|
+
session = boto3.Session(region_name=aws_region)
|
|
30
36
|
|
|
31
37
|
credentials = session.get_credentials()
|
|
32
38
|
if not credentials or not credentials.access_key or not credentials.secret_key:
|
livekit/plugins/aws/version.py
CHANGED
{livekit_plugins_aws-1.0.0.dev5.dist-info → livekit_plugins_aws-1.0.0rc1.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: livekit-plugins-aws
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.0rc1
|
|
4
4
|
Summary: LiveKit Agents Plugin for services from AWS
|
|
5
5
|
Project-URL: Documentation, https://docs.livekit.io
|
|
6
6
|
Project-URL: Website, https://livekit.io/
|
|
@@ -21,7 +21,7 @@ Requires-Python: >=3.9.0
|
|
|
21
21
|
Requires-Dist: aiobotocore==2.19.0
|
|
22
22
|
Requires-Dist: amazon-transcribe>=0.6.2
|
|
23
23
|
Requires-Dist: boto3==1.36.3
|
|
24
|
-
Requires-Dist: livekit-agents>=1.0.0.
|
|
24
|
+
Requires-Dist: livekit-agents>=1.0.0.rc1
|
|
25
25
|
Description-Content-Type: text/markdown
|
|
26
26
|
|
|
27
27
|
# LiveKit Plugins AWS
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
livekit/plugins/aws/__init__.py,sha256=Ea-hK7QdutnwdZvvs9K2fiR8RWJqz2JcONxXnV1kXF0,977
|
|
2
|
+
livekit/plugins/aws/llm.py,sha256=2wdIZhjume5ukSkNHe3L1QLhBN6MyrtNuxHefEUM104,11050
|
|
3
|
+
livekit/plugins/aws/log.py,sha256=jFief0Xhv0n_F6sp6UFu9VKxs2bXNVGAfYGmEYfR_2Q,66
|
|
4
|
+
livekit/plugins/aws/models.py,sha256=Nf8RFmDulW7h03dG2lERTog3mgDK0TbLvW0eGOncuEE,704
|
|
5
|
+
livekit/plugins/aws/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
livekit/plugins/aws/stt.py,sha256=j2vEsoixFcsyTbCNhW5EWea5CEv3K-DzL9wmweebf3o,8030
|
|
7
|
+
livekit/plugins/aws/tts.py,sha256=4EOI4VabvhjCcDyp_QoDhlXOdrMrKpnmNIDTeoJ8kcU,7601
|
|
8
|
+
livekit/plugins/aws/utils.py,sha256=AiLzvztT635oF_DW4LQiKAL5wq_2nwBL6zBnyvdKB90,4978
|
|
9
|
+
livekit/plugins/aws/version.py,sha256=pF0lh6G9GYL7Mj7EnfhjFifzlzdWx6u3RvB0Itch4UE,604
|
|
10
|
+
livekit_plugins_aws-1.0.0rc1.dist-info/METADATA,sha256=BK464NnvrztaIc7bJFOwxGRjhBZec7BMFIhbL6y-6B8,1485
|
|
11
|
+
livekit_plugins_aws-1.0.0rc1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
12
|
+
livekit_plugins_aws-1.0.0rc1.dist-info/RECORD,,
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
livekit/plugins/aws/__init__.py,sha256=Ea-hK7QdutnwdZvvs9K2fiR8RWJqz2JcONxXnV1kXF0,977
|
|
2
|
-
livekit/plugins/aws/llm.py,sha256=Mc910AREP7-FX1yEV1k_rViue_30Gy8qmp42VDAptSE,11011
|
|
3
|
-
livekit/plugins/aws/log.py,sha256=jFief0Xhv0n_F6sp6UFu9VKxs2bXNVGAfYGmEYfR_2Q,66
|
|
4
|
-
livekit/plugins/aws/models.py,sha256=Nf8RFmDulW7h03dG2lERTog3mgDK0TbLvW0eGOncuEE,704
|
|
5
|
-
livekit/plugins/aws/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
-
livekit/plugins/aws/stt.py,sha256=hRulbbMXtYqYPuqo359ARWE0fYDy1PzMdpT-h2m1UsY,7575
|
|
7
|
-
livekit/plugins/aws/tts.py,sha256=WA-KtEVF8dq4GZEbPWdY3azdHZRiHFyptesx7kh6Tio,7250
|
|
8
|
-
livekit/plugins/aws/utils.py,sha256=Q62NpoJs3bLerMBlhW22L9xiZHgmtxK3-js7KbL0bkQ,4790
|
|
9
|
-
livekit/plugins/aws/version.py,sha256=pXgCpV03nQI-5Kk-74NFyAdw1htj2cx6unwQHipEcfE,605
|
|
10
|
-
livekit_plugins_aws-1.0.0.dev5.dist-info/METADATA,sha256=P10ho20uMHMcEW2xywzbYwXvPqego-Yv3EvpWLXsSCs,1488
|
|
11
|
-
livekit_plugins_aws-1.0.0.dev5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
12
|
-
livekit_plugins_aws-1.0.0.dev5.dist-info/RECORD,,
|
|
File without changes
|