From 9387eca6e9c5d0bce4f1f1e20f0a488c06e8e2ca Mon Sep 17 00:00:00 2001 From: rakeshv Date: Tue, 29 Sep 2026 16:17:47 +0530 Subject: [PATCH 1/2] updated comments for LanguageInfo msg --- sdk/batch/speechmatics/batch/_models.py | 4 ++-- sdk/rt/speechmatics/rt/_models.py | 11 ++++++++++ tests/rt/test_models.py | 28 +++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 tests/rt/test_models.py diff --git a/sdk/batch/speechmatics/batch/_models.py b/sdk/batch/speechmatics/batch/_models.py index 478dac9a..d5f25f1a 100644 --- a/sdk/batch/speechmatics/batch/_models.py +++ b/sdk/batch/speechmatics/batch/_models.py @@ -123,12 +123,12 @@ class TranscriptionConfig: language_hints: List of languages that are most likely to appear in your audio, This improves accuracy by biasing recognition toward the specified languages. Use ``language_hints_strict`` to control whether other languages can also be detected. - Applicable only for the next-gen models. Support for next-gen models is coming soon. + Applicable only for the next-gen models (e.g. melia-1, oak-1). language_hints_strict: Controls how strictly language hints are applied. When ``True``, the transcript will only contain languages specified in ``language_hints``. When ``False``, recognition is biased toward the specified languages while still allowing other languages to be detected if present. - Applicable only for the next-gen models. Support for the next-gen models is coming soon. + Applicable only for the next-gen models (e.g. melia-1, oak-1). """ language: str = "en" diff --git a/sdk/rt/speechmatics/rt/_models.py b/sdk/rt/speechmatics/rt/_models.py index 38240146..ac6e986e 100644 --- a/sdk/rt/speechmatics/rt/_models.py +++ b/sdk/rt/speechmatics/rt/_models.py @@ -395,6 +395,15 @@ class TranscriptionConfig: Defaults to None. operating_point: (Deprecated) Legacy argument for specifying the operating point. Use `model` instead going forward Defaults to None. + language_hints: (Optional) List of languages that are most likely to appear in your audio, + This improves accuracy by biasing recognition toward the specified languages. + Use ``language_hints_strict`` to control whether other languages can also be detected. + Applicable only for the next-gen models (e.g. melia-1). + language_hints_strict: (Optional) Controls how strictly language hints are applied. + When ``True``, the transcript will only contain languages specified in ``language_hints``. + When ``False``, recognition is biased toward the specified languages while still allowing other + languages to be detected if present. + Applicable only for the next-gen models (e.g. melia-1). Examples: Basic English transcription: @@ -438,6 +447,8 @@ class TranscriptionConfig: ctrl: Optional[dict] = None channel_diarization_labels: Optional[list[str]] = None operating_point: Optional[OperatingPoint] = None + language_hints: Optional[list[str]] = None + language_hints_strict: Optional[bool] = None def __post_init__(self) -> None: if self.model is not _UNSET and self.operating_point is not None: diff --git a/tests/rt/test_models.py b/tests/rt/test_models.py new file mode 100644 index 00000000..e4cd974e --- /dev/null +++ b/tests/rt/test_models.py @@ -0,0 +1,28 @@ +from speechmatics.rt._models import TranscriptionConfig + + +class TestLanguageHintsToDict: + def test_language_hints_serializes_correctly(self): + config = TranscriptionConfig(language_hints=["en", "fr"]) + result = config.to_dict() + assert result["language_hints"] == ["en", "fr"] + assert "language_hints_strict" not in result + + def test_language_hints_strict_true_serializes_correctly(self): + config = TranscriptionConfig(language_hints=["en"], language_hints_strict=True) + result = config.to_dict() + assert result["language_hints"] == ["en"] + assert result["language_hints_strict"] is True + + def test_language_hints_strict_false_serializes_correctly(self): + config = TranscriptionConfig(language_hints=["en"], language_hints_strict=False) + result = config.to_dict() + assert result["language_hints"] == ["en"] + assert "language_hints_strict" in result + assert result["language_hints_strict"] is False + + def test_language_hints_absent_when_none(self): + config = TranscriptionConfig() + result = config.to_dict() + assert "language_hints" not in result + assert "language_hints_strict" not in result From c72f5fe681d3df3259e2d65a880f1dd71e2747a2 Mon Sep 17 00:00:00 2001 From: rakeshv Date: Tue, 29 Sep 2026 17:21:24 +0530 Subject: [PATCH 2/2] fixed redundant comments --- sdk/batch/speechmatics/batch/_models.py | 18 ++++++++++-------- sdk/rt/speechmatics/rt/_models.py | 20 ++++++++++++-------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/sdk/batch/speechmatics/batch/_models.py b/sdk/batch/speechmatics/batch/_models.py index d5f25f1a..4019d334 100644 --- a/sdk/batch/speechmatics/batch/_models.py +++ b/sdk/batch/speechmatics/batch/_models.py @@ -120,15 +120,17 @@ class TranscriptionConfig: defaults to None. audio_filtering_config: Configuration for limiting the transcription of quiet audio. Defaults to None. - language_hints: List of languages that are most likely to appear in your audio, - This improves accuracy by biasing recognition toward the specified languages. - Use ``language_hints_strict`` to control whether other languages can also be detected. - Applicable only for the next-gen models (e.g. melia-1, oak-1). - language_hints_strict: Controls how strictly language hints are applied. - When ``True``, the transcript will only contain languages specified in ``language_hints``. - When ``False``, recognition is biased toward the specified languages while still allowing other - languages to be detected if present. + language_hints: List of languages that are most likely to appear in your audio. + Recognition is restricted to these languages, which improves accuracy on multilingual + audio. Typically used with ``language="multi"``. Hints take precedence over ``language``, + so the transcript may not contain the language named there. Applicable only for the next-gen models (e.g. melia-1, oak-1). + language_hints_strict: Controls how strictly ``language_hints`` is applied, and is only valid + alongside it. + Only ``True`` is currently supported: the transcript will contain only the languages + specified in ``language_hints``. This is also what happens when it is left unset. + ``False`` is reserved for biasing recognition toward the hinted languages while still + allowing other languages to be detected, which the models do not implement yet. """ language: str = "en" diff --git a/sdk/rt/speechmatics/rt/_models.py b/sdk/rt/speechmatics/rt/_models.py index ac6e986e..cf2540ed 100644 --- a/sdk/rt/speechmatics/rt/_models.py +++ b/sdk/rt/speechmatics/rt/_models.py @@ -395,15 +395,19 @@ class TranscriptionConfig: Defaults to None. operating_point: (Deprecated) Legacy argument for specifying the operating point. Use `model` instead going forward Defaults to None. - language_hints: (Optional) List of languages that are most likely to appear in your audio, - This improves accuracy by biasing recognition toward the specified languages. - Use ``language_hints_strict`` to control whether other languages can also be detected. - Applicable only for the next-gen models (e.g. melia-1). - language_hints_strict: (Optional) Controls how strictly language hints are applied. - When ``True``, the transcript will only contain languages specified in ``language_hints``. - When ``False``, recognition is biased toward the specified languages while still allowing other - languages to be detected if present. + language_hints: (Optional) List of languages that are most likely to appear in your audio. + Recognition is restricted to these languages, which improves accuracy on multilingual + audio. Typically used with ``language="multi"``. Hints take precedence over ``language``, + so the transcript may not contain the language named there. Applicable only for the next-gen models (e.g. melia-1). + Defaults to None. + language_hints_strict: (Optional) Controls how strictly ``language_hints`` is applied, and is + only valid alongside it. + Only ``True`` is currently supported: the transcript will contain only the languages + specified in ``language_hints``. This is also what happens when it is left unset. + ``False`` is reserved for biasing recognition toward the hinted languages while still + allowing other languages to be detected, which the models do not implement yet. + Defaults to None. Examples: Basic English transcription: