Enable live real-time TTS voice synchronization between VoiceManager and KokoroTTS

This commit is contained in:
Adolfo Reyna
2026-08-07 20:23:21 -04:00
parent 469d372338
commit 757261ebfd
3 changed files with 20 additions and 1 deletions
+13
View File
@@ -77,6 +77,19 @@ class VoiceManager:
logger.warning(f"Could not load saved voice settings: {e}")
return self._active_voice
def sync_voice(self) -> str:
"""Check if voice_settings.json was updated on disk and update TTS live."""
current_disk_voice = self.load_saved_voice()
if self._tts_processor and current_disk_voice:
if hasattr(self._tts_processor, "_settings"):
current_tts_voice = getattr(self._tts_processor._settings, "voice", None)
if current_tts_voice != current_disk_voice:
self._tts_processor._settings.voice = current_disk_voice
logger.info(f"Live TTS voice synced to: {current_disk_voice}")
elif hasattr(self._tts_processor, "set_voice"):
self._tts_processor.set_voice(current_disk_voice)
return current_disk_voice
def save_voice(self, voice_name: str):
try:
self._config_file.write_text(json.dumps({"voice": voice_name}, indent=2))