{"record":{"id":"021464d1e46ce70c","repo":"CorentinJ/Real-Time-Voice-Cloning","slug":"please-load-wave-rnn-in-memory-before-using-it","errorCode":null,"errorMessage":"Please load Wave-RNN in memory before using it","messagePattern":"Please load Wave-RNN in memory before using it","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"vocoder/inference.py","lineNumber":58,"sourceCode":"\ndef is_loaded():\n    return _model is not None\n\n\ndef infer_waveform(mel, normalize=True,  batched=True, target=8000, overlap=800, \n                   progress_callback=None):\n    \"\"\"\n    Infers the waveform of a mel spectrogram output by the synthesizer (the format must match \n    that of the synthesizer!)\n    \n    :param normalize:  \n    :param batched: \n    :param target: \n    :param overlap: \n    :return: \n    \"\"\"\n    if _model is None:\n        raise Exception(\"Please load Wave-RNN in memory before using it\")\n    \n    if normalize:\n        mel = mel / hp.mel_max_abs_value\n    mel = torch.from_numpy(mel[None, ...])\n    wav = _model.generate(mel, batched, target, overlap, hp.mu_law, progress_callback)\n    return wav\n","sourceCodeStart":40,"sourceCodeEnd":65,"githubUrl":"https://github.com/CorentinJ/Real-Time-Voice-Cloning/blob/890f3a03187195b9829db2079b75c2ba2ab0405c/vocoder/inference.py#L40-L65","documentation":"Raised by infer_waveform() in vocoder/inference.py when the module-level _model singleton is None. Like the encoder (error 3), the vocoder inference API is stateful: load_model(models_dir, model_fpath, _) must populate _model before generation. The guard is a bare None check on the WaveRNN instance, so any path that reaches infer_waveform without a successful load fails here.","triggerScenarios":"Calling infer_waveform(mel) directly, or via the toolbox/demo_cli synthesis flow, without a prior vocoder load_model(); also when the toolbox is configured with the Griffin-Lim fallback (vocoder_fpath None) and code nevertheless calls infer_waveform instead of the Griffin-Lim path.","commonSituations":"New integration code that skips the vocoder load step; a load_model failure (missing vocoder.pt, CUDA OOM) swallowed earlier; notebook reuse after an exception during load; mixing WaveRNN inference into a script that only loaded the synthesizer.","solutions":["Call vocoder.inference.load_model(Path(\"<models_dir>/<name>/vocoder.pt\")) once before infer_waveform().","If load_model itself failed, fix that first (verify the vocoder.pt path exists under the models dir you passed).","In toolbox flows, when the vocoder box shows Griffin-Lim, ensure the code routes to the Griffin-Lim vocoder path rather than infer_waveform."],"exampleFix":"# before\nfrom vocoder import inference\nwav = inference.infer_waveform(mel)  # _model is None -> raises\n\n# after\nfrom vocoder import inference\nfrom pathlib import Path\ninference.load_model(Path(\"vocoder/saved_models/pretrained/vocoder.pt\"))\nwav = inference.infer_waveform(mel)","handlingStrategy":"validation","validationCode":"from vocoder import inference\nfrom pathlib import Path\n\ndef ensure_vocoder_loaded(models_dir: Path, fpath: Path):\n    if inference._model is None:\n        inference.load_model(models_dir, fpath, False)","typeGuard":null,"tryCatchPattern":"try:\n    wav = inference.infer_waveform(mel)\nexcept Exception as e:\n    if \"Wave-RNN\" in str(e):\n        inference.load_model(Path(\"vocoder/saved_models/pretrained\"), Path(\"vocoder/saved_models/pretrained/vocoder.pt\"), False)\n        wav = inference.infer_waveform(mel)\n    else:\n        raise","preventionTips":["Load encoder, synthesizer, and vocoder in one init routine and assert each is loaded before serving.","When the toolbox vocoder selection is Griffin-Lim (None), route to the Griffin-Lim code path instead of infer_waveform.","Fail loudly on load_model errors instead of continuing into generation."],"tags":["vocoder","inference","model-loading","state"],"backgroundTag":null,"analyzedSha":"890f3a03187195b9829db2079b75c2ba2ab0405c","analyzedAt":"2026-08-15T02:15:13.202Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}