Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class STTOptions:
keywords: list[tuple[str, float]]
keyterm: str | Sequence[str]
profanity_filter: bool
redact: str | list[str]
endpoint_url: str
vad_events: bool = True
numerals: bool = False
Expand Down Expand Up @@ -94,6 +95,7 @@ def __init__(
keyterm: NotGivenOr[str | list[str]] = NOT_GIVEN,
tags: NotGivenOr[list[str]] = NOT_GIVEN,
profanity_filter: bool = False,
redact: NotGivenOr[str | list[str]] = NOT_GIVEN,
api_key: NotGivenOr[str] = NOT_GIVEN,
http_session: aiohttp.ClientSession | None = None,
base_url: str = "https://api.deepgram.com/v1/listen",
Expand Down Expand Up @@ -123,6 +125,9 @@ def __init__(
`keyterm` is only supported by Nova-3 models.
tags: List of tags to add to the requests for usage reporting. Defaults to NOT_GIVEN.
profanity_filter: Whether to filter profanity from the transcription. Defaults to False.
redact: Redact sensitive information from the transcription. Accepts a single value or
list of values. Supported values: "pci", "numbers", "ssn", "true" (redact all).
See https://developers.deepgram.com/docs/redaction for details.
api_key: Your Deepgram API key. If not provided, will look for DEEPGRAM_API_KEY environment variable.
http_session: Optional aiohttp ClientSession to use for requests.
base_url: The base URL for Deepgram API. Defaults to "https://api.deepgram.com/v1/listen".
Expand Down Expand Up @@ -180,6 +185,7 @@ def __init__(
keywords=keywords if is_given(keywords) else [],
keyterm=keyterm if is_given(keyterm) else [],
profanity_filter=profanity_filter,
redact=redact if is_given(redact) else [],
numerals=numerals,
mip_opt_out=mip_opt_out,
vad_events=vad_events,
Expand Down Expand Up @@ -222,6 +228,8 @@ async def _recognize_impl(
"numerals": config.numerals,
"mip_opt_out": config.mip_opt_out,
}
if config.redact:
recognize_config["redact"] = config.redact
if config.enable_diarization:
logger.warning("speaker diarization is not supported in non-streaming mode, ignoring")

Expand Down Expand Up @@ -293,6 +301,7 @@ def update_options(
keywords: NotGivenOr[list[tuple[str, float]]] = NOT_GIVEN,
keyterm: NotGivenOr[str | list[str]] = NOT_GIVEN,
profanity_filter: NotGivenOr[bool] = NOT_GIVEN,
redact: NotGivenOr[str | list[str]] = NOT_GIVEN,
numerals: NotGivenOr[bool] = NOT_GIVEN,
mip_opt_out: NotGivenOr[bool] = NOT_GIVEN,
vad_events: NotGivenOr[bool] = NOT_GIVEN,
Expand Down Expand Up @@ -332,6 +341,8 @@ def update_options(
self._opts.keyterm = keyterm
if is_given(profanity_filter):
self._opts.profanity_filter = profanity_filter
if is_given(redact):
self._opts.redact = redact
if is_given(numerals):
self._opts.numerals = numerals
if is_given(mip_opt_out):
Expand All @@ -357,6 +368,7 @@ def update_options(
keywords=keywords,
keyterm=keyterm,
profanity_filter=profanity_filter,
redact=redact,
numerals=numerals,
mip_opt_out=mip_opt_out,
vad_events=vad_events,
Expand Down Expand Up @@ -432,6 +444,7 @@ def update_options(
keywords: NotGivenOr[list[tuple[str, float]]] = NOT_GIVEN,
keyterm: NotGivenOr[str | list[str]] = NOT_GIVEN,
profanity_filter: NotGivenOr[bool] = NOT_GIVEN,
redact: NotGivenOr[str | list[str]] = NOT_GIVEN,
numerals: NotGivenOr[bool] = NOT_GIVEN,
mip_opt_out: NotGivenOr[bool] = NOT_GIVEN,
vad_events: NotGivenOr[bool] = NOT_GIVEN,
Expand Down Expand Up @@ -471,6 +484,8 @@ def update_options(
self._opts.keyterm = keyterm
if is_given(profanity_filter):
self._opts.profanity_filter = profanity_filter
if is_given(redact):
self._opts.redact = redact
if is_given(numerals):
self._opts.numerals = numerals
if is_given(mip_opt_out):
Expand Down Expand Up @@ -640,6 +655,8 @@ async def _connect_ws(self) -> aiohttp.ClientWebSocketResponse:
if self._opts.language:
live_config["language"] = self._opts.language

if self._opts.redact:
live_config["redact"] = self._opts.redact
if self._opts.tags:
live_config["tag"] = self._opts.tags

Expand Down
Loading