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.1: cap OpenBLAS threads, survive failing voices
sky4d77de3e110f
diff --git a/tests/test_engine.py b/tests/test_engine.pyindex 57b60e8..64326eb 100644--- a/tests/test_engine.py+++ b/tests/test_engine.py@@ -44,3 +44,17 @@ def test_soundboard_mixes_and_drains(engine):assert np.mean(np.abs(blocks[0])) > 0.2assert np.max(np.abs(blocks[-1])) == 0.0assert engine._sounds == []+++def test_failing_voice_is_dropped_not_fatal(engine):+ class Broken:+ latency = 0++ def process(self, x):+ raise RuntimeError("device removed")++ engine.processor = Broken()+ x = 0.1 * np.sin(2 * np.pi * 300 * np.arange(480) / SR)+ out = call(engine, x)+ assert engine.processor is None and "device removed" in engine.processor_error+ assert np.max(np.abs(out[:, 0] - x)) < 1e-3 # the mic keeps flowing, unprocesseddiff --git a/voxshift/__init__.py b/voxshift/__init__.pyindex c7188fd..0d451ec 100644--- a/voxshift/__init__.py+++ b/voxshift/__init__.py@@ -1,2 +1,9 @@"""VoxShift — local real-time voice changer."""-__version__ = "0.2.0"+import os++# numpy's OpenBLAS reserves a work buffer per CPU thread at import: ~1.4 GB of+# commit on a 24-thread laptop that the audio code never uses (it is single-+# threaded and FFT-bound). Two threads keep matrix maths quick at ~160 MB.+os.environ.setdefault("OPENBLAS_NUM_THREADS", "2")++__version__ = "0.2.1"diff --git a/voxshift/ai/seedvc.py b/voxshift/ai/seedvc.pyindex bc4b3af..88b43ee 100644--- a/voxshift/ai/seedvc.py+++ b/voxshift/ai/seedvc.py@@ -419,6 +419,7 @@ class SeedVCProcessor:# decouples, so the host keeps small low-latency buffers.self.preferred_blocksize = self.streamer.block_frame if mode == "inline" else Noneself.headroom = float(spec.get("rtf_headroom", 0.9)) # inference time as a fraction of a block+ self.error: str | None = None # set by the worker if conversion failsself._in = np.zeros(0)self._out = np.zeros(self._prefill())self._q_in: queue.Queue = queue.Queue()@@ -463,8 +464,18 @@ class SeedVCProcessor:blk = self._q_in.get(timeout=0.1)except queue.Empty:continue- with self._lock:- self._q_out.put(self.streamer.process_block(blk))+ # if conversion falls behind (hot / throttled GPU), skip stale audio instead of+ # queueing it without bound: memory stays flat and latency recovers+ while self._q_in.qsize() > 1:+ blk = self._q_in.get_nowait()+ try:+ with self._lock:+ self._q_out.put(self.streamer.process_block(blk))+ except Exception as e: # e.g. GPU device removed: report, stop converting+ import logging+ logging.getLogger(__name__).exception("AI voice conversion failed")+ self.error = f"{type(e).__name__}: {e}"+ returndef close(self):self._stop.set()diff --git a/voxshift/audio/engine.py b/voxshift/audio/engine.pyindex fecc84c..9d19870 100644--- a/voxshift/audio/engine.py+++ b/voxshift/audio/engine.py@@ -145,6 +145,7 @@ class AudioEngine:self.output_gain_db = 0.0self.monitor_gain_db = -6.0self.meters = Meters()+ self.processor_error: str | None = None # set when a voice failed and was droppedself._limiter = SoftLimiter(samplerate, ceiling_db=-0.5)self._sounds: list[np.ndarray] = []self._lock = threading.Lock()@@ -233,7 +234,17 @@ class AudioEngine:x = indata[:, 0].astype(np.float64) * (0.0 if self.mic_muted else db_to_lin(self.input_gain_db))with self._lock:proc = self.processor- y = proc.process(x) if (proc is not None and self.voice_enabled) else x+ y = x+ if proc is not None and self.voice_enabled:+ error = getattr(proc, "error", None) # a threaded AI worker reports failures here+ if error is None:+ try:+ y = proc.process(x)+ except Exception as e: # e.g. the GPU was reset mid-inference+ error = f"{type(e).__name__}: {e}"+ if error is not None:+ # never let a broken voice kill the audio: drop it, pass the mic through+ self.processor, self.processor_error, y = None, error, xif self._sounds:keep = []for s in self._sounds:diff --git a/voxshift/gui.py b/voxshift/gui.pyindex 0ec0ac0..d407254 100644--- a/voxshift/gui.py+++ b/voxshift/gui.py@@ -692,6 +692,12 @@ class App:self._ui_queue.get_nowait()()except Exception:log.exception("UI callback failed")+ if self.engine and self.engine.processor_error: # the engine dropped a failing voice+ err, self.engine.processor_error = self.engine.processor_error, None+ log.error("voice stopped: %s", err)+ self.current_key = None+ self.refresh_voices(select="clean")+ self.status.set(f"The voice stopped after an error and VoxShift switched to Clean ({err[:120]})")c = self.meterc.delete("all")if self.engine: