Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for custom deepgram base url #1088

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/olive-kangaroos-yawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"livekit-plugins-deepgram": patch
---

Added support for custom deepgram base url
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ def __init__(
profanity_filter: bool = False,
api_key: str | None = None,
http_session: aiohttp.ClientSession | None = None,
base_url: str = BASE_URL,
base_url_ws: str = BASE_URL_WS,
) -> None:
"""
Create a new instance of Deepgram STT.
Expand Down Expand Up @@ -189,6 +191,8 @@ async def _recognize_impl(
"smart_format": config.smart_format,
"keywords": self._opts.keywords,
"profanity_filter": config.profanity_filter,
"base_url": self.base_url,
"base_url_ws": self.base_url_ws,
}
if config.language:
recognize_config["language"] = config.language
Expand Down Expand Up @@ -303,6 +307,8 @@ async def _run(self, max_retry: int) -> None:
"filler_words": self._opts.filler_words,
"keywords": self._opts.keywords,
"profanity_filter": self._opts.profanity_filter,
"base_url": self.base_url,
"base_url_ws": self.base_url_ws,
}

if self._opts.language:
Expand Down Expand Up @@ -549,5 +555,5 @@ 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()}
base_url = BASE_URL_WS if websocket else BASE_URL
base_url = opts.get("base_url_ws") if websocket else opts.get("base_url")
return f"{base_url}?{urlencode(opts, doseq=True)}"
Loading