kevinwang676 commited on
Commit
4a1fed3
1 Parent(s): 3ce52de

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -1
app.py CHANGED
@@ -93,7 +93,7 @@ from infer_rvc_python import BaseLoader
93
 
94
  #converter = BaseLoader(only_cpu=True, hubert_path="hubert_base.pt", rmvpe_path="rmvpe.pt")
95
  #converter = BaseLoader(only_cpu=True, hubert_path=None, rmvpe_path=None)
96
-
97
  @spaces.GPU()
98
  def convert_now(audio_files, random_tag, converter):
99
  return converter(
@@ -118,7 +118,38 @@ converter_test.apply_conf(
118
  )
119
 
120
  convert_now("10.wav", "test", converter_test)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
 
 
122
 
123
  def get_file_name(url):
124
  match = re.search(pattern_zip, url)
@@ -533,6 +564,7 @@ def rvc_infer_music(url, model_name, song_name, split_model, f0_up_key, vocal_vo
533
  global singers
534
  if model_name not in singers:
535
  singers = singers+ ' '+ model_name
 
536
  download_online_model(url, model_name)
537
  rvc_models(zip_path)
538
  song_name = song_name.strip().replace(" ", "")
 
93
 
94
  #converter = BaseLoader(only_cpu=True, hubert_path="hubert_base.pt", rmvpe_path="rmvpe.pt")
95
  #converter = BaseLoader(only_cpu=True, hubert_path=None, rmvpe_path=None)
96
+ '''
97
  @spaces.GPU()
98
  def convert_now(audio_files, random_tag, converter):
99
  return converter(
 
118
  )
119
 
120
  convert_now("10.wav", "test", converter_test)
121
+ '''
122
+
123
+ @spaces.GPU()
124
+ def load_hu_bert(config, hubert_path=None):
125
+ global hubert_model
126
+ from fairseq import checkpoint_utils
127
+
128
+ if hubert_path is None:
129
+ hubert_path = ""
130
+ if not os.path.exists(hubert_path):
131
+ for id_model in BASE_MODELS:
132
+ download_manager(
133
+ os.path.join(BASE_DOWNLOAD_LINK, id_model), BASE_DIR
134
+ )
135
+ hubert_path = "hubert_base.pt"
136
+
137
+ models, _, _ = checkpoint_utils.load_model_ensemble_and_task(
138
+ [hubert_path],
139
+ suffix="",
140
+ )
141
+ hubert_model = models[0]
142
+ hubert_model = hubert_model.to(config.device)
143
+ if config.is_half:
144
+ hubert_model = hubert_model.half()
145
+ else:
146
+ hubert_model = hubert_model.float()
147
+ hubert_model.eval()
148
+ print(hubert_model)
149
+
150
+ return hubert_model
151
 
152
+ load_hu_bert(config, None)
153
 
154
  def get_file_name(url):
155
  match = re.search(pattern_zip, url)
 
564
  global singers
565
  if model_name not in singers:
566
  singers = singers+ ' '+ model_name
567
+ print("开始下载模型...")
568
  download_online_model(url, model_name)
569
  rvc_models(zip_path)
570
  song_name = song_name.strip().replace(" ", "")