Improve the apply speech settings confirmation work flow.
This commit is contained in:
@@ -227,6 +227,21 @@ class SpeechRateMenu:
|
|||||||
# If cancel fails, try to reinitialize
|
# If cancel fails, try to reinitialize
|
||||||
self.init_speech()
|
self.init_speech()
|
||||||
|
|
||||||
|
def confirm_saved_settings(self):
|
||||||
|
"""Restart speechd, announce success, and wait for confirmation."""
|
||||||
|
subprocess.run(
|
||||||
|
["sudo", "killall", "speech-dispatcher"],
|
||||||
|
check=False,
|
||||||
|
)
|
||||||
|
time.sleep(1)
|
||||||
|
self.init_speech()
|
||||||
|
self.speak("Speech settings applied. Press Enter to continue.", interrupt=False)
|
||||||
|
|
||||||
|
while True:
|
||||||
|
key = self.stdscr.getch()
|
||||||
|
if key == curses.KEY_ENTER or key == 10 or key == 13:
|
||||||
|
break
|
||||||
|
|
||||||
def draw_menu(self):
|
def draw_menu(self):
|
||||||
"""Draw the menu on the screen"""
|
"""Draw the menu on the screen"""
|
||||||
self.stdscr.clear()
|
self.stdscr.clear()
|
||||||
@@ -391,12 +406,10 @@ class SpeechRateMenu:
|
|||||||
self.speak("Saving speech settings to system configuration.")
|
self.speak("Saving speech settings to system configuration.")
|
||||||
success = self.save_settings_to_config()
|
success = self.save_settings_to_config()
|
||||||
if success:
|
if success:
|
||||||
self.speak(f"Speech settings saved successfully. Rate {self.currentRate}, Volume {self.currentVolume}, Pitch {self.currentPitch}.")
|
self.confirm_saved_settings()
|
||||||
else:
|
else:
|
||||||
self.speak("Failed to save speech settings. You may need root privileges.")
|
self.speak("Failed to save speech settings. You may need root privileges.")
|
||||||
|
|
||||||
# Wait briefly to allow speech to complete before exiting
|
|
||||||
time.sleep(4)
|
|
||||||
break # Exit the loop after saving
|
break # Exit the loop after saving
|
||||||
|
|
||||||
elif key == 27 or key == ord('q') or key == ord('Q'): # Esc or Q
|
elif key == 27 or key == ord('q') or key == ord('Q'): # Esc or Q
|
||||||
|
|||||||
Reference in New Issue
Block a user