Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class STTOptions:
profanity: NotGivenOr[speechsdk.enums.ProfanityOption] = NOT_GIVEN
phrase_list: NotGivenOr[list[str] | None] = NOT_GIVEN
explicit_punctuation: bool = False
true_text_post_processing: bool = False


class STT(stt.STT):
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,
true_text_post_processing: bool = False,
):
"""
Create a new instance of Azure STT.
Expand All @@ -97,6 +99,7 @@ def __init__(
explicit_punctuation: Controls punctuation behavior. If True, enables explicit punctuation mode
where punctuation marks are added explicitly. If False (default), uses Azure's
default punctuation behavior.
true_text_post_processing: Enables Azure "TrueText" post-processing in the recognition result.
"""

super().__init__(
Expand Down Expand Up @@ -151,6 +154,7 @@ def __init__(
speech_endpoint=speech_endpoint,
phrase_list=phrase_list,
explicit_punctuation=explicit_punctuation,
true_text_post_processing=true_text_post_processing,
)
self._streams = weakref.WeakSet[SpeechStream]()

Expand Down Expand Up @@ -406,6 +410,10 @@ def _create_speech_recognizer(
speech_config.set_service_property(
"punctuation", "explicit", speechsdk.ServicePropertyChannel.UriQueryParameter
)
if config.true_text_post_processing:
speech_config.set_property(
speechsdk.enums.PropertyId.SpeechServiceResponse_PostProcessingOption, "TrueText"
)

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