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

feat: normalize audio

This commit is contained in:
源文雨
2024-06-04 22:29:39 +09:00
parent c5d06bd2ec
commit b3215d126c
4 changed files with 7 additions and 10 deletions

View File

@@ -47,6 +47,11 @@ def original_audio_time_minus():
def original_audio_freq_minus(): def original_audio_freq_minus():
return original_audio_storage()["f"] return original_audio_storage()["f"]
@singleton_variable
def original_rmvpe_f0():
x = original_audio_storage()
return x["pitch"], x["pitchf"]
def _cut_u16(n): def _cut_u16(n):
if n > 16384: if n > 16384:
@@ -88,9 +93,6 @@ def wave_hash(time_field):
def model_hash(config, tgt_sr, net_g, if_f0, version): def model_hash(config, tgt_sr, net_g, if_f0, version):
pipeline = Pipeline(tgt_sr, config) pipeline = Pipeline(tgt_sr, config)
audio = original_audio() audio = original_audio()
audio_max = np.abs(audio).max() / 0.95
if audio_max > 1:
np.divide(audio, audio_max, audio)
hbt = load_hubert(config.device, config.is_half) hbt = load_hubert(config.device, config.is_half)
audio_opt = pipeline.pipeline( audio_opt = pipeline.pipeline(
hbt, hbt,
@@ -99,7 +101,7 @@ def model_hash(config, tgt_sr, net_g, if_f0, version):
audio, audio,
[0, 0, 0], [0, 0, 0],
6, 6,
"rmvpe", original_rmvpe_f0(),
"", "",
0, 0,
2 if if_f0 else 0, 2 if if_f0 else 0,

Binary file not shown.

Binary file not shown.

View File

@@ -16,7 +16,6 @@ import pyworld
import torch import torch
import torch.nn.functional as F import torch.nn.functional as F
import torchcrepe import torchcrepe
import pathlib
from scipy import signal from scipy import signal
now_dir = os.getcwd() now_dir = os.getcwd()
@@ -385,12 +384,8 @@ class Pipeline(object):
filter_radius, filter_radius,
inp_f0, inp_f0,
) )
"""
np.savez_compressed(pathlib.Path(__file__).parent / "lgdsng_f0.npz", pitch=pitch, pitchf=pitchf)
"""
elif if_f0 == 2: elif if_f0 == 2:
pitchz = np.load(pathlib.Path(__file__).parent / "lgdsng_f0.npz") pitch, pitchf = f0_method
pitch, pitchf = pitchz["pitch"], pitchz["pitchf"]
pitch = pitch[:p_len] pitch = pitch[:p_len]
pitchf = pitchf[:p_len] pitchf = pitchf[:p_len]
if "mps" not in str(self.device) or "xpu" not in str(self.device): if "mps" not in str(self.device) or "xpu" not in str(self.device):