Change pitch and volume added to voice settings.

This commit is contained in:
Storm Dragon
2025-08-07 21:33:11 -04:00
parent 835f7ca4af
commit 7b235bec14
4 changed files with 221 additions and 65 deletions
+35 -6
View File
@@ -147,19 +147,48 @@ class VoiceSelectionMenu:
# Clean up before executing system commands
self.cleanup(full_cleanup=False)
# Use sed to update the DefaultModule in speechd.conf
sed_cmd = f"sudo sed -i '/^\\s*#\\?\\s*DefaultModule\\s\\+/c\\DefaultModule {module}' /etc/speech-dispatcher/speechd.conf"
subprocess.run(sed_cmd, shell=True, check=True)
# Read the current config file
import re
with open('/etc/speech-dispatcher/speechd.conf', 'r') as f:
content = f.read()
# Restart speech-dispatcher
# Check if DefaultModule is already uncommented
if re.search(r'^\s*DefaultModule\s+', content, re.MULTILINE):
# Replace existing DefaultModule line
new_content = re.sub(
r'^(\s*)DefaultModule\s+\S+',
f'\\1DefaultModule {module}',
content,
flags=re.MULTILINE
)
else:
# Uncomment and set DefaultModule line
new_content = re.sub(
r'^(\s*)#\s*DefaultModule\s+\S*',
f'\\1DefaultModule {module}',
content,
flags=re.MULTILINE
)
# Write to a temporary file
temp_file = "/tmp/speechd.conf.new"
with open(temp_file, 'w') as f:
f.write(new_content)
# Use sudo to move the file to the correct location
subprocess.run(f"sudo mv {temp_file} /etc/speech-dispatcher/speechd.conf", shell=True, check=True)
# Restart speech-dispatcher more thoroughly
subprocess.run("sudo systemctl restart speech-dispatcher", shell=True, check=False)
# Also kill any remaining processes
subprocess.run("sudo killall speech-dispatcher", shell=True, check=False)
# Re-initialize speech after changes
time.sleep(1) # Give a moment for the service to restart
time.sleep(2) # Give more time for the service to restart
self.init_speech()
# Notify the user that the change is complete - should not be interrupted
self.speak(f"The {module} module is now being used for this system.", interrupt=False)
self.speak(f"The {module} module is now set as the default voice for this system.", interrupt=False)
# Return to the menu after speech finishes
# No sleep here - the next UI repaint doesn't depend on speech finishing