Skip to content

fix: actually load SoVITS weights in CLI and GUI entrypoints - #2834

Open
kyo-zzz wants to merge 1 commit into
RVC-Boss:mainfrom
kyo-zzz:fix/inference-entrypoints-ignored-sovits-weights
Open

kyo-zzz wants to merge 1 commit into
RVC-Boss:mainfrom
kyo-zzz:fix/inference-entrypoints-ignored-sovits-weights

Conversation

@kyo-zzz

@kyo-zzz kyo-zzz commented Aug 30, 2026

Copy link
Copy Markdown

Problem

inference_cli.py and inference_gui.py call change_sovits_weights() as a plain statement. That function is a generator (it yields Gradio UI-update dicts for the webui), so calling it only creates a generator object: the body never runs. As a result --sovits_model is silently ignored — change_gpt_weights() works because it is a regular function, which is exactly the asymmetry that makes this easy to miss. Audio still gets produced because inference_webui loads the default v2 model at import time (its own next(...) call, wrapped in a bare try/except), so the CLI synthesizes with whatever model was loaded at startup instead of the one the user asked for.

Fixes #2829.

What changed

  1. inference_cli.py / inference_gui.py — iterate the generator (for _ in change_sovits_weights(...): pass) so the SoVITS weights actually load and load errors surface.
  2. inference_webui.py — consuming the generator end-to-end exposed a second latent bug: the post-load yield references six locals (prompt_text_update, prompt_language_update, text_update, text_language_update, visible_sample_steps, visible_inp_refs) that were only assigned when the webui passes UI language args. Any arg-less call therefore raised UnboundLocalError at that yield — invisible until now because the import-time next() swallows everything with except: pass. These six locals now get neutral defaults ({"__type__": "update"} / False); the webui path overwrites all of them exactly as before.

Verification

Windows 11, CPU only (torch 2.5.1+cpu), v2 pretrained models (s1bert25hz-5kh-longer-epoch=12-step=369668.ckpt + s2G2333k.pth):

  • Before the fix (reproduces inference_cli.py never loads the SoVITS model: change_sovits_weights is a generator and is called without being iterated #2829): inference_cli.py --sovits_model NONEXISTENT_BOGUS.pth → exit 0, output.wav produced, using the silently-wrong default model. No error anywhere.
  • After the fix, bogus path: exit 1 with FileNotFoundError: [Errno 2] No such file or directory: 'NONEXISTENT_BOGUS.pth' — fails fast instead of silently synthesizing with the wrong model.
  • After the fix, valid path: exit 0, output.wav produced, and the log shows loading sovits_v2 <All keys matched successfully> twice (import-time load + the CLI's own call) with the requested path echoed by the function's own print — the requested model actually loads.
  • Webui path regression: calling change_sovits_weights(sovits_path, prompt_language="中文", text_language="中文") and consuming the generator yields exactly 2 events, the button goes disabled → interactive, and the 4th update dict carries value == "中文" from the argument — gradio behavior unchanged.
  • ruff check on the three touched files reports the same 62 pre-existing findings before and after the change (none in the added lines); ruff format --diff output is identical to the pristine file's (all pre-existing).

Note

The GUI call site gets the identical fix; I verified it by code-path identity (same function, same consumption pattern, same arg-less signature) — the runtime evidence above comes from the CLI, which shares the entire loading path.

change_sovits_weights() is a generator function (it yields Gradio update
dicts for the webui), but inference_cli.py and inference_gui.py called it
as a plain statement. The call only built a generator object: the body
never ran, so --sovits_model was silently ignored and synthesis used the
default v2 model loaded at import time (fixes RVC-Boss#2829).

Iterating the generator end-to-end exposed a second latent bug: the
post-load yield references six locals (prompt_text_update,
prompt_language_update, text_update, text_language_update,
visible_sample_steps, visible_inp_refs) that were only assigned when the
webui passes UI language args, so any arg-less call raised
UnboundLocalError at that yield - previously masked by the bare
try/except around the import-time next(). Initialize them with neutral
defaults; the webui path overwrites them unchanged.

Verified on Windows/CPU with v2 pretrained models: a bogus --sovits_model
now fails fast with FileNotFoundError instead of silently using the
default model; a valid path loads (double 'loading sovits_v2' log) and
synthesizes; the webui-style call still yields its two UI events.
@kyo-zzz
kyo-zzz force-pushed the fix/inference-entrypoints-ignored-sovits-weights branch from 51c0e00 to c2a1dec Compare October 11, 2026 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

inference_cli.py never loads the SoVITS model: change_sovits_weights is a generator and is called without being iterated

1 participant