babysor/MockingBird · error · Exception
Please load hifi-gan in memory before using it
Error message
Please load hifi-gan in memory before using it
What it means
infer_waveform in models/vocoder/hifigan/inference.py requires the module-global `generator` to be initialized by a prior load_model() call; otherwise it raises immediately.
Source
Thrown at models/vocoder/hifigan/inference.py:63
_device = torch.device('cpu')
generator = Generator(h).to(_device)
state_dict_g = load_checkpoint(
weights_fpath, _device
)
generator.load_state_dict(state_dict_g['generator'])
generator.eval()
generator.remove_weight_norm()
def is_loaded():
return generator is not None
def infer_waveform(mel, progress_callback=None):
if generator is None:
raise Exception("Please load hifi-gan in memory before using it")
mel = torch.FloatTensor(mel).to(_device)
mel = mel.unsqueeze(0)
with torch.no_grad():
y_g_hat = generator(mel)
audio = y_g_hat.squeeze()
audio = audio.cpu().numpy()
return audio, output_sample_rate
View on GitHub (pinned to 28dc5e14f1)
Solutions
- Call hifigan.load_model(weights_fpath) before infer_waveform
- Confirm the .pt/.pth checkpoint path is correct and the file loads
- Guard with is_loaded() before calling
Example fix
# before
wav = hifigan.infer_waveform(mel)
# after
higigan = hifigan.load_model(Path('logs/hifigan/generator_v1'))
wav = hifigan.infer_waveform(mel) Defensive patterns
Strategy: validation
Validate before calling
from models.vocoder import hifigan
if not hifigan.is_loaded():
hifigan.load_model(Path('models/vocoder/hifigan/generator_v1')) Type guard
def hifigan_ready() -> bool:
from models.vocoder.hifigan import inference
return inference.generator is not None Try / catch
try:
wav = hifigan.infer_waveform(mel)
except Exception as e:
if 'load hifi-gan' in str(e):
hifigan.load_model(ckpt); wav = hifigan.infer_waveform(mel)
else: raise Prevention
- Load vocoder weights once at app startup
- Guard with is_loaded() and surface a clear 'loading weights' message in UIs
When it happens
Trigger: Calling infer_waveform(mel) without a preceding successful load_model(...) in the same process.
Common situations: Skipping vocoder init in a custom synthesis script; failed/aborted checkpoint load; toolbox configured with missing hifgan weights.
Related errors
- Please load fre-gan in memory before using it
- Please load Wave-RNN in memory before using it
- Package 'webrtcvad' not found. This package enables noise re
- Model folder {VOC_MODELS_DIRT} doesn't exist.
- Model folder {VOC_MODELS_DIRT} doesn't exist.
AI-assisted analysis of babysor/MockingBird@28dc5e14f1 (2026-08-27).
Data as JSON: /api/errors/cfc778b36a963015.
Report an issue: GitHub.