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.
Clean upgrades: installer asks a running VoxShift to quit
skyc107a5e36701
diff --git a/packaging/publish.py b/packaging/publish.pyindex 2f34d81..3bb913b 100644--- a/packaging/publish.py+++ b/packaging/publish.py@@ -3,12 +3,13 @@python packaging/publish.py --models # build/model-pack -> release models-v1 (not "latest")python packaging/publish.py --app # build/VoxShift-Setup-<ver>.exe -> release v<ver> (latest)-Files already on the release with the right size are skipped, so re-running+Files already on the release with the same SHA-256 are skipped, so re-runningafter a network failure only uploads what is missing. Needs the GitHub CLI."""from __future__ import annotationsimport argparse+import hashlibimport jsonimport subprocessimport sys@@ -39,11 +40,18 @@ def assets(release_id: int) -> dict[str, dict]:return {a["name"]: a for a in json.loads(gh("api", f"repos/{REPO}/releases/{release_id}/assets?per_page=100"))}+def same_file(asset: dict, f: Path) -> bool:+ """GitHub reports a SHA-256 digest per asset; fall back to size for older assets."""+ if asset.get("digest", "").startswith("sha256:"):+ return asset["digest"] == "sha256:" + hashlib.sha256(f.read_bytes()).hexdigest()+ return asset["size"] == f.stat().st_size++def upload(tag: str, release_id: int, files: list[Path], tries: int = 6) -> None:for i, f in enumerate(files, 1):for attempt in range(1, tries + 1):have = assets(release_id).get(f.name)- if have and have["state"] == "uploaded" and have["size"] == f.stat().st_size:+ if have and have["state"] == "uploaded" and same_file(have, f):print(f"[{i}/{len(files)}] {f.name}: ok")breakif have: # partial / stale upload: remove before retryingdiff --git a/packaging/voxshift.iss b/packaging/voxshift.issindex 92bfd1b..29e2fc2 100644--- a/packaging/voxshift.iss+++ b/packaging/voxshift.iss@@ -46,6 +46,10 @@ Name: "vbcable"; Description: "Install the virtual microphone (free VB-CABLE driName: "desktopicon"; Description: "Create a desktop shortcut"Name: "autostart"; Description: "Start VoxShift with Windows (in the tray)"; Flags: unchecked+[InstallDelete]+; an earlier offline (bundled-model) install kept the model here; web installs use %LOCALAPPDATA%+Type: filesandordirs; Name: "{app}\models"+[Files]Source: "{#DistDir}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs@@ -91,6 +95,34 @@ beginResult := FileExists(ExpandConstant('{localappdata}\VoxShift\models\onnx\whisper-small-bigvgan\config.json'));end;+{ Ask a running VoxShift to exit before its files are replaced. It hides in the tray when its+ window is closed, so the Restart Manager alone cannot shut it down. }+function OpenEvent(Access: Cardinal; Inherit: LongBool; Name: String): THandle;+ external '[email protected] stdcall';+function SetEvent(Handle: THandle): LongBool;+ external '[email protected] stdcall';+function CloseHandle(Handle: THandle): LongBool;+ external '[email protected] stdcall';++function PrepareToInstall(var NeedsRestart: Boolean): String;+var+ H: THandle;+ I: Integer;+begin+ Result := '';+ H := OpenEvent($0002, False, 'Local\VoxShift.Quit');+ if H <> 0 then begin+ SetEvent(H);+ CloseHandle(H);+ for I := 1 to 50 do begin { the event vanishes once the app has exited; wait up to 5 s }+ Sleep(100);+ H := OpenEvent($0002, False, 'Local\VoxShift.Quit');+ if H = 0 then Break;+ CloseHandle(H);+ end;+ end;+end;+#ifdef ModelIncludevarDownloadPage: TDownloadWizardPage;diff --git a/voxshift/gui.py b/voxshift/gui.pyindex 1abbbf0..0ec0ac0 100644--- a/voxshift/gui.py+++ b/voxshift/gui.py@@ -220,6 +220,11 @@ class App:self.register_hotkeys()self._start_tray()root.protocol("WM_DELETE_WINDOW", self.on_close)+ # Tk delivers WM_QUERYENDSESSION (Windows logoff / Restart Manager during updates) as+ # WM_SAVE_YOURSELF: really exit then, instead of hiding in the tray.+ root.protocol("WM_SAVE_YOURSELF", self.quit)+ self._quit_evt = winsys.NamedEvent(winsys.NamedEvent.QUIT)+ self._show_evt = winsys.NamedEvent(winsys.NamedEvent.SHOW)if minimized or self.s.start_minimized:root.withdraw() if self.tray else root.iconify()root.after(400, self._first_run)@@ -677,6 +682,11 @@ class App:# -------------------------------------------------------------- metersdef _tick(self):+ if self._quit_evt.is_set(): # the installer is about to replace our files+ self.quit()+ return+ if self._show_evt.is_set(): # VoxShift was launched again: surface this instance+ self.show()while not self._ui_queue.empty():try:self._ui_queue.get_nowait()()@@ -708,7 +718,8 @@ def main(argv: list[str] | None = None):_setup_logging()guard = winsys.SingleInstance()if guard.already_running:- winsys.message_box("VoxShift is already running — look for its icon in the system tray.")+ if not winsys.NamedEvent.signal(winsys.NamedEvent.SHOW):+ winsys.message_box("VoxShift is already running — look for its icon in the system tray.")returnwinsys.set_app_id()winsys.enable_dpi_awareness()diff --git a/voxshift/winsys.py b/voxshift/winsys.pyindex 3687524..ebc137a 100644--- a/voxshift/winsys.py+++ b/voxshift/winsys.py@@ -50,6 +50,34 @@ class SingleInstance:self.already_running = ctypes.get_last_error() == 183 # ERROR_ALREADY_EXISTS+class NamedEvent:+ """Auto-reset Win32 event other processes can signal by name.++ The installer sets ``Local\\VoxShift.Quit`` so a running copy exits+ before files are replaced; a second launch sets ``Local\\VoxShift.Show``+ to bring the running window forward instead of starting twice."""++ QUIT, SHOW = "Local\\VoxShift.Quit", "Local\\VoxShift.Show"++ def __init__(self, name: str):+ self.handle = ctypes.WinDLL("kernel32").CreateEventW(None, False, False, name) if IS_WIN else None++ def is_set(self) -> bool:+ return bool(self.handle) and ctypes.WinDLL("kernel32").WaitForSingleObject(self.handle, 0) == 0++ @staticmethod+ def signal(name: str) -> bool:+ if not IS_WIN:+ return False+ k32 = ctypes.WinDLL("kernel32")+ h = k32.OpenEventW(0x0002, False, name) # EVENT_MODIFY_STATE+ if not h:+ return False+ k32.SetEvent(h)+ k32.CloseHandle(h)+ return True++class GlobalHotkeys:"""RegisterHotKey on a dedicated thread with its own message loop.