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 @@ -77,6 +77,7 @@ class STTOptions:
model: SpeechModels | str
sample_rate: int
min_confidence_threshold: float
profanity_filter: bool
keywords: NotGivenOr[list[tuple[str, float]]] = NOT_GIVEN

@property
Expand Down Expand Up @@ -128,6 +129,7 @@ def __init__(
enable_voice_activity_events: bool = False,
model: SpeechModels | str = "latest_long",
location: str = "global",
profanity_filter: bool = False,
sample_rate: int = 16000,
min_confidence_threshold: float = _default_min_confidence,
credentials_info: NotGivenOr[dict] = NOT_GIVEN,
Expand All @@ -153,6 +155,7 @@ def __init__(
enable_voice_activity_events(bool): whether to enable voice activity events (default: False)
model(SpeechModels): the model to use for recognition default: "latest_long"
location(str): the location to use for recognition default: "global"
profanity_filter(bool): whether to filter out profanities default: False
sample_rate(int): the sample rate of the audio default: 16000
min_confidence_threshold(float): minimum confidence threshold for recognition
(default: 0.65)
Expand Down Expand Up @@ -210,6 +213,7 @@ def __init__(
enable_word_confidence=enable_word_confidence,
enable_voice_activity_events=enable_voice_activity_events,
model=model,
profanity_filter=profanity_filter,
sample_rate=sample_rate,
min_confidence_threshold=min_confidence_threshold,
keywords=keywords,
Expand Down Expand Up @@ -298,6 +302,7 @@ def _build_recognition_config(
enable_spoken_punctuation=config.spoken_punctuation,
enable_word_time_offsets=config.enable_word_time_offsets,
enable_word_confidence=config.enable_word_confidence,
profanity_filter=config.profanity_filter,
),
model=config.model,
language_codes=config.languages,
Expand All @@ -313,6 +318,7 @@ def _build_recognition_config(
enable_word_confidence=config.enable_word_confidence,
enable_automatic_punctuation=config.punctuate,
enable_spoken_punctuation=config.spoken_punctuation,
profanity_filter=config.profanity_filter,
model=config.model,
)

Expand Down Expand Up @@ -388,6 +394,7 @@ def update_options(
interim_results: NotGivenOr[bool] = NOT_GIVEN,
punctuate: NotGivenOr[bool] = NOT_GIVEN,
spoken_punctuation: NotGivenOr[bool] = NOT_GIVEN,
profanity_filter: NotGivenOr[bool] = NOT_GIVEN,
model: NotGivenOr[SpeechModels] = NOT_GIVEN,
location: NotGivenOr[str] = NOT_GIVEN,
keywords: NotGivenOr[list[tuple[str, float]]] = NOT_GIVEN,
Expand All @@ -404,6 +411,8 @@ def update_options(
self._config.punctuate = punctuate
if is_given(spoken_punctuation):
self._config.spoken_punctuation = spoken_punctuation
if is_given(profanity_filter):
self._config.profanity_filter = profanity_filter
if is_given(model):
old_version = self._config.version
self._config.model = model
Expand All @@ -424,6 +433,7 @@ def update_options(
interim_results=interim_results,
punctuate=punctuate,
spoken_punctuation=spoken_punctuation,
profanity_filter=profanity_filter,
model=model,
keywords=keywords,
)
Expand Down Expand Up @@ -459,6 +469,7 @@ def update_options(
interim_results: NotGivenOr[bool] = NOT_GIVEN,
punctuate: NotGivenOr[bool] = NOT_GIVEN,
spoken_punctuation: NotGivenOr[bool] = NOT_GIVEN,
profanity_filter: NotGivenOr[bool] = NOT_GIVEN,
model: NotGivenOr[SpeechModels] = NOT_GIVEN,
min_confidence_threshold: NotGivenOr[float] = NOT_GIVEN,
keywords: NotGivenOr[list[tuple[str, float]]] = NOT_GIVEN,
Expand All @@ -475,6 +486,8 @@ def update_options(
self._config.punctuate = punctuate
if is_given(spoken_punctuation):
self._config.spoken_punctuation = spoken_punctuation
if is_given(profanity_filter):
self._config.profanity_filter = profanity_filter
if is_given(model):
old_version = self._config.version
self._config.model = model
Expand Down Expand Up @@ -506,6 +519,7 @@ def _build_streaming_config(
enable_word_time_offsets=self._config.enable_word_time_offsets,
enable_spoken_punctuation=self._config.spoken_punctuation,
enable_word_confidence=self._config.enable_word_confidence,
profanity_filter=self._config.profanity_filter,
),
),
streaming_features=cloud_speech_v2.StreamingRecognitionFeatures(
Expand All @@ -526,6 +540,7 @@ def _build_streaming_config(
enable_word_confidence=self._config.enable_word_confidence,
enable_automatic_punctuation=self._config.punctuate,
enable_spoken_punctuation=self._config.spoken_punctuation,
profanity_filter=self._config.profanity_filter,
model=self._config.model,
),
interim_results=self._config.interim_results,
Expand Down