Attempted better flood control. It's also a configurable settings.

This commit is contained in:
Storm Dragon
2025-12-28 19:18:26 -05:00
parent 49a79d2722
commit 1932118f6a
3 changed files with 20 additions and 1 deletions

View File

@@ -69,6 +69,11 @@ auto_read_incoming=True
# Speak individual numbers instead of whole string.
read_numbers_as_digits = False
# Flood protection: skip reading incoming text if it exceeds this many lines.
# This prevents system slowdown when large amounts of text appear at once.
# Set to 0 to disable flood protection. Default: 500
flood_protection_lines=500
# genericSpeechCommand is the command that is executed for talking
# the following variables are replaced with values
# fenrirText = is the text that should be spoken

View File

@@ -50,11 +50,24 @@ class command:
return
delta_text = self.env["screen"]["new_delta"]
# Skip if tab completion already handled this delta
if self._was_handled_by_tab_completion(delta_text):
return
# Flood protection: skip if too many lines to prevent system slowdown
# Get threshold from settings, default to 500 lines
flood_threshold = self.env["runtime"]["SettingsManager"].get_setting_as_int(
"speech", "flood_protection_lines"
)
if flood_threshold <= 0:
flood_threshold = 500 # Fallback default
line_count = delta_text.count('\n') + 1
if line_count > flood_threshold:
# Too much text - skip to prevent system slowdown
return
# this must be a keyecho or something
# if len(self.env['screen']['new_delta'].strip(' \n\t')) <= 1:
x_move = abs(

View File

@@ -29,6 +29,7 @@ settings_data = {
"language": "",
"auto_read_incoming": True,
"read_numbers_as_digits": False,
"flood_protection_lines": 500,
"generic_speech_command": 'espeak -a fenrirVolume -s fenrirRate -p fenrirPitch -v fenrirVoice "fenrirText"',
"fenrir_min_volume": 0,
"fenrir_max_volume": 200,