RVC-Boss/GPT-SoVITS · error · RuntimeError
SoVits V3/4模型不支持流式推理模式
Error message
SoVits V3/4模型不支持流式推理模式
What it means
RuntimeError raised in the streaming decode branch when the loaded vits_model has no decode_streaming capability but streaming was requested. SoVITS v3/v4 use a different vocoder architecture whose decoder cannot do chunked streaming generation, so only v1/v2 (25hz/non-25hz classic) models support streaming; requesting it with v3/v4 hits the else-branch and raises.
Source
Thrown at GPT_SoVITS/TTS_infer_pack/TTS.py:1442
# token_padding_length = int(phones.shape[-1]*2)-_semantic_tokens.shape[-1]
# if token_padding_length>0:
# _semantic_tokens = F.pad(_semantic_tokens, (0, token_padding_length), "constant", 486)
# else:
# token_padding_length = 0
audio_chunk, latent, latent_mask = self.vits_model.decode_streaming(
_semantic_tokens.unsqueeze(0),
phones, refer_audio_spec,
speed=speed_factor,
sv_emb=sv_emb,
result_length=semantic_tokens.shape[-1]+overlap_len if not is_first_chunk else None,
overlap_frames=last_latent[:,:,-overlap_len*(2 if self.vits_model.semantic_frame_rate == "25hz" else 1):] \
if last_latent is not None else None,
padding_length=token_padding_length
)
audio_chunk=audio_chunk.detach()[0, 0, :]
else:
raise RuntimeError(i18n("SoVits V3/4模型不支持流式推理模式"))
if overlap_len>overlap_length:
audio_chunk=audio_chunk[-int((overlap_length+semantic_tokens.shape[-1])*upsample_rate):]
audio_chunk_ = audio_chunk
if is_first_chunk and not is_final:
is_first_chunk = False
audio_chunk_ = audio_chunk_[:-overlap_size]
elif is_first_chunk and is_final:
is_first_chunk = False
elif not is_first_chunk and not is_final:
audio_chunk_ = self.sola_algorithm([last_audio_chunk, audio_chunk_], overlap_size)
audio_chunk_ = (
audio_chunk_[last_audio_chunk.shape[0]-overlap_size:-overlap_size] if not is_final \
else audio_chunk_[last_audio_chunk.shape[0]-overlap_size:]
)
last_latent = latentView on GitHub (pinned to d523079fc0)
Solutions
- Switch to a v1 or v2 SoVITS model if streaming/realtime output is a hard requirement.
- Or disable streaming (return_finished_audio=True / stream=False) so inference falls back to full-clip generation even with v3/v4.
- If you build a client, probe model capability (check model_version or hasattr(model, 'decode_streaming')) before requesting streaming, and fall back to non-streaming automatically.
Example fix
# before
for chunk in handler.run(..., stream=True): # RuntimeError: SoVits V3/4模型不支持流式推理模式
play(chunk)
# after
streaming_ok = getattr(handler.vits_model, "decode_streaming", None) is not None
if streaming_ok:
for chunk in handler.run(..., stream=True):
play(chunk)
else:
play(handler.run(..., return_finished_audio=True)) Defensive patterns
Strategy: type-guard
Validate before calling
streaming_supported = getattr(handler.vits_model, "decode_streaming", None) is not None
if stream_requested and not streaming_supported:
stream_requested = False # fall back to full-clip generation Type guard
def model_supports_streaming(handler) -> bool:
"""v1/v2 sovits expose decode_streaming; v3/v4 do not."""
return getattr(handler.vits_model, "decode_streaming", None) is not None Try / catch
try:
yield from handler.run(..., stream=True)
except RuntimeError as e:
if "不支持流式" in str(e):
yield handler.run(..., return_finished_audio=True)
else:
raise Prevention
- Advertise streaming capability from the server based on the loaded model, and gate client requests on it.
- Keep a v1/v2 checkpoint available if realtime streaming is a product requirement.
- Test streaming immediately after every model switch.
When it happens
Trigger: Calling the streaming inference API (stream=True / the generator variant of run) while a SoVITS v3 or v4 model is loaded — the code calls self.vits_model.decode_streaming only when the attribute exists, otherwise raises RuntimeError with this message.
Common situations: API server configured for streaming responses but user switched the sovits checkpoint to a v3/v4 lora or full model; new deployment copies a streaming example config while shipping v4 weights; client demands realtime chunked audio but the model cannot provide it.
Related errors
- SoVITS %s 底模缺失,无法加载相应 LoRA 权重
- {path_sovits}SoVITS {model_version}底模缺失,无法加载相应 LoRA 权重
- {path_sovits}SoVITS {model_version}底模缺失,无法加载相应 LoRA 权重
- 搜索音频长度 ({search_len}) 必须大于等于参考音频长度 ({ref_len})
AI-assisted analysis of RVC-Boss/GPT-SoVITS@d523079fc0 (2026-08-15).
Data as JSON: /api/errors/5e55cc0399781b28.
Report an issue: GitHub.