smjain commited on
Commit
e13b586
1 Parent(s): 972a836

Upload myinfer_latest.py

Browse files
Files changed (1) hide show
  1. myinfer_latest.py +18 -18
myinfer_latest.py CHANGED
@@ -211,7 +211,7 @@ def get_processed_audio(audio_id):
211
 
212
 
213
  def convert_voice(spk_id, input_audio_path, voice_transform,unique_id):
214
- get_vc_safe(spk_id,0.5)
215
  print("*****before makinf call to vc ", unique_id)
216
 
217
 
@@ -380,22 +380,22 @@ def get_vc(sid, to_return_protect0):
380
  if torch.cuda.is_available():
381
  torch.cuda.empty_cache()
382
  ###楼下不这么折腾清理不干净
383
- if_f0 = cpt.get("f0", 1)
384
- version = cpt.get("version", "v1")
385
  if version == "v1":
386
  if if_f0 == 1:
387
  net_g = SynthesizerTrnMs256NSFsid(
388
- *cpt["config"], is_half=config.is_half
389
  )
390
  else:
391
- net_g = SynthesizerTrnMs256NSFsid_nono(*cpt["config"])
392
  elif version == "v2":
393
  if if_f0 == 1:
394
  net_g = SynthesizerTrnMs768NSFsid(
395
- *cpt["config"], is_half=config.is_half
396
  )
397
  else:
398
- net_g = SynthesizerTrnMs768NSFsid_nono(*cpt["config"])
399
  del net_g, cpt
400
  if torch.cuda.is_available():
401
  torch.cuda.empty_cache()
@@ -408,10 +408,10 @@ def get_vc(sid, to_return_protect0):
408
  )
409
  print(f"Loading {sid} model...")
410
  selected_model = sid[:-4]
411
- cpt = torch.load(os.path.join(weight_root, sid), map_location="cpu")
412
- tgt_sr = cpt["config"][-1]
413
- cpt["config"][-3] = cpt["weight"]["emb_g.weight"].shape[0]
414
- if_f0 = cpt.get("f0", 1)
415
  if if_f0 == 0:
416
  to_return_protect0 = {
417
  "visible": False,
@@ -424,26 +424,26 @@ def get_vc(sid, to_return_protect0):
424
  "value": to_return_protect0,
425
  "__type__": "update",
426
  }
427
- version = cpt.get("version", "v1")
428
  if version == "v1":
429
  if if_f0 == 1:
430
- net_g = SynthesizerTrnMs256NSFsid(*cpt["config"], is_half=config.is_half)
431
  else:
432
- net_g = SynthesizerTrnMs256NSFsid_nono(*cpt["config"])
433
  elif version == "v2":
434
  if if_f0 == 1:
435
- net_g = SynthesizerTrnMs768NSFsid(*cpt["config"], is_half=config.is_half)
436
  else:
437
- net_g = SynthesizerTrnMs768NSFsid_nono(*cpt["config"])
438
  del net_g.enc_q
439
- print(net_g.load_state_dict(cpt["weight"], strict=False))
440
  net_g.eval().to(config.device)
441
  if config.is_half:
442
  net_g = net_g.half()
443
  else:
444
  net_g = net_g.float()
445
  vc = VC(tgt_sr, config)
446
- n_spk = cpt["config"][-3]
447
  weights_index = []
448
  for _, _, index_files in os.walk(index_root):
449
  for file in index_files:
 
211
 
212
 
213
  def convert_voice(spk_id, input_audio_path, voice_transform,unique_id):
214
+ get_vc(spk_id,0.5)
215
  print("*****before makinf call to vc ", unique_id)
216
 
217
 
 
380
  if torch.cuda.is_available():
381
  torch.cuda.empty_cache()
382
  ###楼下不这么折腾清理不干净
383
+ if_f0 = cpt[sid].get("f0", 1)
384
+ version = cpt[sid].get("version", "v1")
385
  if version == "v1":
386
  if if_f0 == 1:
387
  net_g = SynthesizerTrnMs256NSFsid(
388
+ *cpt[sid]["config"], is_half=config.is_half
389
  )
390
  else:
391
+ net_g = SynthesizerTrnMs256NSFsid_nono(*cpt[sid]["config"])
392
  elif version == "v2":
393
  if if_f0 == 1:
394
  net_g = SynthesizerTrnMs768NSFsid(
395
+ *cpt[sid]["config"], is_half=config.is_half
396
  )
397
  else:
398
+ net_g = SynthesizerTrnMs768NSFsid_nono(*cpt[sid]["config"])
399
  del net_g, cpt
400
  if torch.cuda.is_available():
401
  torch.cuda.empty_cache()
 
408
  )
409
  print(f"Loading {sid} model...")
410
  selected_model = sid[:-4]
411
+ cpt[sid] = torch.load(os.path.join(weight_root, sid), map_location="cpu")
412
+ tgt_sr = cpt[sid]["config"][-1]
413
+ cpt[sid]["config"][-3] = cpt[sid]["weight"]["emb_g.weight"].shape[0]
414
+ if_f0 = cpt[sid].get("f0", 1)
415
  if if_f0 == 0:
416
  to_return_protect0 = {
417
  "visible": False,
 
424
  "value": to_return_protect0,
425
  "__type__": "update",
426
  }
427
+ version = cpt[sid].get("version", "v1")
428
  if version == "v1":
429
  if if_f0 == 1:
430
+ net_g = SynthesizerTrnMs256NSFsid(*cpt[sid]["config"], is_half=config.is_half)
431
  else:
432
+ net_g = SynthesizerTrnMs256NSFsid_nono(*cpt[sid]["config"])
433
  elif version == "v2":
434
  if if_f0 == 1:
435
+ net_g = SynthesizerTrnMs768NSFsid(*cpt[sid]["config"], is_half=config.is_half)
436
  else:
437
+ net_g = SynthesizerTrnMs768NSFsid_nono(*cpt[sid]["config"])
438
  del net_g.enc_q
439
+ print(net_g.load_state_dict(cpt[sid]["weight"], strict=False))
440
  net_g.eval().to(config.device)
441
  if config.is_half:
442
  net_g = net_g.half()
443
  else:
444
  net_g = net_g.float()
445
  vc = VC(tgt_sr, config)
446
+ n_spk = cpt[sid]["config"][-3]
447
  weights_index = []
448
  for _, _, index_files in os.walk(index_root):
449
  for file in index_files: