livekit-plugins-google 0.7.2__py3-none-any.whl → 0.7.3__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/google/stt.py +27 -1
- livekit/plugins/google/version.py +1 -1
- {livekit_plugins_google-0.7.2.dist-info → livekit_plugins_google-0.7.3.dist-info}/METADATA +1 -1
- livekit_plugins_google-0.7.3.dist-info/RECORD +11 -0
- {livekit_plugins_google-0.7.2.dist-info → livekit_plugins_google-0.7.3.dist-info}/WHEEL +1 -1
- livekit_plugins_google-0.7.2.dist-info/RECORD +0 -11
- {livekit_plugins_google-0.7.2.dist-info → livekit_plugins_google-0.7.3.dist-info}/top_level.txt +0 -0
livekit/plugins/google/stt.py
CHANGED
@@ -28,7 +28,7 @@ from livekit.agents import (
|
|
28
28
|
utils,
|
29
29
|
)
|
30
30
|
|
31
|
-
from google.api_core.exceptions import DeadlineExceeded, GoogleAPICallError
|
31
|
+
from google.api_core.exceptions import Aborted, DeadlineExceeded, GoogleAPICallError
|
32
32
|
from google.auth import default as gauth_default
|
33
33
|
from google.auth.exceptions import DefaultCredentialsError
|
34
34
|
from google.cloud.speech_v2 import SpeechAsyncClient
|
@@ -50,6 +50,25 @@ class STTOptions:
|
|
50
50
|
punctuate: bool
|
51
51
|
spoken_punctuation: bool
|
52
52
|
model: SpeechModels
|
53
|
+
keywords: List[tuple[str, float]] | None
|
54
|
+
|
55
|
+
def build_adaptation(self) -> cloud_speech.SpeechAdaptation | None:
|
56
|
+
if self.keywords:
|
57
|
+
return cloud_speech.SpeechAdaptation(
|
58
|
+
phrase_sets=[
|
59
|
+
cloud_speech.SpeechAdaptation.AdaptationPhraseSet(
|
60
|
+
inline_phrase_set=cloud_speech.PhraseSet(
|
61
|
+
phrases=[
|
62
|
+
cloud_speech.PhraseSet.Phrase(
|
63
|
+
value=keyword, boost=boost
|
64
|
+
)
|
65
|
+
for keyword, boost in self.keywords
|
66
|
+
]
|
67
|
+
)
|
68
|
+
)
|
69
|
+
]
|
70
|
+
)
|
71
|
+
return None
|
53
72
|
|
54
73
|
|
55
74
|
class STT(stt.STT):
|
@@ -64,6 +83,7 @@ class STT(stt.STT):
|
|
64
83
|
model: SpeechModels = "long",
|
65
84
|
credentials_info: dict | None = None,
|
66
85
|
credentials_file: str | None = None,
|
86
|
+
keywords: List[tuple[str, float]] | None = None,
|
67
87
|
):
|
68
88
|
"""
|
69
89
|
Create a new instance of Google STT.
|
@@ -100,6 +120,7 @@ class STT(stt.STT):
|
|
100
120
|
punctuate=punctuate,
|
101
121
|
spoken_punctuation=spoken_punctuation,
|
102
122
|
model=model,
|
123
|
+
keywords=keywords,
|
103
124
|
)
|
104
125
|
|
105
126
|
def _ensure_client(self) -> SpeechAsyncClient:
|
@@ -163,6 +184,7 @@ class STT(stt.STT):
|
|
163
184
|
sample_rate_hertz=frame.sample_rate,
|
164
185
|
audio_channel_count=frame.num_channels,
|
165
186
|
),
|
187
|
+
adaptation=config.build_adaptation(),
|
166
188
|
features=cloud_speech.RecognitionFeatures(
|
167
189
|
enable_automatic_punctuation=config.punctuate,
|
168
190
|
enable_spoken_punctuation=config.spoken_punctuation,
|
@@ -228,6 +250,7 @@ class SpeechStream(stt.SpeechStream):
|
|
228
250
|
sample_rate_hertz=self._sample_rate,
|
229
251
|
audio_channel_count=self._num_channels,
|
230
252
|
),
|
253
|
+
adaptation=config.build_adaptation(),
|
231
254
|
language_codes=self._config.languages,
|
232
255
|
model=self._config.model,
|
233
256
|
features=cloud_speech.RecognitionFeatures(
|
@@ -280,6 +303,9 @@ class SpeechStream(stt.SpeechStream):
|
|
280
303
|
retry_count = 0 # connection successful, reset retry count
|
281
304
|
|
282
305
|
await self._run_stream(stream)
|
306
|
+
except Aborted:
|
307
|
+
logger.error("google stt connection aborted")
|
308
|
+
break
|
283
309
|
except Exception as e:
|
284
310
|
if retry_count >= max_retry:
|
285
311
|
logger.error(
|
@@ -0,0 +1,11 @@
|
|
1
|
+
livekit/plugins/google/__init__.py,sha256=rqV6C5mFNDFlrA2IcGJrsebr2VxQwMzoDUjY1JhMBZM,1117
|
2
|
+
livekit/plugins/google/log.py,sha256=GI3YWN5YzrafnUccljzPRS_ZALkMNk1i21IRnTl2vNA,69
|
3
|
+
livekit/plugins/google/models.py,sha256=n8pgTJ7xyJpPCZJ_y0GzaQq6LqYknL6K6trpi07-AxM,1307
|
4
|
+
livekit/plugins/google/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
|
+
livekit/plugins/google/stt.py,sha256=WjeqYsunW8jY-WHlnNeks7gR-TiojMRR7LYdAVdCxqY,15268
|
6
|
+
livekit/plugins/google/tts.py,sha256=hRN8ul1lDXU8LPVEfbTszgBiRYsifZXCPMwk-Pv2KeA,8793
|
7
|
+
livekit/plugins/google/version.py,sha256=yJeG0VwiekDJAk7GHcIAe43ebagJgloe-ZsqEGZnqzE,600
|
8
|
+
livekit_plugins_google-0.7.3.dist-info/METADATA,sha256=8UvORpoVunOTq0xKxHEk8M3sexKFnBnu66DkEJCnrRY,1647
|
9
|
+
livekit_plugins_google-0.7.3.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
|
10
|
+
livekit_plugins_google-0.7.3.dist-info/top_level.txt,sha256=OoDok3xUmXbZRvOrfvvXB-Juu4DX79dlq188E19YHoo,8
|
11
|
+
livekit_plugins_google-0.7.3.dist-info/RECORD,,
|
@@ -1,11 +0,0 @@
|
|
1
|
-
livekit/plugins/google/__init__.py,sha256=rqV6C5mFNDFlrA2IcGJrsebr2VxQwMzoDUjY1JhMBZM,1117
|
2
|
-
livekit/plugins/google/log.py,sha256=GI3YWN5YzrafnUccljzPRS_ZALkMNk1i21IRnTl2vNA,69
|
3
|
-
livekit/plugins/google/models.py,sha256=n8pgTJ7xyJpPCZJ_y0GzaQq6LqYknL6K6trpi07-AxM,1307
|
4
|
-
livekit/plugins/google/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
|
-
livekit/plugins/google/stt.py,sha256=XNU9G0DKc-joOMdhgfJJ2u6IZ3JJ33Wi-XmdqX426fg,14198
|
6
|
-
livekit/plugins/google/tts.py,sha256=hRN8ul1lDXU8LPVEfbTszgBiRYsifZXCPMwk-Pv2KeA,8793
|
7
|
-
livekit/plugins/google/version.py,sha256=wNTnO8L3jrMdUjS-xAEFoMTKPaPYiFY9Kxnvzm4hTBc,600
|
8
|
-
livekit_plugins_google-0.7.2.dist-info/METADATA,sha256=ohgXDVPUSOXfZ8AA7PQhC5RU5huOaZF9dq9GDDRO0-E,1647
|
9
|
-
livekit_plugins_google-0.7.2.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
|
10
|
-
livekit_plugins_google-0.7.2.dist-info/top_level.txt,sha256=OoDok3xUmXbZRvOrfvvXB-Juu4DX79dlq188E19YHoo,8
|
11
|
-
livekit_plugins_google-0.7.2.dist-info/RECORD,,
|
{livekit_plugins_google-0.7.2.dist-info → livekit_plugins_google-0.7.3.dist-info}/top_level.txt
RENAMED
File without changes
|