livekit-plugins-soniox 1.2.15__tar.gz → 1.2.17__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-soniox might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: livekit-plugins-soniox
3
- Version: 1.2.15
3
+ Version: 1.2.17
4
4
  Summary: Agent Framework plugin for services using Soniox's API.
5
5
  Project-URL: Documentation, https://docs.livekit.io
6
6
  Project-URL: Website, https://livekit.io/
@@ -17,7 +17,7 @@ Classifier: Programming Language :: Python :: 3.10
17
17
  Classifier: Topic :: Multimedia :: Sound/Audio
18
18
  Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
19
  Requires-Python: >=3.9.0
20
- Requires-Dist: livekit-agents>=1.2.15
20
+ Requires-Dist: livekit-agents>=1.2.17
21
21
  Description-Content-Type: text/markdown
22
22
 
23
23
  # Soniox plugin for LiveKit Agents
@@ -17,10 +17,17 @@
17
17
  See https://docs.livekit.io/agents/integrations/stt/soniox/ for more information.
18
18
  """
19
19
 
20
- from .stt import STT, STTOptions
20
+ from .stt import STT, ContextGeneralItem, ContextObject, ContextTranslationTerm, STTOptions
21
21
  from .version import __version__
22
22
 
23
- __all__ = ["STT", "STTOptions", "__version__"]
23
+ __all__ = [
24
+ "STT",
25
+ "STTOptions",
26
+ "ContextObject",
27
+ "ContextGeneralItem",
28
+ "ContextTranslationTerm",
29
+ "__version__",
30
+ ]
24
31
 
25
32
 
26
33
  from livekit.agents import Plugin
@@ -18,7 +18,7 @@ import asyncio
18
18
  import json
19
19
  import os
20
20
  import time
21
- from dataclasses import dataclass
21
+ from dataclasses import asdict, dataclass
22
22
 
23
23
  import aiohttp
24
24
 
@@ -56,22 +56,47 @@ def is_end_token(token: dict) -> bool:
56
56
  return token.get("text") in (END_TOKEN, FINALIZED_TOKEN)
57
57
 
58
58
 
59
+ @dataclass
60
+ class ContextGeneralItem:
61
+ key: str
62
+ value: str
63
+
64
+
65
+ @dataclass
66
+ class ContextTranslationTerm:
67
+ source: str
68
+ target: str
69
+
70
+
71
+ @dataclass
72
+ class ContextObject:
73
+ """Context object for models with context_version 2, for Soniox stt-rt-v3-preview and higher.
74
+
75
+ Learn more about context in the documentation:
76
+ https://soniox.com/docs/stt/concepts/context
77
+ """
78
+
79
+ general: list[ContextGeneralItem] | None = None
80
+ text: str | None = None
81
+ terms: list[str] | None = None
82
+ translation_terms: list[ContextTranslationTerm] | None = None
83
+
84
+
59
85
  @dataclass
60
86
  class STTOptions:
61
87
  """Configuration options for Soniox Speech-to-Text service."""
62
88
 
63
89
  model: str | None = "stt-rt-preview"
90
+
64
91
  language_hints: list[str] | None = None
65
- context: str | None = None
92
+ context: ContextObject | str | None = None
66
93
 
67
94
  num_channels: int = 1
68
95
  sample_rate: int = 16000
69
96
 
97
+ enable_speaker_diarization: bool = False
70
98
  enable_language_identification: bool = True
71
99
 
72
- enable_non_final_tokens: bool = True
73
- max_non_final_tokens_duration_ms: int | None = None
74
-
75
100
  client_reference_id: str | None = None
76
101
 
77
102
 
@@ -176,6 +201,10 @@ class SpeechStream(stt.SpeechStream):
176
201
  # If VAD was passed, disable endpoint detection, otherwise enable it.
177
202
  enable_endpoint_detection = not self._stt._vad_stream
178
203
 
204
+ context = self._stt._params.context
205
+ if isinstance(context, ContextObject):
206
+ context = asdict(context)
207
+
179
208
  # Create initial config object.
180
209
  config = {
181
210
  "api_key": self._stt._api_key,
@@ -185,9 +214,8 @@ class SpeechStream(stt.SpeechStream):
185
214
  "enable_endpoint_detection": enable_endpoint_detection,
186
215
  "sample_rate": self._stt._params.sample_rate,
187
216
  "language_hints": self._stt._params.language_hints,
188
- "context": self._stt._params.context,
189
- "enable_non_final_tokens": self._stt._params.enable_non_final_tokens,
190
- "max_non_final_tokens_duration_ms": self._stt._params.max_non_final_tokens_duration_ms,
217
+ "context": context,
218
+ "enable_speaker_diarization": self._stt._params.enable_speaker_diarization,
191
219
  "enable_language_identification": self._stt._params.enable_language_identification,
192
220
  "client_reference_id": self._stt._params.client_reference_id,
193
221
  }
@@ -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.2.15"
15
+ __version__ = "1.2.17"
@@ -28,7 +28,7 @@ classifiers = [
28
28
  "Programming Language :: Python :: 3.10",
29
29
  "Programming Language :: Python :: 3 :: Only",
30
30
  ]
31
- dependencies = ["livekit-agents>=1.2.15"]
31
+ dependencies = ["livekit-agents>=1.2.17"]
32
32
 
33
33
  [project.urls]
34
34
  Documentation = "https://docs.livekit.io"