livekit-plugins-deepgram 1.0.0rc6__py3-none-any.whl → 1.0.0rc7__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.
@@ -112,6 +112,7 @@ class STTOptions:
112
112
  energy_filter: AudioEnergyFilter | bool = False
113
113
  numerals: bool = False
114
114
  mip_opt_out: bool = False
115
+ tags: NotGivenOr[list[str]] = NOT_GIVEN
115
116
 
116
117
 
117
118
  class STT(stt.STT):
@@ -131,6 +132,7 @@ class STT(stt.STT):
131
132
  filler_words: bool = True,
132
133
  keywords: NotGivenOr[list[tuple[str, float]]] = NOT_GIVEN,
133
134
  keyterms: NotGivenOr[list[str]] = NOT_GIVEN,
135
+ tags: NotGivenOr[list[str]] = NOT_GIVEN,
134
136
  profanity_filter: bool = False,
135
137
  api_key: NotGivenOr[str] = NOT_GIVEN,
136
138
  http_session: aiohttp.ClientSession | None = None,
@@ -157,6 +159,7 @@ class STT(stt.STT):
157
159
  `keywords` does not work with Nova-3 models. Use `keyterms` instead.
158
160
  keyterms: List of key terms to improve recognition accuracy. Defaults to None.
159
161
  `keyterms` is supported by Nova-3 models.
162
+ tags: List of tags to add to the requests for usage reporting. Defaults to NOT_GIVEN.
160
163
  profanity_filter: Whether to filter profanity from the transcription. Defaults to False.
161
164
  api_key: Your Deepgram API key. If not provided, will look for DEEPGRAM_API_KEY environment variable.
162
165
  http_session: Optional aiohttp ClientSession to use for requests.
@@ -184,6 +187,7 @@ class STT(stt.STT):
184
187
  raise ValueError("Deepgram API key is required")
185
188
 
186
189
  model = _validate_model(model, language)
190
+ _validate_keyterms(model, language, keyterms, keywords)
187
191
 
188
192
  self._opts = STTOptions(
189
193
  language=language,
@@ -203,6 +207,7 @@ class STT(stt.STT):
203
207
  energy_filter=energy_filter,
204
208
  numerals=numerals,
205
209
  mip_opt_out=mip_opt_out,
210
+ tags=_validate_tags(tags) if is_given(tags) else [],
206
211
  )
207
212
  self._session = http_session
208
213
  self._streams = weakref.WeakSet[SpeechStream]()
@@ -300,6 +305,7 @@ class STT(stt.STT):
300
305
  profanity_filter: NotGivenOr[bool] = NOT_GIVEN,
301
306
  numerals: NotGivenOr[bool] = NOT_GIVEN,
302
307
  mip_opt_out: NotGivenOr[bool] = NOT_GIVEN,
308
+ tags: NotGivenOr[list[str]] = NOT_GIVEN,
303
309
  ):
304
310
  if is_given(language):
305
311
  self._opts.language = language
@@ -329,6 +335,8 @@ class STT(stt.STT):
329
335
  self._opts.numerals = numerals
330
336
  if is_given(mip_opt_out):
331
337
  self._opts.mip_opt_out = mip_opt_out
338
+ if is_given(tags):
339
+ self._opts.tags = _validate_tags(tags)
332
340
 
333
341
  for stream in self._streams:
334
342
  stream.update_options(
@@ -421,6 +429,7 @@ class SpeechStream(stt.SpeechStream):
421
429
  profanity_filter: NotGivenOr[bool] = NOT_GIVEN,
422
430
  numerals: NotGivenOr[bool] = NOT_GIVEN,
423
431
  mip_opt_out: NotGivenOr[bool] = NOT_GIVEN,
432
+ tags: NotGivenOr[list[str]] = NOT_GIVEN,
424
433
  ):
425
434
  if is_given(language):
426
435
  self._opts.language = language
@@ -450,6 +459,8 @@ class SpeechStream(stt.SpeechStream):
450
459
  self._opts.numerals = numerals
451
460
  if is_given(mip_opt_out):
452
461
  self._opts.mip_opt_out = mip_opt_out
462
+ if is_given(tags):
463
+ self._opts.tags = _validate_tags(tags)
453
464
 
454
465
  self._reconnect_event.set()
455
466
 
@@ -602,6 +613,9 @@ class SpeechStream(stt.SpeechStream):
602
613
  if self._opts.language:
603
614
  live_config["language"] = self._opts.language
604
615
 
