feat: switch wake word to waltron
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import re
|
||||
import pymorphy3
|
||||
from num2words import num2words
|
||||
from .config import WAKE_WORD, WAKE_WORD_ALIASES
|
||||
from .roman import roman_to_int
|
||||
|
||||
morph = pymorphy3.MorphAnalyzer()
|
||||
@@ -83,6 +84,10 @@ MONTHS_GENITIVE = [
|
||||
|
||||
# Время
|
||||
TIME_UNIT_LEMMAS = {"час", "минута", "секунда"}
|
||||
WAKE_WORD_BLOCKED_PATTERNS = [
|
||||
re.compile(rf"\b{re.escape(alias)}\b", flags=re.IGNORECASE)
|
||||
for alias in set(WAKE_WORD_ALIASES) | {WAKE_WORD.lower()}
|
||||
]
|
||||
|
||||
# Суффиксы порядковых
|
||||
_ORDINAL_SUFFIX_MAP = {
|
||||
@@ -419,6 +424,10 @@ def clean_response(text: str, language: str = "ru") -> str:
|
||||
flags=re.IGNORECASE | re.MULTILINE,
|
||||
)
|
||||
|
||||
# Запрет на произнесение wake word в любых ответах ассистента.
|
||||
for pattern in WAKE_WORD_BLOCKED_PATTERNS:
|
||||
text = pattern.sub("ассистент", text)
|
||||
|
||||
# Числа в слова
|
||||
if language == "ru":
|
||||
text = roman_numerals_to_words(text)
|
||||
|
||||
Reference in New Issue
Block a user