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
2 changes: 1 addition & 1 deletion assemblyai/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.64.32"
__version__ = "0.64.33"
14 changes: 13 additions & 1 deletion assemblyai/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,10 @@ class LanguageDetectionOptions(BaseModel):
None,
description="The language detection model to use.",
)
localization: Optional[List[str]] = Field(
None,
description='Locale codes (e.g. ["en_au"]) to render detected English in a regional spelling variant. Supported values are "en_au" and "en_uk"; at most one locale per language.',
)


class CodeSwitchingLanguage(BaseModel):
Expand Down Expand Up @@ -1969,6 +1973,7 @@ def set_language_detection(
expected_languages: Optional[List[str]] = None,
fallback_language: Optional[str] = None,
on_low_language_confidence: Optional[str] = None,
localization: Optional[List[str]] = None,
) -> Self:
"""
Enable Automatic Language Detection with optional configuration.
Expand All @@ -1979,6 +1984,7 @@ def set_language_detection(
expected_languages: A list of languages that the audio could be expected to be.
fallback_language: The language to fallback to if detection fails.
on_low_language_confidence: Controls behavior when language confidence is below threshold. Either "error" (default) or "fallback".
localization: Locale codes (e.g. ["en_au"]) to render detected English in a regional spelling variant. Supported values are "en_au" and "en_uk".
"""

if not enable:
Expand All @@ -1992,12 +1998,18 @@ def set_language_detection(
confidence_threshold
)

if expected_languages or fallback_language or on_low_language_confidence:
if (
expected_languages
or fallback_language
or on_low_language_confidence
or localization
):
self._raw_transcription_config.language_detection_options = (
LanguageDetectionOptions(
expected_languages=expected_languages,
fallback_language=fallback_language,
on_low_language_confidence=on_low_language_confidence,
localization=localization,
)
)

Expand Down
Loading