Free, open-source real-time voice changer for Windows: 20 live voices, local AI voice conversion (Seed-VC on ONNX Runtime), soundboard, virtual mic, hotkeys.
0.2.2: no error dialog when quitting from the tray
sky2dbbf874060e
diff --git a/tests/test_gui.py b/tests/test_gui.pynew file mode 100644index 0000000..dbced1e--- /dev/null+++ b/tests/test_gui.py@@ -0,0 +1,41 @@+"""Desktop app lifecycle (real Tk window; audio, tray and hotkeys stubbed out)."""+import pytest++tk = pytest.importorskip("tkinter")+++def app(monkeypatch, tmp_path):+ monkeypatch.setenv("APPDATA", str(tmp_path))+ monkeypatch.setenv("LOCALAPPDATA", str(tmp_path))+ from voxshift import gui, winsys++ class NoEvent: # don't touch the named events a running VoxShift may own+ QUIT = SHOW = ""++ def __init__(self, name):+ pass++ def is_set(self):+ return False++ monkeypatch.setattr(winsys, "NamedEvent", NoEvent)+ for name in ("restart_engine", "register_hotkeys", "_start_tray", "_first_run"):+ monkeypatch.setattr(gui.App, name, lambda self: None)+ try:+ root = tk.Tk()+ except tk.TclError as e:+ pytest.skip(f"no display: {e}")+ root.withdraw()+ return gui.App(root)+++def test_tray_quit_during_tick_is_clean(app):+ # the tray's Quit is marshalled through the UI queue and runs inside _tick;+ # _tick must not touch the (now destroyed) window afterwards+ app.call_soon(app.quit)+ app._tick()+ assert app._closing+ with pytest.raises(tk.TclError):+ app.root.winfo_exists()+ app.quit() # a second request (hotkey, installer) is a harmless no-opdiff --git a/voxshift/__init__.py b/voxshift/__init__.pyindex 0d451ec..de885dc 100644--- a/voxshift/__init__.py+++ b/voxshift/__init__.py@@ -6,4 +6,4 @@ import os# threaded and FFT-bound). Two threads keep matrix maths quick at ~160 MB.os.environ.setdefault("OPENBLAS_NUM_THREADS", "2")-__version__ = "0.2.1"+__version__ = "0.2.2"diff --git a/voxshift/gui.py b/voxshift/gui.pyindex 5c25d31..34daed9 100644--- a/voxshift/gui.py+++ b/voxshift/gui.py@@ -205,6 +205,7 @@ class App:self.hotkey_errors: dict[str, str] = {}self.tray = Noneself._load_token = 0+ self._closing = Falseself._ui_queue: queue.SimpleQueue = queue.SimpleQueue()root.title("VoxShift")root.geometry("1000x640")@@ -681,6 +682,9 @@ class App:self.quit()def quit(self):+ if self._closing: # tray, hotkey, installer and WM_SAVE_YOURSELF can all ask+ return+ self._closing = Trueself.s.save()if self.hotkeys:self.hotkeys.stop()@@ -702,11 +706,13 @@ class App:returnif self._show_evt.is_set(): # VoxShift was launched again: surface this instanceself.show()- while not self._ui_queue.empty():+ while not self._ui_queue.empty() and not self._closing:try:self._ui_queue.get_nowait()()except Exception:log.exception("UI callback failed")+ if self._closing: # a queued action (e.g. tray "Quit") just destroyed the window+ returnif self.engine and self.engine.processor_error: # the engine dropped a failing voiceerr, self.engine.processor_error = self.engine.processor_error, Nonelog.error("voice stopped: %s", err)