From 7e8c3530d4463e62b49e74956b92e033ad807e7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sun, 2 Jun 2024 01:24:43 +0900 Subject: [PATCH] optimize(vc): use np.divide instead of general `/` --- configs/config.py | 2 +- infer/modules/vc/modules.py | 2 +- infer/modules/vc/utils.py | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/configs/config.py b/configs/config.py index c8aaff6..50c63f0 100644 --- a/configs/config.py +++ b/configs/config.py @@ -146,7 +146,7 @@ class Config: self.preprocess_per = 3.0 logger.info("overwrite preprocess_per to %d" % (self.preprocess_per)) - def device_config(self) -> tuple: + def device_config(self): if torch.cuda.is_available(): if self.has_xpu(): self.device = self.instead = "xpu:0" diff --git a/infer/modules/vc/modules.py b/infer/modules/vc/modules.py index 9fdf6cc..e739c9f 100644 --- a/infer/modules/vc/modules.py +++ b/infer/modules/vc/modules.py @@ -163,7 +163,7 @@ class VC: audio = load_audio(input_audio_path, 16000) audio_max = np.abs(audio).max() / 0.95 if audio_max > 1: - audio /= audio_max + np.divide(audio, audio_max, audio) times = [0, 0, 0] if self.hubert_model is None: diff --git a/infer/modules/vc/utils.py b/infer/modules/vc/utils.py index 0df05f6..5b9e765 100644 --- a/infer/modules/vc/utils.py +++ b/infer/modules/vc/utils.py @@ -2,6 +2,8 @@ import os from fairseq import checkpoint_utils +from configs.config import singleton_variable + def get_index_path_from_model(sid): return next( @@ -20,6 +22,7 @@ def get_index_path_from_model(sid): ) +@singleton_variable def load_hubert(device, is_half): models, _, _ = checkpoint_utils.load_model_ensemble_and_task( ["assets/hubert/hubert_base.pt"],