Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class STTOptions:
sample_rate: int
min_confidence_threshold: float
keywords: NotGivenOr[list[tuple[str, float]]] = NOT_GIVEN
denoiser_config: NotGivenOr[cloud_speech.DenoiserConfig] = NOT_GIVEN

def build_adaptation(self) -> cloud_speech.SpeechAdaptation | None:
if is_given(self.keywords):
Expand Down Expand Up @@ -113,6 +114,7 @@ def __init__(
credentials_file: NotGivenOr[str] = NOT_GIVEN,
keywords: NotGivenOr[list[tuple[str, float]]] = NOT_GIVEN,
use_streaming: NotGivenOr[bool] = NOT_GIVEN,
denoiser_config: NotGivenOr[cloud_speech.DenoiserConfig] = NOT_GIVEN,
):
"""
Create a new instance of Google STT.
Expand All @@ -139,6 +141,7 @@ def __init__(
credentials_file(str): the credentials file to use for recognition (default: None)
keywords(List[tuple[str, float]]): list of keywords to recognize (default: None)
use_streaming(bool): whether to use streaming for recognition (default: True)
denoiser_config(DenoiserConfig): configuration for audio denoising (default: None)
"""
if not is_given(use_streaming):
use_streaming = True
Expand Down Expand Up @@ -176,6 +179,7 @@ def __init__(
sample_rate=sample_rate,
min_confidence_threshold=min_confidence_threshold,
keywords=keywords,
denoiser_config=denoiser_config,
)
self._streams = weakref.WeakSet[SpeechStream]()
self._pool = utils.ConnectionPool[SpeechAsyncClient](
Expand Down Expand Up @@ -265,6 +269,7 @@ async def _recognize_impl(
),
model=config.model,
language_codes=config.languages,
denoiser_config=config.denoiser_config,
)

try:
Expand Down Expand Up @@ -516,6 +521,7 @@ async def process_stream(
enable_word_time_offsets=self._config.enable_word_time_offsets,
enable_spoken_punctuation=self._config.spoken_punctuation,
),
denoiser_config=self._config.denoiser_config,
),
streaming_features=cloud_speech.StreamingRecognitionFeatures(
interim_results=self._config.interim_results,
Expand Down
Loading