Retrieval-based-Voice-Conversion-WebUI icon indicating copy to clipboard operation
Retrieval-based-Voice-Conversion-WebUI copied to clipboard

AttributeError: 'RVC' object has no attribute 'tgt_sr'

Open ghost opened this issue 1 year ago • 12 comments

i get a crash and this error when starting the voice conversion:

C:\Users\mouse\Programs\Retrieval-based-Voice-Conversion-WebUI>gui_v1.py
2024-09-19 23:01:44 | INFO | faiss.loader | Loading faiss with AVX2 support.
2024-09-19 23:01:44 | INFO | faiss.loader | Could not load library with AVX2 support due to:
ModuleNotFoundError("No module named 'faiss.swigfaiss_avx2'")
2024-09-19 23:01:44 | INFO | faiss.loader | Loading faiss.
2024-09-19 23:01:44 | INFO | faiss.loader | Successfully loaded faiss.
2024-09-19 23:01:44 | INFO | configs.config | Found GPU NVIDIA GeForce RTX 4060 Ti
2024-09-19 23:01:44 | INFO | configs.config | Half-precision floating-point: True, device: cuda:0
Input device: 1:CABLE Output (VB-Audio Virtual
Output device: 4:Headphones (UC USB Headset)
cuda_is_available: True
Traceback (most recent call last):
  File "C:\Users\mouse\Programs\Retrieval-based-Voice-Conversion-WebUI\infer\lib\rtrvc.py", line 99, in __init__
    models, _, _ = fairseq.checkpoint_utils.load_model_ensemble_and_task(
  File "C:\Users\mouse\AppData\Roaming\Python\Python310\site-packages\fairseq\checkpoint_utils.py", line 423, in load_model_ensemble_and_task
    raise IOError("Model file not found: {}".format(filename))
OSError: Model file not found: assets/hubert/hubert_base.pt

Traceback (most recent call last):
  File "C:\Users\mouse\Programs\Retrieval-based-Voice-Conversion-WebUI\gui_v1.py", line 1070, in <module>
    gui = GUI()
  File "C:\Users\mouse\Programs\Retrieval-based-Voice-Conversion-WebUI\gui_v1.py", line 150, in __init__
    self.launcher()
  File "C:\Users\mouse\Programs\Retrieval-based-Voice-Conversion-WebUI\gui_v1.py", line 532, in launcher
    self.event_handler()
  File "C:\Users\mouse\Programs\Retrieval-based-Voice-Conversion-WebUI\gui_v1.py", line 566, in event_handler
    self.start_vc()
  File "C:\Users\mouse\Programs\Retrieval-based-Voice-Conversion-WebUI\gui_v1.py", line 805, in start_vc
    if self.rvc.tgt_sr != self.gui_config.samplerate:
AttributeError: 'RVC' object has no attribute 'tgt_sr'

ghost avatar Sep 20 '24 03:09 ghost

Problem with Gradio version

pin24 avatar Sep 20 '24 16:09 pin24

i'm using the realtime program, not the webui. i don't think that uses gradio. it uses freesimplegui which i had to manually install.

ghost avatar Sep 20 '24 16:09 ghost

I also have the same problem, how do I fix it?

Kelly458 avatar Oct 09 '24 06:10 Kelly458

you probably need to make sure hubert_base.pt is in the assets\hubert\ folder

timwillhack avatar Jan 12 '25 22:01 timwillhack

I'm also having this problem, has it been fixed? is there a solution? I have hubert in assets/hubert/ but it still doesnt work

jurassicjordan avatar Feb 06 '25 21:02 jurassicjordan

does it still say 'SError: Model file not found: assets/hubert/hubert_base.pt'?

timwillhack avatar Feb 06 '25 21:02 timwillhack

does it still say 'SError: Model file not found: assets/hubert/hubert_base.pt'?

no, this is what the output says:

2025-02-06 13:18:45 | INFO | faiss.loader | Loading faiss with AVX2 support.
2025-02-06 13:18:45 | INFO | faiss.loader | Successfully loaded faiss with AVX2 support.
input device:28:Built-in Audio Analog Stereo (JACK Audio Connection Kit)
output device:30:carly-virtualmic Audio/Source/Virtual sink (JACK Audio Connection Kit)
using_cuda:True
load model(s) from /home/jordancruz/Tools/Retrieval-based-Voice-Conversion-WebUI/hubert_base.pt
2025-02-06 13:30:11 | INFO | fairseq.tasks.hubert_pretraining | current directory is /home/jordancruz/Tools/Retrieval-based-Voice-Conversion-WebUI
2025-02-06 13:30:11 | INFO | fairseq.tasks.hubert_pretraining | HubertPretrainingTask Config {'_name': 'hubert_pretraining', 'data': 'metadata', 'fine_tuning': False, 'labels': ['km'], 'label_dir': 'label', 'label_rate': 50.0, 'sample_rate': 16000, 'normalize': False, 'enable_padding': False, 'max_keep_size': None, 'max_sample_size': 250000, 'min_sample_size': 32000, 'single_target': False, 'random_crop': True, 'pad_audio': False}
2025-02-06 13:30:11 | INFO | fairseq.models.hubert.hubert | HubertModel Config: {'_name': 'hubert', 'label_rate': 50.0, 'extractor_mode': default, 'encoder_layers': 12, 'encoder_embed_dim': 768, 'encoder_ffn_embed_dim': 3072, 'encoder_attention_heads': 12, 'activation_fn': gelu, 'layer_type': transformer, 'dropout': 0.1, 'attention_dropout': 0.1, 'activation_dropout': 0.0, 'encoder_layerdrop': 0.05, 'dropout_input': 0.1, 'dropout_features': 0.1, 'final_dim': 256, 'untie_final_proj': True, 'layer_norm_first': False, 'conv_feature_layers': '[(512,10,5)] + [(512,3,2)] * 4 + [(512,2,2)] * 2', 'conv_bias': False, 'logit_temp': 0.1, 'target_glu': False, 'feature_grad_mult': 0.1, 'mask_length': 10, 'mask_prob': 0.8, 'mask_selection': static, 'mask_other': 0.0, 'no_mask_overlap': False, 'mask_min_space': 1, 'mask_channel_length': 10, 'mask_channel_prob': 0.0, 'mask_channel_selection': static, 'mask_channel_other': 0.0, 'no_mask_channel_overlap': False, 'mask_channel_min_space': 1, 'conv_pos': 128, 'conv_pos_groups': 16, 'latent_temp': [2.0, 0.5, 0.999995], 'skip_masked': False, 'skip_nomask': False, 'checkpoint_activations': False, 'required_seq_len_multiple': 2, 'depthwise_conv_kernel_size': 31, 'attn_type': '', 'pos_enc_type': 'abs', 'fp16': False}
Traceback (most recent call last):
  File "/home/jordancruz/Tools/Retrieval-based-Voice-Conversion-WebUI/gui.py", line 83, in __init__
    self.tgt_sr = cpt["config"][-1]
KeyError: 'config'

Traceback (most recent call last):
  File "/home/jordancruz/Tools/Retrieval-based-Voice-Conversion-WebUI/gui.py", line 681, in <module>
    gui = GUI()
  File "/home/jordancruz/Tools/Retrieval-based-Voice-Conversion-WebUI/gui.py", line 254, in __init__
    self.launcher()
  File "/home/jordancruz/Tools/Retrieval-based-Voice-Conversion-WebUI/gui.py", line 442, in launcher
    self.event_handler()
  File "/home/jordancruz/Tools/Retrieval-based-Voice-Conversion-WebUI/gui.py", line 453, in event_handler
    self.start_vc()
  File "/home/jordancruz/Tools/Retrieval-based-Voice-Conversion-WebUI/gui.py", line 524, in start_vc
    orig_freq=self.rvc.tgt_sr,

jurassicjordan avatar Feb 06 '25 21:02 jurassicjordan

I have encountered similar issue, as I download and use the RVC1006Nvidia.7z, I got the error

Traceback (most recent call last):
  File "E:\gitrepos\RVC1006Nvidia\gui_v1.py", line 874, in <module>
    gui = GUI()

  File "E:\gitrepos\RVC1006Nvidia\gui_v1.py", line 114, in __init__
    self.launcher()

  File "E:\gitrepos\RVC1006Nvidia\gui_v1.py", line 400, in launcher
    self.event_handler()

  File "E:\gitrepos\RVC1006Nvidia\gui_v1.py", line 431, in event_handler
    self.start_vc()

  File "E:\gitrepos\RVC1006Nvidia\gui_v1.py", line 558, in start_vc
    self.gui_config.samplerate = self.rvc.tgt_sr

I seems to be related to the sample rate and there are totally no definition on the tgr_sr

def start_vc(self):
            torch.cuda.empty_cache()
            self.flag_vc = True
            self.rvc = rvc_for_realtime.RVC(
                self.gui_config.pitch,
                self.gui_config.pth_path,
                self.gui_config.index_path,
                self.gui_config.index_rate,
                self.gui_config.n_cpu,
                inp_q,
                opt_q,
                self.config,
                self.rvc if hasattr(self, "rvc") else None,
            )
            self.gui_config.samplerate = self.rvc.tgt_sr

The as you can see here the rvc class is defined right above it and never actually defined...., not sure if the creator of this version ever tested it,

The code is different in the current master branch, however I still not sure if it will ever work

Daniel53245 avatar Feb 27 '25 12:02 Daniel53245

The whole try in the RVC class, init when into except branch so the tgt_sr attr didn't get init properly. I think in your case is because the pt file didn't get downloaded

OSError: Model file not found: assets/hubert/hubert_base.pt, just download it and see what happens

960ptou avatar Apr 14 '25 19:04 960ptou

The whole try in the RVC class, init when into except branch so the tgt_sr attr didn't get init properly. I think in your case is because the pt file didn't get downloaded

OSError: Model file not found: assets/hubert/hubert_base.pt, just download it and see what happens

Hello, hubert_base.pt is already downloaded for me but the error stands

maxingan2412 avatar Apr 15 '25 23:04 maxingan2412

The whole try in the RVC class, init when into except branch so the tgt_sr attr didn't get init properly. I think in your case is because the pt file didn't get downloaded OSError: Model file not found: assets/hubert/hubert_base.pt, just download it and see what happens

Hello, hubert_base.pt is already downloaded for me but the error stands

The resulting error is the same, but the cause might be different, can u send your complete log?

  • I actually see this error due to pytorch version being 2.6 and run back to 2.51 which fixed it.

960ptou avatar Apr 15 '25 23:04 960ptou

The whole try in the RVC class, init when into except branch so the tgt_sr attr didn't get init properly. I think in your case is because the pt file didn't get downloaded OSError: Model file not found: assets/hubert/hubert_base.pt, just download it and see what happens

Hello, hubert_base.pt is already downloaded for me but the error stands

The resulting error is the same, but the cause might be different, can u send your complete log?

  • I actually see this error due to pytorch version being 2.6 and run back to 2.51 which fixed it.

Ty it's got fixed after run back to 2.51!

maxingan2412 avatar Apr 16 '25 18:04 maxingan2412

You may try #2574

haofanurusai avatar May 31 '25 03:05 haofanurusai