Fenrir will now read dots in the middle of or at the beginning of words regardless of punctuation settings.

This commit is contained in:
Storm Dragon
2025-08-21 23:29:45 -04:00
parent 78c1cbbb6b
commit b3d73102fc

View File

@@ -77,6 +77,27 @@ class OutputManager:
def get_last_echo(self): def get_last_echo(self):
return self.last_echo return self.last_echo
def process_mid_word_punctuation(self, text):
"""
Process punctuation that appears mid-word to ensure proper pronunciation.
Specifically handles dots between word characters (e.g., "settings.conf" -> "settings dot conf")
and dots at word beginnings (e.g., ".local" -> "dot local")
while preserving sentence-ending periods and other punctuation behavior.
"""
if not text:
return text
# Handle dots at the beginning of words (like .local, .bashrc, .config)
# Look for non-word character (or start of string), dot, then word characters
text = re.sub(r'(?<!\w)\.(\w+)', r'dot \1', text)
# Replace dots that appear between word characters with spoken form
# Use a loop to handle multiple consecutive dots like www.example.com or a.b.c.d
while re.search(r'\b\w+\.\w+\b', text):
text = re.sub(r'\b(\w+)\.(\w+)\b', r'\1 dot \2', text)
return text
def speak_text( def speak_text(
self, self,
text, text,
@@ -208,6 +229,7 @@ class OutputManager:
clean_text = self.env["runtime"]["TextManager"].replace_head_lines( clean_text = self.env["runtime"]["TextManager"].replace_head_lines(
clean_text clean_text
) )
clean_text = self.process_mid_word_punctuation(clean_text)
clean_text = self.env["runtime"][ clean_text = self.env["runtime"][
"PunctuationManager" "PunctuationManager"
].proceed_punctuation(clean_text, ignore_punctuation) ].proceed_punctuation(clean_text, ignore_punctuation)