Skip to content
Open
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 @@ -54,6 +54,7 @@ class STTOptions:
language: list[
str
] # see https://learn.microsoft.com/en-us/azure/ai-services/speech-service/language-support?tabs=stt
end_silence_timeout_ms: NotGivenOr[int]
speech_endpoint: NotGivenOr[str] = NOT_GIVEN
profanity: NotGivenOr[speechsdk.enums.ProfanityOption] = NOT_GIVEN
phrase_list: NotGivenOr[list[str] | None] = NOT_GIVEN
Expand All @@ -79,6 +80,7 @@ def __init__(
speech_endpoint: NotGivenOr[str] = NOT_GIVEN,
phrase_list: NotGivenOr[list[str] | None] = NOT_GIVEN,
explicit_punctuation: bool = False,
end_silence_timeout_ms: NotGivenOr[int] = NOT_GIVEN,
):
"""
Create a new instance of Azure STT.
Expand Down Expand Up @@ -144,6 +146,7 @@ def __init__(
speech_endpoint=speech_endpoint,
phrase_list=phrase_list,
explicit_punctuation=explicit_punctuation,
end_silence_timeout_ms=end_silence_timeout_ms,
)
self._streams = weakref.WeakSet[SpeechStream]()

Expand Down Expand Up @@ -387,6 +390,12 @@ def _create_speech_recognizer(
"punctuation", "explicit", speechsdk.ServicePropertyChannel.UriQueryParameter
)

if config.end_silence_timeout_ms:
speech_config.set_property(
speechsdk.enums.PropertyId.SpeechServiceConnection_EndSilenceTimeoutMs,
str(config.end_silence_timeout_ms),
)

kwargs: dict[str, Any] = {}
if config.language and len(config.language) > 1:
kwargs["auto_detect_source_language_config"] = (
Expand Down