AIFSH / ComfyUI-GPT_SoVITS

a comfyui custom node for GPT-SoVITS! you can voice cloning and tts in comfyui now
Other
161 stars 14 forks source link

Fixed compatibility to load checkpoint trained by original GPT_SoVITS repo, added .gitignore and removed *.pyc files #16

Open BXYMartin opened 2 months ago

BXYMartin commented 2 months ago

I was trying to load some checkpoints I trained from original repo but got an error with traceback

  File "/home/bxymartin/Documents/Projects/ComfyUI/custom_nodes/ComfyUI-GPT_SoVITS/nodes.py", line 103, in get_tts_wav                                                                                             
    get_tts_wav(renfer_audio,prompt_text,prompt_language,                                                                                                                                                          
  File "/home/bxymartin/Documents/Projects/ComfyUI/custom_nodes/ComfyUI-GPT_SoVITS/inference.py", line 122, in get_tts_wav                                                                                         
    vq_model, hps = change_sovits_weights(sovits_weight)                                                                                                                                                           
  File "/home/bxymartin/Documents/Projects/ComfyUI/custom_nodes/ComfyUI-GPT_SoVITS/inference.py", line 78, in change_sovits_weights                                                                                
    dict_s2 = torch.load(sovits_path, map_location="cpu")                                                                                                                                                            File "/home/bxymartin/.pyenv/versions/3.10.10/lib/python3.10/site-packages/torch/serialization.py", line 1025, in load                                                                                           
    return _load(opened_zipfile,                                                                                                                                                                                   
  File "/home/bxymartin/.pyenv/versions/3.10.10/lib/python3.10/site-packages/torch/serialization.py", line 1447, in _load                                                                                          
    result = unpickler.load()                                                                                                                                                                                      
  File "/home/bxymartin/.pyenv/versions/3.10.10/lib/python3.10/site-packages/torch/serialization.py", line 1440, in find_class                                                                                     
    return super().find_class(mod_name, name)
AttributeError: Can't get attribute 'HParams' on <module 'utils' from '/home/bxymartin/Documents/Projects/ComfyUI/comfy/utils.py'>

This is because we have moved the original modules inside the folder and we are having a conflict with comfy/utils.py from ComfyUI and failed to locate the one in GPT_SoVITS/utils.py where it has the definition for HParams module. A simple fix would be to patch the utils entry in sys.module and revert it afterwards.