1
0
mirror of https://github.com/fumiama/Retrieval-based-Voice-Conversion-WebUI.git synced 2026-06-09 20:40:48 +08:00

fix(vc): replace cache_harvest_f0 with md5 key

This commit is contained in:
源文雨
2024-06-02 01:46:18 +09:00
parent 7e8c3530d4
commit 976869e5fb
2 changed files with 6 additions and 8 deletions

View File

@@ -188,7 +188,6 @@ class VC:
self.net_g, self.net_g,
sid, sid,
audio, audio,
input_audio_path,
times, times,
f0_up_key, f0_up_key,
f0_method, f0_method,

View File

@@ -27,8 +27,8 @@ input_audio_path2wav = {}
@lru_cache @lru_cache
def cache_harvest_f0(input_audio_path, fs, f0max, f0min, frame_period): def cache_harvest_f0(f0_cache_key, fs, f0max, f0min, frame_period):
audio = input_audio_path2wav[input_audio_path] audio = input_audio_path2wav[f0_cache_key]
f0, t = pyworld.harvest( f0, t = pyworld.harvest(
audio, audio,
fs=fs, fs=fs,
@@ -83,7 +83,6 @@ class Pipeline(object):
def get_f0( def get_f0(
self, self,
input_audio_path,
x, x,
p_len, p_len,
f0_up_key, f0_up_key,
@@ -114,8 +113,10 @@ class Pipeline(object):
f0, [[pad_size, p_len - len(f0) - pad_size]], mode="constant" f0, [[pad_size, p_len - len(f0) - pad_size]], mode="constant"
) )
elif f0_method == "harvest": elif f0_method == "harvest":
input_audio_path2wav[input_audio_path] = x.astype(np.double) from hashlib import md5
f0 = cache_harvest_f0(input_audio_path, self.sr, f0_max, f0_min, 10) f0_cache_key = md5(x.tobytes()).digest()
input_audio_path2wav[f0_cache_key] = x.astype(np.double)
f0 = cache_harvest_f0(f0_cache_key, self.sr, f0_max, f0_min, 10)
if filter_radius > 2: if filter_radius > 2:
f0 = signal.medfilt(f0, 3) f0 = signal.medfilt(f0, 3)
elif f0_method == "crepe": elif f0_method == "crepe":
@@ -304,7 +305,6 @@ class Pipeline(object):
net_g, net_g,
sid, sid,
audio, audio,
input_audio_path,
times, times,
f0_up_key, f0_up_key,
f0_method, f0_method,
@@ -372,7 +372,6 @@ class Pipeline(object):
pitch, pitchf = None, None pitch, pitchf = None, None
if if_f0 == 1: if if_f0 == 1:
pitch, pitchf = self.get_f0( pitch, pitchf = self.get_f0(
input_audio_path,
audio_pad, audio_pad,
p_len, p_len,
f0_up_key, f0_up_key,