livekit-plugins-google 0.6.2__py3-none-any.whl → 0.6.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 +17 -9
- livekit/plugins/google/tts.py +6 -2
- livekit/plugins/google/version.py +1 -1
- {livekit_plugins_google-0.6.2.dist-info → livekit_plugins_google-0.6.3.dist-info}/METADATA +1 -1
- livekit_plugins_google-0.6.3.dist-info/RECORD +11 -0
- {livekit_plugins_google-0.6.2.dist-info → livekit_plugins_google-0.6.3.dist-info}/WHEEL +1 -1
- livekit_plugins_google-0.6.2.dist-info/RECORD +0 -11
- {livekit_plugins_google-0.6.2.dist-info → livekit_plugins_google-0.6.3.dist-info}/top_level.txt +0 -0
livekit/plugins/google/stt.py
CHANGED
@@ -58,8 +58,11 @@ class STT(stt.STT):
|
|
58
58
|
credentials_file: str | None = None,
|
59
59
|
):
|
60
60
|
"""
|
61
|
-
|
62
|
-
|
61
|
+
Create a new instance of Google STT.
|
62
|
+
|
63
|
+
Credentials must be provided, either by using the ``credentials_info`` dict, or reading
|
64
|
+
from the file specified in ``credentials_file`` or the ``GOOGLE_APPLICATION_CREDENTIALS``
|
65
|
+
environmental variable.
|
63
66
|
"""
|
64
67
|
super().__init__(
|
65
68
|
capabilities=stt.STTCapabilities(streaming=True, interim_results=True)
|
@@ -278,22 +281,22 @@ class SpeechStream(stt.SpeechStream):
|
|
278
281
|
== cloud_speech.StreamingRecognizeResponse.SpeechEventType.SPEECH_EVENT_TYPE_UNSPECIFIED
|
279
282
|
):
|
280
283
|
result = resp.results[0]
|
284
|
+
speech_data = _streaming_recognize_response_to_speech_data(resp)
|
285
|
+
if speech_data is None:
|
286
|
+
continue
|
287
|
+
|
281
288
|
if not result.is_final:
|
282
289
|
self._event_ch.send_nowait(
|
283
290
|
stt.SpeechEvent(
|
284
291
|
type=stt.SpeechEventType.INTERIM_TRANSCRIPT,
|
285
|
-
alternatives=[
|
286
|
-
_streaming_recognize_response_to_speech_data(resp)
|
287
|
-
],
|
292
|
+
alternatives=[speech_data],
|
288
293
|
)
|
289
294
|
)
|
290
295
|
else:
|
291
296
|
self._event_ch.send_nowait(
|
292
297
|
stt.SpeechEvent(
|
293
298
|
type=stt.SpeechEventType.FINAL_TRANSCRIPT,
|
294
|
-
alternatives=[
|
295
|
-
_streaming_recognize_response_to_speech_data(resp)
|
296
|
-
],
|
299
|
+
alternatives=[speech_data],
|
297
300
|
)
|
298
301
|
)
|
299
302
|
|
@@ -337,16 +340,21 @@ def _recognize_response_to_speech_event(
|
|
337
340
|
|
338
341
|
def _streaming_recognize_response_to_speech_data(
|
339
342
|
resp: cloud_speech.StreamingRecognizeResponse,
|
340
|
-
) -> stt.SpeechData:
|
343
|
+
) -> stt.SpeechData | None:
|
341
344
|
text = ""
|
342
345
|
confidence = 0.0
|
343
346
|
for result in resp.results:
|
347
|
+
if len(result.alternatives) == 0:
|
348
|
+
continue
|
344
349
|
text += result.alternatives[0].transcript
|
345
350
|
confidence += result.alternatives[0].confidence
|
346
351
|
|
347
352
|
confidence /= len(resp.results)
|
348
353
|
lg = resp.results[0].language_code
|
349
354
|
|
355
|
+
if text == "":
|
356
|
+
return None
|
357
|
+
|
350
358
|
data = stt.SpeechData(
|
351
359
|
language=lg, start_time=0, end_time=0, confidence=confidence, text=text
|
352
360
|
)
|
livekit/plugins/google/tts.py
CHANGED
@@ -51,9 +51,13 @@ class TTS(tts.TTS):
|
|
51
51
|
credentials_file: str | None = None,
|
52
52
|
) -> None:
|
53
53
|
"""
|
54
|
-
|
55
|
-
|
54
|
+
Create a new instance of Google TTS.
|
55
|
+
|
56
|
+
Credentials must be provided, either by using the ``credentials_info`` dict, or reading
|
57
|
+
from the file specified in ``credentials_file`` or the ``GOOGLE_APPLICATION_CREDENTIALS``
|
58
|
+
environmental variable.
|
56
59
|
"""
|
60
|
+
|
57
61
|
super().__init__(
|
58
62
|
capabilities=tts.TTSCapabilities(
|
59
63
|
streaming=False,
|
@@ -0,0 +1,11 @@
|
|
1
|
+
livekit/plugins/google/__init__.py,sha256=CYbSmm5fEw71F_r_4pEApGaWQ_r15Y3ZEocH88a4yc8,948
|
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=6yhDKrhVA4uANY9INtKG3p0FeMHPuHgi7Ny6swlwbHg,13129
|
6
|
+
livekit/plugins/google/tts.py,sha256=aHmFFViGTBuN8NVyt7h83t6J50hnCZO94SD9X71tAlI,5644
|
7
|
+
livekit/plugins/google/version.py,sha256=BHsM7CdYSULy_oyTN7Tl5mOCCZ-CmE_4ARJPeHOpqVM,600
|
8
|
+
livekit_plugins_google-0.6.3.dist-info/METADATA,sha256=kmLq8JvGH0F_Er1OQUzlSFt3hYuQPZib2MRr0DUnMnA,1584
|
9
|
+
livekit_plugins_google-0.6.3.dist-info/WHEEL,sha256=ixB2d4u7mugx_bCBycvM9OzZ5yD7NmPXFRtKlORZS2Y,91
|
10
|
+
livekit_plugins_google-0.6.3.dist-info/top_level.txt,sha256=OoDok3xUmXbZRvOrfvvXB-Juu4DX79dlq188E19YHoo,8
|
11
|
+
livekit_plugins_google-0.6.3.dist-info/RECORD,,
|
@@ -1,11 +0,0 @@
|
|
1
|
-
livekit/plugins/google/__init__.py,sha256=CYbSmm5fEw71F_r_4pEApGaWQ_r15Y3ZEocH88a4yc8,948
|
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=Jt3_uc6F9rBZootKyPYslgCgusQB_k7NQ1Cvj9CwppI,12970
|
6
|
-
livekit/plugins/google/tts.py,sha256=jvbw-T-JlVxcYWiF-tCox35LZuCN3DBKwDp3zN8JCTw,5549
|
7
|
-
livekit/plugins/google/version.py,sha256=hj5La4IQz5ccAWt5oJAkV9TnNFuujYmxSTjcRby-kNQ,600
|
8
|
-
livekit_plugins_google-0.6.2.dist-info/METADATA,sha256=fvHmaZHNW-dAFBr8-G5Mrm1sHs66AY6Ur8rXvD2Q-rg,1584
|
9
|
-
livekit_plugins_google-0.6.2.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
|
10
|
-
livekit_plugins_google-0.6.2.dist-info/top_level.txt,sha256=OoDok3xUmXbZRvOrfvvXB-Juu4DX79dlq188E19YHoo,8
|
11
|
-
livekit_plugins_google-0.6.2.dist-info/RECORD,,
|
{livekit_plugins_google-0.6.2.dist-info → livekit_plugins_google-0.6.3.dist-info}/top_level.txt
RENAMED
File without changes
|