odettecantswim commited on
Commit
26dc2c8
·
1 Parent(s): 996f78a

Update vc_infer_pipeline.py

Browse files
Files changed (1) hide show
  1. vc_infer_pipeline.py +23 -2
vc_infer_pipeline.py CHANGED
@@ -82,7 +82,28 @@ class VC(object):
82
  f0_max = 1100
83
  f0_mel_min = 1127 * np.log(1 + f0_min / 700)
84
  f0_mel_max = 1127 * np.log(1 + f0_max / 700)
85
- if f0_method == "crepe":
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  model = "full"
87
  # Pick a batch size that doesn't cause memory errors on your gpu
88
  batch_size = 512
@@ -407,4 +428,4 @@ class VC(object):
407
  del pitch, pitchf, sid
408
  if torch.cuda.is_available():
409
  torch.cuda.empty_cache()
410
- return audio_opt
 
82
  f0_max = 1100
83
  f0_mel_min = 1127 * np.log(1 + f0_min / 700)
84
  f0_mel_max = 1127 * np.log(1 + f0_max / 700)
85
+ if f0_method == "pm":
86
+ f0 = (
87
+ parselmouth.Sound(x, self.sr)
88
+ .to_pitch_ac(
89
+ time_step=time_step / 1000,
90
+ voicing_threshold=0.6,
91
+ pitch_floor=f0_min,
92
+ pitch_ceiling=f0_max,
93
+ )
94
+ .selected_array["frequency"]
95
+ )
96
+ pad_size = (p_len - len(f0) + 1) // 2
97
+ if pad_size > 0 or p_len - len(f0) - pad_size > 0:
98
+ f0 = np.pad(
99
+ f0, [[pad_size, p_len - len(f0) - pad_size]], mode="constant"
100
+ )
101
+ elif f0_method == "harvest":
102
+ input_audio_path2wav[input_audio_path] = x.astype(np.double)
103
+ f0 = cache_harvest_f0(input_audio_path, self.sr, f0_max, f0_min, 10)
104
+ if filter_radius > 2:
105
+ f0 = signal.medfilt(f0, 3)
106
+ elif f0_method == "crepe":
107
  model = "full"
108
  # Pick a batch size that doesn't cause memory errors on your gpu
109
  batch_size = 512
 
428
  del pitch, pitchf, sid
429
  if torch.cuda.is_available():
430
  torch.cuda.empty_cache()
431
+ return audio_opt