Setting added to choose caps notification type, beep, pitch, both or none.

This commit is contained in:
Storm Dragon
2025-12-30 04:09:25 -05:00
parent 49a79d2722
commit d7f86ca0de
5 changed files with 33 additions and 27 deletions

View File

@@ -45,6 +45,12 @@ rate=0.5
pitch=0.5
# Pitch for capital letters
capital_pitch=0.9
# How to indicate capital letters:
# pitch = change speech pitch (uses capital_pitch value)
# beep = play Caps.wav sound icon
# both = play beep AND change pitch
# none = no special indication
capital_indicator=pitch
# Volume controls the loudness of the voice, select from 0, quietest, to 1.0, loudest.
volume=1.0

View File

@@ -17,8 +17,7 @@ from fenrirscreenreader.core.eventData import FenrirEventType
class EventManager:
def __init__(self):
self.running = Value(c_bool, True)
# Bounded queue to prevent memory exhaustion
self._eventQueue = Queue(maxsize=100)
self._eventQueue = Queue()
self.clean_event_queue()
def initialize(self, environment):
@@ -107,23 +106,5 @@ class EventManager:
return False
if event == FenrirEventType.ignore:
return False
# Use bounded queue - if full, this will block briefly or drop older
# events
try:
self._eventQueue.put({"Type": event, "data": data}, timeout=0.1)
except Exception as e:
# Queue full - drop oldest event and add new one for critical
# events
if event in [
FenrirEventType.screen_update,
FenrirEventType.keyboard_input,
]:
try:
self._eventQueue.get_nowait() # Remove oldest
self._eventQueue.put(
{"Type": event, "data": data}, timeout=0.1
)
except BaseException:
pass # If still can't add, drop the event
# For non-critical events, just drop them if queue is full
self._eventQueue.put({"Type": event, "data": data})
return True

View File

@@ -65,13 +65,31 @@ class OutputManager:
return
if (len(text) > 1) and (text.strip(string.whitespace) == ""):
return
to_announce_capital = announce_capital and text[0].isupper()
if to_announce_capital:
if self.play_sound_icon("capital", False):
to_announce_capital = False
is_capital = announce_capital and text[0].isupper()
use_pitch_for_capital = False
if is_capital:
indicator = self.env["runtime"]["SettingsManager"].get_setting(
"speech", "capital_indicator"
).lower()
if indicator == "none":
pass # No indication
elif indicator == "beep":
# Play beep with interrupt=True to fix stacking
self.play_sound_icon("capital", True)
elif indicator == "pitch":
use_pitch_for_capital = True
elif indicator == "both":
self.play_sound_icon("capital", True)
use_pitch_for_capital = True
else:
# Default to pitch for unknown values
use_pitch_for_capital = True
self.last_echo = text
self.speak_text(
text, interrupt, ignore_punctuation, to_announce_capital, flush
text, interrupt, ignore_punctuation, use_pitch_for_capital, flush
)
def get_last_echo(self):

View File

@@ -23,6 +23,7 @@ settings_data = {
"rate": 0.75,
"pitch": 0.5,
"capital_pitch": 0.8,
"capital_indicator": "pitch",
"volume": 1.0,
"module": "",
"voice": "en-us",

View File

@@ -4,5 +4,5 @@
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributors.
version = "2025.12.28"
version = "2025.12.30"
code_name = "testing"