From 629111005bc0de7448d8f6c172c0542e1be92cb5 Mon Sep 17 00:00:00 2001 From: will wade Date: Sat, 14 Sep 2024 18:54:34 +0100 Subject: [PATCH] fixing values to unpack --- VoiceServer/RegisterVoice.py | 8 ++++---- VoiceServer/VoiceServer.py | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/VoiceServer/RegisterVoice.py b/VoiceServer/RegisterVoice.py index 487ee9f..4d333c9 100644 --- a/VoiceServer/RegisterVoice.py +++ b/VoiceServer/RegisterVoice.py @@ -103,14 +103,14 @@ def register_selected_voices(self): QMessageBox.warning(self, "Warning", "Please select at least one voice to register.") return - # Extract the selected voices from the list - selected_voices = [item.data(Qt.UserRole)['name'] for item in selected_items] + engine_name = self.engine_combo.currentText() # Extract the engine name from the combo box + selected_voices = [f"{engine_name}-{item.data(Qt.UserRole)['name']}" for item in selected_items] - # Send registration request to the pipe service for each selected voice + # Send registration request to the pipe service for voice_iso_code in selected_voices: request = { "action": "set_voice", - "voice_iso_code": voice_iso_code # Voice ISO code now includes both engine and voice + "voice_iso_code": voice_iso_code # Now includes both engine and voice } response = send_pipe_request(request) if response and response.get("status") == "success": diff --git a/VoiceServer/VoiceServer.py b/VoiceServer/VoiceServer.py index fcb2a7d..459aaaa 100644 --- a/VoiceServer/VoiceServer.py +++ b/VoiceServer/VoiceServer.py @@ -273,12 +273,15 @@ def speak_text_streamed(self, pipe, tts_engine, text, voice): def register_voice(self, voice_iso_code): try: + # Check if the voice_iso_code contains both engine and voice + if "-" not in voice_iso_code: + raise ValueError(f"Invalid voice_iso_code format: {voice_iso_code}") + # Split the voice_iso_code to get engine and voice name engine_name, voice_name = voice_iso_code.split("-", 1) - # Log the registration process logging.info(f"Registering voice: {voice_name} for engine: {engine_name}") - + # Register the engine DLL engine_dll = os.path.join(self.libs_directory, 'pysapittsengine.dll') self.run_command(["regsvr32.exe", "/s", engine_dll]) @@ -293,8 +296,6 @@ def register_voice(self, voice_iso_code): '--module', 'voices', '--class', f"{engine_name}Voice" ] - - # Run the registration command self.run_command(register_command) logging.info(f"Successfully registered voice: {voice_iso_code}")