Experimental Braille support added.

This commit is contained in:
Storm Dragon
2025-10-19 18:02:34 -04:00
parent 16e01cb1f5
commit f9564265fa
6 changed files with 891 additions and 54 deletions

View File

@@ -14,7 +14,7 @@ from src.tts_engine import TtsEngine
class OptionsMenu:
"""Options menu for configuring BookStorm settings"""
def __init__(self, config, speechEngine, voiceSelector, audioPlayer, ttsReloadCallback=None):
def __init__(self, config, speechEngine, voiceSelector, audioPlayer, ttsReloadCallback=None, brailleOutput=None):
"""
Initialize options menu
@@ -24,12 +24,14 @@ class OptionsMenu:
voiceSelector: VoiceSelector instance
audioPlayer: MpvPlayer instance
ttsReloadCallback: Optional callback to reload TTS engine
brailleOutput: Optional BrailleOutput instance
"""
self.config = config
self.speechEngine = speechEngine
self.voiceSelector = voiceSelector
self.audioPlayer = audioPlayer
self.ttsReloadCallback = ttsReloadCallback
self.brailleOutput = brailleOutput
self.currentSelection = 0
self.inMenu = False
@@ -78,6 +80,10 @@ class OptionsMenu:
'label': "Speech Rate Settings",
'action': 'speech_rate'
},
{
'label': "Braille Settings",
'action': 'braille_settings'
},
{
'label': absLabel,
'action': 'audiobookshelf_setup'
@@ -132,6 +138,8 @@ class OptionsMenu:
return self._toggle_show_text()
elif action == 'speech_rate':
return self._speech_rate_info()
elif action == 'braille_settings':
return self._braille_settings()
elif action == 'audiobookshelf_setup':
return self._audiobookshelf_setup()
elif action == 'back':
@@ -493,6 +501,40 @@ class OptionsMenu:
if menuItems and self.currentSelection < len(menuItems):
self.speechEngine.speak(menuItems[self.currentSelection]['label'])
def _braille_settings(self):
"""Open Braille settings submenu"""
if not self.brailleOutput:
self.speechEngine.speak("Braille output not initialized")
return True
# Import here to avoid circular dependency
from src.braille_menu import BrailleMenu
import pygame
# Create Braille menu
# Get pygame screen if available
screen = pygame.display.get_surface()
if not screen:
# Create minimal display for menu
screen = pygame.display.set_mode((1600, 900))
brailleMenu = BrailleMenu(screen, self.speechEngine, self.brailleOutput, self.config)
# Show Braille menu (blocks until user exits)
continueRunning = brailleMenu.show()
# Return to options menu
if continueRunning:
self.speechEngine.speak("Back to options menu")
# Speak current menu item
menuItems = self.show_main_menu()
if menuItems and self.currentSelection < len(menuItems):
self.speechEngine.speak(menuItems[self.currentSelection]['label'])
return True
else:
# User closed the application
return False
def _audiobookshelf_setup(self):
"""Setup Audiobookshelf server connection"""
from src.ui import get_input