RVC-Boss/GPT-SoVITS · error · ValueError

The following condition must be satisfied: max_sil_kept >= h

Error message

The following condition must be satisfied: max_sil_kept >= hop_size

What it means

Companion invariant in Slicer.__init__: max_sil_kept must be >= hop_size. max_sil_kept caps how much silence a slice may retain; the silence detector steps in hop_size units, so if the step were larger than the kept-silence budget the detector could never express its intended retention and rounding would degenerate. The constructor validates it right after the min_length/min_interval/hop_size check.

Source

Thrown at tools/slicer2.py:51

    power = np.mean(np.abs(x) ** 2, axis=-2, keepdims=True)

    return np.sqrt(power)


class Slicer:
    def __init__(
        self,
        sr: int,
        threshold: float = -40.0,
        min_length: int = 5000,
        min_interval: int = 300,
        hop_size: int = 20,
        max_sil_kept: int = 5000,
    ):
        if not min_length >= min_interval >= hop_size:
            raise ValueError("The following condition must be satisfied: min_length >= min_interval >= hop_size")
        if not max_sil_kept >= hop_size:
            raise ValueError("The following condition must be satisfied: max_sil_kept >= hop_size")
        min_interval = sr * min_interval / 1000
        self.threshold = 10 ** (threshold / 20.0)
        self.hop_size = round(sr * hop_size / 1000)
        self.win_size = min(round(min_interval), 4 * self.hop_size)
        self.min_length = round(sr * min_length / 1000 / self.hop_size)
        self.min_interval = round(min_interval / self.hop_size)
        self.max_sil_kept = round(sr * max_sil_kept / 1000 / self.hop_size)

    def _apply_slice(self, waveform, begin, end):
        if len(waveform.shape) > 1:
            return waveform[:, begin * self.hop_size : min(waveform.shape[1], end * self.hop_size)]
        else:
            return waveform[begin * self.hop_size : min(waveform.shape[0], end * self.hop_size)]

    # @timeit
    def slice(self, waveform):
        if len(waveform.shape) > 1:
            samples = waveform.mean(axis=0)

View on GitHub (pinned to d523079fc0)

Solutions

  1. Keep max_sil_kept >= hop_size (defaults: 5000 >= 20 ms).
  2. If you raised hop_size, raise max_sil_kept at least to that value — ideally several multiples.
  3. If you want near-zero retained silence, lower hop_size instead of max_sil_kept below it.
  4. Add a shared parameter-validator/clamp in config-loading code so both slicer invariants are checked together.

Example fix

# before
slicer = Slicer(32000, hop_size=100, max_sil_kept=50)  # ValueError

# after
hop = 100
slicer = Slicer(32000, hop_size=hop, max_sil_kept=max(hop, 50))  # or a sane 5*hop
Defensive patterns

Strategy: validation

Validate before calling

max_sil_kept = max(max_sil_kept, hop_size)
slicer = Slicer(sr, hop_size=hop_size, max_sil_kept=max_sil_kept, ...)

Type guard

def valid_slicer_silence(max_sil_kept: int, hop_size: int) -> bool:
    return max_sil_kept >= hop_size

Prevention

When it happens

Trigger: Constructing Slicer with max_sil_kept < hop_size, e.g. Slicer(32000, hop_size=100, max_sil_kept=50) — a big analysis hop combined with a small silence-retention cap.

Common situations: Tuning for minimal retained silence (tiny max_sil_kept) while simultaneously raising hop_size for speed; hand-edited YAML/JSON configs where the two fields are tuned independently.

Related errors


AI-assisted analysis of RVC-Boss/GPT-SoVITS@d523079fc0 (2026-08-15). Data as JSON: /api/errors/639ef5da9d8d3663. Report an issue: GitHub.