A few final adjustments to the audio utility.

This commit is contained in:
Storm Dragon
2026-04-15 16:04:59 -04:00
parent e24d79272e
commit f2e729e508

View File

@@ -1,6 +1,7 @@
#!/usr/bin/env python3
import curses
import configparser
import json
import os
import re
@@ -256,6 +257,11 @@ class AudioManagerApp:
self.backend = AudioBackend()
self.feedback = AudioFeedback()
self.speech_client = None
self.config_dir = os.path.expanduser("~/.config/stormux")
self.config_file = os.path.join(self.config_dir, "game_launcher.conf")
self.config = configparser.ConfigParser()
self.speech_rate = 0
self.speech_pitch = 0
self.stdscr = None
self.focus_names = [
"Output Volume",
@@ -276,6 +282,19 @@ class AudioManagerApp:
self.input_volume = 50
self.pending_change = None
self.status_message = ""
self.load_speech_settings()
def load_speech_settings(self):
if not os.path.exists(self.config_file):
return
try:
self.config.read(self.config_file)
if "Speech" in self.config:
self.speech_rate = self.config.getint("Speech", "rate", fallback=0)
self.speech_pitch = self.config.getint("Speech", "pitch", fallback=0)
except Exception:
pass
def init_speech(self):
if speechd is None:
@@ -283,6 +302,8 @@ class AudioManagerApp:
self.speech_client = speechd.SSIPClient("audio_manager")
self.speech_client.set_priority(speechd.Priority.IMPORTANT)
self.speech_client.set_punctuation(speechd.PunctuationMode.SOME)
self.speech_client.set_rate(self.speech_rate)
self.speech_client.set_pitch(self.speech_pitch)
def speak(self, text, interrupt=True):
if not self.speech_client:
@@ -557,11 +578,7 @@ class AudioManagerApp:
except Exception:
pass
self.speak(
"Sound and Volume. Use left and right arrows to select, "
"up and down arrows to adjust, and space to read the current value. "
"Press h for help."
)
self.speak("Stormux audio manager, press h for help.")
while True:
if pending_change_expired(self.pending_change):