Improve Kazakh language detection

This commit is contained in:
Konturai DevOps
2026-05-02 02:14:38 +05:00
parent 984bc2195a
commit 1dfed913db
2 changed files with 22 additions and 4 deletions
+21 -3
View File
@@ -255,6 +255,27 @@ _KAZAKH_LANGUAGE_MARKERS = frozenset({
"казак",
"қазақ",
"қазақша",
"сәлем",
"салем",
"сәлеметсіз",
"салеметсиз",
"рахмет",
"жақсы",
"жаксы",
"иә",
"ия",
"жоқ",
"жок",
"менің",
"менин",
"атым",
"маған",
"маган",
"керек",
"көмек",
"комек",
"сұрақ",
"сурак",
})
_RUSSIAN_LANGUAGE_MARKERS = frozenset({
"русский",
@@ -296,9 +317,6 @@ def _detect_session_language(text: str) -> str | None:
has_russian = any(ch in _RUSSIAN_SPECIFIC_LETTERS for ch in normalized)
if has_russian:
return "ru"
cyrillic_chars = sum(1 for ch in normalized if "а" <= ch <= "я" or ch == "ё")
if cyrillic_chars >= 2:
return "ru"
return None
+1 -1
View File
@@ -92,7 +92,7 @@ class OpenAISTT(BaseSTT):
).strip() or None
self._input_sample_rate_hz = max(int(input_sample_rate_hz), 1)
self._prompt = str(prompt if prompt is not None else os.getenv("STT_PROMPT", "")).strip()
self._language = str(language if language is not None else os.getenv("OPENAI_STT_LANGUAGE", "ru")).strip() or None
self._language = str(language if language is not None else os.getenv("OPENAI_STT_LANGUAGE", "")).strip() or None
self._timeout_seconds = max(float(timeout_seconds if timeout_seconds is not None else _timeout_seconds()), 1.0)
self._max_retries = max(int(max_retries if max_retries is not None else _max_retries()), 0)
self._client: Any | None = None