616
+ if self._opts.tags:
617
+ live_config["tag"] = self._opts.tags
618
+
605
619
  ws = await asyncio.wait_for(
606
620
  self._session.ws_connect(
607
621
  _to_deepgram_url(live_config, base_url=self._base_url, websocket=True),
@@ -749,7 +763,6 @@ def _to_deepgram_url(opts: dict, base_url: str, *, websocket: bool) -> str:
749
763
 
750
764
  elif not websocket and base_url.startswith("ws"):
751
765
  base_url = base_url.replace("ws", "http", 1)
752
-
753
766
  return f"{base_url}?{urlencode(opts, doseq=True)}"
754
767
 
755
768
 
@@ -776,3 +789,36 @@ def _validate_model(
776
789
  )
777
790
  return "nova-2-general"
778
791
  return model
792
+
793
+
794
+ def _validate_tags(tags: list[str]) -> list[str]:
795
+ for tag in tags:
796
+ if len(tag) > 128:
797
+ raise ValueError("tag must be no more than 128 characters")
798
+ return tags
799
+
800
+
801
+ def _validate_keyterms(
802
+ model: DeepgramModels | str,
803
+ language: NotGivenOr[DeepgramLanguages | str],
804
+ keyterms: NotGivenOr[list[str]],
805
+ keywords: NotGivenOr[list[tuple[str, float]]],
806
+ ) -> None:
807
+ """
808
+ Validating keyterms and keywords for model compatibility.
809
+ See: https://developers.deepgram.com/docs/keyterm and https://developers.deepgram.com/docs/keywords
810
+ """
811
+ if model.startswith("nova-3") and is_given(keywords):
812
+ raise ValueError(
813
+ "Keywords is only available for use with Nova-2, Nova-1, Enhanced, and "
814
+ "Base speech to text models. For Nova-3, use Keyterm Prompting."
815
+ )
816
+
817
+ if is_given(keyterms) and (
818
+ (model.startswith("nova-3") and language not in ("en-US", "en"))
819
+ or not model.startswith("nova-3")
820
+ ):
821
+ raise ValueError(
822
+ "Keyterm Prompting is only available for English transcription using the Nova-3 Model. "
823
+ "To boost recognition of keywords using another model, use the Keywords feature."
824
+ )
@@ -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.0.0.rc6'
15
+ __version__ = '1.0.0.rc7'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: livekit-plugins-deepgram
3
- Version: 1.0.0rc6
3
+ Version: 1.0.0rc7
4
4
  Summary: Agent Framework plugin for services using Deepgram's API.
5
5
  Project-URL: Documentation, https://docs.livekit.io
6
6
  Project-URL: Website, https://livekit.io/
@@ -18,7 +18,7 @@ Classifier: Topic :: Multimedia :: Sound/Audio
18
18
  Classifier: Topic :: Multimedia :: Video
19
19
  Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
20
  Requires-Python: >=3.9.0
21
- Requires-Dist: livekit-agents[codecs]>=1.0.0.rc6
21
+ Requires-Dist: livekit-agents[codecs]>=1.0.0.rc7
22
22
  Requires-Dist: numpy>=1.26
23
23
  Description-Content-Type: text/markdown
24
24
 
@@ -3,9 +3,9 @@ livekit/plugins/deepgram/_utils.py,sha256=0O3O77qURXjYYCenl5McE85fcBApaQvQl5zKQz
3
3
  livekit/plugins/deepgram/log.py,sha256=isjd2-ROJXiDFhRRnqRmYxv16U5H9dBV6ut2g5bU7q0,71
4
4
  livekit/plugins/deepgram/models.py,sha256=TdytPIBC5X6POp6QbfHqOIVee_7u6MQ1S7umlst6pNQ,1223
5
5
  livekit/plugins/deepgram/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- livekit/plugins/deepgram/stt.py,sha256=AnOfwX5cjD9-ox6r0uMmZa8Xp_S2tcIdN0UPbQM9On8,30625
6
+ livekit/plugins/deepgram/stt.py,sha256=-TCeE9QIWFYZc2G5tvBbeXdF9nRAm9cAjsxC_DkrX8U,32497
7
7
  livekit/plugins/deepgram/tts.py,sha256=mIkm-jrPpDrqX_Fm3yvfSymWvaXPkzG6SAAQRojJHzg,15505
8
- livekit/plugins/deepgram/version.py,sha256=PDOEKN5zsYLQdbfAm5Di6G1sFYANNA0LqJR8zZzeghg,604
9
- livekit_plugins_deepgram-1.0.0rc6.dist-info/METADATA,sha256=HVTRa7ue2dfzHo04rwgd9lle5DBQq31I13iTIa03Ii8,1355
10
- livekit_plugins_deepgram-1.0.0rc6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
11
- livekit_plugins_deepgram-1.0.0rc6.dist-info/RECORD,,
8
+ livekit/plugins/deepgram/version.py,sha256=tiVbeZ_X3blYKeNH4fEAAE8RYOJd-aJvw5PvPOojzYc,604
9
+ livekit_plugins_deepgram-1.0.0rc7.dist-info/METADATA,sha256=4-kf9H1z-iQ1ZcsFX32k4qKvlhTXwuLZOaR9bIFb8Sg,1355
10
+ livekit_plugins_deepgram-1.0.0rc7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
11
+ livekit_plugins_deepgram-1.0.0rc7.dist-info/RECORD,,