speculative fixes for hardware speech.

This commit is contained in:
Storm Dragon
2026-05-23 17:10:46 -04:00
parent d853e1b24d
commit d4b2fec1db
3 changed files with 57 additions and 4 deletions
+1 -1
View File
@@ -4,5 +4,5 @@
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributors.
version = "2026.05.22"
version = "2026.05.23"
code_name = "testing"
@@ -51,6 +51,8 @@ class hardware_serial_driver(speech_driver):
)
self._open_serial_port()
self._is_initialized = self.serial_port is not None
if not self._is_initialized:
raise RuntimeError("hardware speech device is not available")
if self._is_initialized:
self._stop_worker = False
self.worker_thread = threading.Thread(
@@ -124,6 +126,7 @@ class hardware_serial_driver(speech_driver):
self._debug(
"Hardware speech device not found",
debug.DebugLevel.ERROR,
on_any_level=True,
)
return
try:
@@ -140,10 +143,16 @@ class hardware_serial_driver(speech_driver):
termios.tcsetattr(port, termios.TCSANOW, attrs)
self.serial_port = port
self.device = device
self._debug(
f"Hardware speech device opened: {device}",
debug.DebugLevel.INFO,
on_any_level=True,
)
except OSError as error:
self._debug(
f"Hardware speech device open failed: {device}: {error}",
debug.DebugLevel.ERROR,
on_any_level=True,
)
self.serial_port = None
@@ -173,12 +182,13 @@ class hardware_serial_driver(speech_driver):
self._debug(
f"Hardware speech write failed: {error}",
debug.DebugLevel.ERROR,
on_any_level=True,
)
def _resolve_device(self, device):
if device and device != "auto":
return device
for pattern in ("/dev/ttyACM*", "/dev/ttyUSB*"):
for pattern in ("/dev/ttyACM*", "/dev/ttyUSB*", "/dev/ttyS*"):
matches = sorted(glob.glob(pattern))
if matches:
return matches[0]
@@ -205,10 +215,10 @@ class hardware_serial_driver(speech_driver):
value = max(0.0, min(1.0, value))
return int(round(minimum + value * (maximum - minimum)))
def _debug(self, message, level):
def _debug(self, message, level, on_any_level=False):
try:
self.env["runtime"]["DebugManager"].write_debug_out(
message, level
message, level, on_any_level=on_any_level
)
except Exception:
pass