Still attempting to kill off this delay.
This commit is contained in:
@@ -133,16 +133,16 @@ class OutputManager:
|
||||
"""
|
||||
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)
|
||||
|
||||
text = re.sub(r"(?<!\w)\.(\w+)", r"dot \1", text)
|
||||
|
||||
# Replace dots between word characters in one pass. The old loop
|
||||
# rescanned the full speech string once per remaining dotted word,
|
||||
# which made large directory listings block the event loop for seconds.
|
||||
text = re.sub(r"(?<=\w)\.(?=\w)", " dot ", text)
|
||||
|
||||
return text
|
||||
|
||||
def speak_text(
|
||||
|
||||
@@ -178,6 +178,19 @@ def test_present_text_records_speech_history_when_enabled():
|
||||
speech_driver.speak.assert_called_once()
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_process_mid_word_punctuation_handles_chained_dotted_words():
|
||||
output_manager, _sound_driver, _speech_driver = build_output_manager()
|
||||
|
||||
result = output_manager.process_mid_word_punctuation(
|
||||
".config archive.tar.gz settings.conf."
|
||||
)
|
||||
|
||||
assert result == (
|
||||
"dot config archive dot tar dot gz settings dot conf."
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_present_text_does_not_record_when_speech_disabled():
|
||||
output_manager, _sound_driver, speech_driver = build_output_manager()
|
||||
|
||||
Reference in New Issue
Block a user