From 5833d69c63ea9ae4d4778faecda2c3035d5472b2 Mon Sep 17 00:00:00 2001 From: Vinoth Date: Thu, 31 Oct 2024 16:32:18 -0400 Subject: [PATCH 1/3] support for additional deepgram config --- .../livekit/plugins/deepgram/stt.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/livekit-plugins/livekit-plugins-deepgram/livekit/plugins/deepgram/stt.py b/livekit-plugins/livekit-plugins-deepgram/livekit/plugins/deepgram/stt.py index 1637b7e95..4f1b2860d 100644 --- a/livekit-plugins/livekit-plugins-deepgram/livekit/plugins/deepgram/stt.py +++ b/livekit-plugins/livekit-plugins-deepgram/livekit/plugins/deepgram/stt.py @@ -98,6 +98,7 @@ class STTOptions: num_channels: int keywords: list[Tuple[str, float]] profanity_filter: bool + additional_config: dict = dataclasses.field(default_factory=dict) class STT(stt.STT): @@ -118,6 +119,7 @@ def __init__( profanity_filter: bool = False, api_key: str | None = None, http_session: aiohttp.ClientSession | None = None, + additional_config: dict | None = None, ) -> None: """ Create a new instance of Deepgram STT. @@ -168,6 +170,7 @@ def __init__( num_channels=1, keywords=keywords, profanity_filter=profanity_filter, + additional_config=additional_config or {}, ) self._session = http_session @@ -243,6 +246,9 @@ def _sanitize_options(self, *, language: str | None = None) -> STTOptions: if config.detect_language: config.language = None + for key, value in self._opts.additional_config.items(): + setattr(config, key, value) + return config From 95aca4446dd0381ceaf1325837b6c2918118b736 Mon Sep 17 00:00:00 2001 From: Vinoth Date: Thu, 31 Oct 2024 17:34:45 -0400 Subject: [PATCH 2/3] Create quiet-spiders-behave.md support for additional deepgram configs --- .changeset/quiet-spiders-behave.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/quiet-spiders-behave.md diff --git a/.changeset/quiet-spiders-behave.md b/.changeset/quiet-spiders-behave.md new file mode 100644 index 000000000..01a977b88 --- /dev/null +++ b/.changeset/quiet-spiders-behave.md @@ -0,0 +1,5 @@ +--- +"livekit-plugins-deepgram": patch +--- + +support for additional deepgram config From 2288c3f8d936b580911187baf83e210a14db190c Mon Sep 17 00:00:00 2001 From: Vinoth Date: Thu, 31 Oct 2024 19:11:35 -0400 Subject: [PATCH 3/3] suuport for additional deepgram configs --- .../livekit-plugins-deepgram/livekit/plugins/deepgram/stt.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/livekit-plugins/livekit-plugins-deepgram/livekit/plugins/deepgram/stt.py b/livekit-plugins/livekit-plugins-deepgram/livekit/plugins/deepgram/stt.py index 4f1b2860d..351a2d00d 100644 --- a/livekit-plugins/livekit-plugins-deepgram/livekit/plugins/deepgram/stt.py +++ b/livekit-plugins/livekit-plugins-deepgram/livekit/plugins/deepgram/stt.py @@ -192,6 +192,7 @@ async def _recognize_impl( "smart_format": config.smart_format, "keywords": self._opts.keywords, "profanity_filter": config.profanity_filter, + **config.additional_config, } if config.language: recognize_config["language"] = config.language @@ -309,6 +310,7 @@ async def _run(self, max_retry: int) -> None: "filler_words": self._opts.filler_words, "keywords": self._opts.keywords, "profanity_filter": self._opts.profanity_filter, + **self._opts.additional_config, } if self._opts.language: @@ -555,5 +557,6 @@ def _to_deepgram_url(opts: dict, *, websocket: bool = False) -> str: # lowercase bools opts = {k: str(v).lower() if isinstance(v, bool) else v for k, v in opts.items()} + logger.info(f"Connecting to Deepgram with configs: {opts}") base_url = BASE_URL_WS if websocket else BASE_URL return f"{base_url}?{urlencode(opts, doseq=True)}"