optimize(vc): use np.divide instead of general /

This commit is contained in:
源文雨 2024-06-02 01:24:43 +09:00
parent 2991e75fc0
commit 7e8c3530d4
3 changed files with 5 additions and 2 deletions

View File

@ -146,7 +146,7 @@ class Config:
self.preprocess_per = 3.0 self.preprocess_per = 3.0
logger.info("overwrite preprocess_per to %d" % (self.preprocess_per)) 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 torch.cuda.is_available():
if self.has_xpu(): if self.has_xpu():
self.device = self.instead = "xpu:0" self.device = self.instead = "xpu:0"

View File

@ -163,7 +163,7 @@ class VC:
audio = load_audio(input_audio_path, 16000) audio = load_audio(input_audio_path, 16000)
audio_max = np.abs(audio).max() / 0.95 audio_max = np.abs(audio).max() / 0.95
if audio_max > 1: if audio_max > 1:
audio /= audio_max np.divide(audio, audio_max, audio)
times = [0, 0, 0] times = [0, 0, 0]
if self.hubert_model is None: if self.hubert_model is None:

View File

@ -2,6 +2,8 @@ import os
from fairseq import checkpoint_utils from fairseq import checkpoint_utils
from configs.config import singleton_variable
def get_index_path_from_model(sid): def get_index_path_from_model(sid):
return next( return next(
@ -20,6 +22,7 @@ def get_index_path_from_model(sid):
) )
@singleton_variable
def load_hubert(device, is_half): def load_hubert(device, is_half):
models, _, _ = checkpoint_utils.load_model_ensemble_and_task( models, _, _ = checkpoint_utils.load_model_ensemble_and_task(
["assets/hubert/hubert_base.pt"], ["assets/hubert/hubert_base.pt"],