Enable live real-time TTS voice synchronization between VoiceManager and KokoroTTS
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user