fix(ai): ignore generic phrases and stopwords in voice name extraction

This commit is contained in:
Yera All
2026-04-07 01:01:06 +05:00
parent f976a0c2be
commit 1444cf07ab
+10 -1
View File
@@ -375,8 +375,17 @@ def _extract_name_candidate(text: str | None, language: str) -> tuple[str | None
candidate = _normalize_name_candidate(raw)
if candidate:
lower_cand = candidate.lower()
stopwords = {
"здравствуйте", "привет", "алло", "да", "нет", "добрый", "день",
"саламатсыз", "сәлеметсіз", "ба", "бе", "ау", "слышно", "интернет", "не", "работает", "вопрос", "у", "меня"
}
cand_words = set(lower_cand.split())
if cand_words.issubset(stopwords) or len(lower_cand) < 2:
return None, False
word_count = len(re.findall(r"[^\W\d_]+(?:[-'][^\W\d_]+)*", raw, flags=re.UNICODE))
if word_count <= 3 and not _name_followup_needed(raw):
if word_count <= 2 and not _name_followup_needed(raw):
return candidate, False
return candidate, True
return None, False