CorentinJ/Real-Time-Voice-Cloning · error · RuntimeError

Unknown model mode value -

Error message

Unknown model mode value - 

What it means

Raised in WaveRNN.generate() (vocoder/models/fatchord_version.py) during the sample loop when self.mode is neither 'MOL' (mixture of logistics) nor 'RAW' (categorical softmax). The mode is baked into the model object — set from hparams / the class-string of the loaded weights — and determines how network logits are turned into audio samples. Note the bug-shaped message: RuntimeError("Unknown model mode value - ", self.mode) passes the mode as a separate arg instead of formatting it, so the printed message never shows the offending value.

Source

Thrown at vocoder/models/fatchord_version.py:230

                if self.mode == 'MOL':
                    sample = sample_from_discretized_mix_logistic(logits.unsqueeze(0).transpose(1, 2))
                    output.append(sample.view(-1))
                    if torch.cuda.is_available():
                        # x = torch.FloatTensor([[sample]]).cuda()
                        x = sample.transpose(0, 1).cuda()
                    else:
                        x = sample.transpose(0, 1)

                elif self.mode == 'RAW' :
                    posterior = F.softmax(logits, dim=1)
                    distrib = torch.distributions.Categorical(posterior)

                    sample = 2 * distrib.sample().float() / (self.n_classes - 1.) - 1.
                    output.append(sample)
                    x = sample.unsqueeze(-1)
                else:
                    raise RuntimeError("Unknown model mode value - ", self.mode)

                if i % 100 == 0:
                    gen_rate = (i + 1) / (time.time() - start) * b_size / 1000
                    progress_callback(i, seq_len, b_size, gen_rate)

        output = torch.stack(output).transpose(0, 1)
        output = output.cpu().numpy()
        output = output.astype(np.float64)
        
        if batched:
            output = self.xfade_and_unfold(output, target, overlap)
        else:
            output = output[0]

        if mu_law:
            output = decode_mu_law(output, self.n_classes, False)
        if hp.apply_preemphasis:
            output = de_emphasis(output)

View on GitHub (pinned to 890f3a0318)

Solutions

  1. Align the mode with the checkpoint: if using the standard pretrained vocoder, keep the repository's default hparams (which set the correct mode) instead of overriding them.
  2. Inspect the mode before generating: print(_model.mode) — it must be exactly 'MOL' or 'RAW' (uppercase).
  3. If loading custom weights, set the mode argument at WaveRNN construction / load_model to match how those weights were trained.
  4. As a quick sanity check, load with the unmodified repo hparams first; only customize after generation works.

Example fix

# before: checkpoint trained in MOL, hparams forced to RAW
hp.vocoder_mode = 'RAW'  # ... later: RuntimeError: Unknown model mode value -

# after
hp.vocoder_mode = 'MOL'  # match the checkpoint's training mode; print(model.mode) to confirm
Defensive patterns

Strategy: validation

Validate before calling

def valid_wavernn_mode(mode) -> bool:
    return mode in ("MOL", "RAW")

# before generate(): assert valid_wavernn_mode(model.mode), model.mode

Type guard

def is_wavernn_mode(m) -> bool:
    return m in ("MOL", "RAW")

Try / catch

try:
    wav = model.generate(mel, batched, target, overlap, mu_law)
except RuntimeError as e:
    if "Unknown model mode" in str(e):
        raise RuntimeError(f"model.mode={model.mode!r} invalid; load with mode MOL/RAW matching the checkpoint") from e
    raise

Prevention

When it happens

Trigger: Loading a vocoder checkpoint whose training mode disagrees with the mode the runtime assigns (e.g. MOL-trained weights generated with mode 'RAW'), or constructing WaveRNN manually and passing an invalid mode string. The mismatch usually surfaces only at generate() time, not at load time.

Common situations: Using a pretrained vocoder with hparams (vocoder_mode / class-based hp.vocoder_mode) that differ from the checkpoint's training config; editing hparams between train and inference; third-party WaveRNN weights with a nonstandard mode string; typos like 'Mol' or 'raw'.

Related errors


AI-assisted analysis of CorentinJ/Real-Time-Voice-Cloning@890f3a0318 (2026-08-15). Data as JSON: /api/errors/5a4edf0da921ba97. Report an issue: GitHub.