mirror of
https://github.com/storytold/storyteller-ml.git
synced 2026-10-17 00:23:14 +00:00
add lots of logging
This commit is contained in:
@@ -238,6 +238,9 @@ def infer(
|
||||
config_path = Path(config_path)
|
||||
if cluster_model_path is not None:
|
||||
cluster_model_path = Path(cluster_model_path)
|
||||
|
||||
LOG.info("Calling infer()...")
|
||||
|
||||
infer(
|
||||
input_path=input_path,
|
||||
output_path=output_path,
|
||||
|
||||
@@ -111,22 +111,45 @@ class Svc:
|
||||
else:
|
||||
self.dev = torch.device(device)
|
||||
self.net_g_ms = None
|
||||
|
||||
LOG.info("Calling utils.get_hparams_from_file() ...")
|
||||
|
||||
self.hps_ms = utils.get_hparams_from_file(config_path)
|
||||
self.target_sample = self.hps_ms.data.sampling_rate
|
||||
self.hop_size = self.hps_ms.data.hop_length
|
||||
self.spk2id = self.hps_ms.spk
|
||||
|
||||
LOG.info("setting self.hubert_model = utils.get_hubert_model() ... ")
|
||||
self.hubert_model = utils.get_hubert_model().to(self.dev)
|
||||
|
||||
LOG.info("done setting self.hubert_model = utils.get_hubert_model() ... ")
|
||||
|
||||
LOG.info("Calling self.load_model() ...")
|
||||
|
||||
self.load_model()
|
||||
|
||||
LOG.info("Done with: Calling self.load_model() ...")
|
||||
|
||||
if cluster_model_path is not None and Path(cluster_model_path).exists():
|
||||
LOG.warn("cluster.get_cluster_model() ... ")
|
||||
|
||||
self.cluster_model = cluster.get_cluster_model(cluster_model_path)
|
||||
|
||||
LOG.warn("done with: cluster.get_cluster_model() ... ")
|
||||
|
||||
def load_model(self):
|
||||
self.net_g_ms = SynthesizerTrn(
|
||||
self.hps_ms.data.filter_length // 2 + 1,
|
||||
self.hps_ms.train.segment_size // self.hps_ms.data.hop_length,
|
||||
**self.hps_ms.model,
|
||||
)
|
||||
|
||||
LOG.warn("load_model() -> utils.load_checkpoint() ... ")
|
||||
|
||||
_ = utils.load_checkpoint(self.net_g_path, self.net_g_ms, None)
|
||||
|
||||
LOG.warn("done with: load_model() -> utils.load_checkpoint() ... ")
|
||||
|
||||
if "half" in self.net_g_path and torch.cuda.is_available():
|
||||
_ = self.net_g_ms.half().eval().to(self.dev)
|
||||
else:
|
||||
@@ -260,6 +283,9 @@ class Svc:
|
||||
)
|
||||
// 2
|
||||
)
|
||||
|
||||
LOG.info("LOOP: for chunk in split_silence() ... ")
|
||||
|
||||
for chunk in split_silence(
|
||||
audio,
|
||||
top_db=-db_thresh,
|
||||
@@ -280,6 +306,9 @@ class Svc:
|
||||
np.zeros([pad_len], dtype=np.float32),
|
||||
]
|
||||
)
|
||||
|
||||
LOG.info("self.infer() [inside loop]")
|
||||
|
||||
audio_chunk_pad_infer_tensor, _ = self.infer(
|
||||
speaker,
|
||||
transpose,
|
||||
|
||||
@@ -44,6 +44,9 @@ def infer(
|
||||
input_path = Path(input_path)
|
||||
config_path = Path(config_path)
|
||||
cluster_model_path = Path(cluster_model_path) if cluster_model_path else None
|
||||
|
||||
LOG.info("Calling Svc()...")
|
||||
|
||||
svc_model = Svc(
|
||||
net_g_path=model_path.as_posix(),
|
||||
config_path=config_path.as_posix(),
|
||||
@@ -53,7 +56,12 @@ def infer(
|
||||
device=device,
|
||||
)
|
||||
|
||||
LOG.info("Calling librosa.load()...")
|
||||
|
||||
audio, _ = librosa.load(input_path, sr=svc_model.target_sample)
|
||||
|
||||
LOG.info("Calling svc_model.infer_silence()...")
|
||||
|
||||
audio = svc_model.infer_silence(
|
||||
audio.astype(np.float32),
|
||||
speaker=speaker,
|
||||
@@ -68,6 +76,8 @@ def infer(
|
||||
absolute_thresh=absolute_thresh,
|
||||
)
|
||||
|
||||
LOG.info("Calling soundfile.write()...")
|
||||
|
||||
soundfile.write(output_path, audio, svc_model.target_sample)
|
||||
|
||||
|
||||
|
||||
@@ -330,20 +330,33 @@ def ensure_hubert_model() -> Path:
|
||||
if not vec_path.exists():
|
||||
# url = "http://obs.cstcloud.cn/share/obs/sankagenkeshi/checkpoint_best_legacy_500.pt"
|
||||
# url = "https://huggingface.co/innnky/contentvec/resolve/main/checkpoint_best_legacy_500.pt"
|
||||
|
||||
LOG.warn("DOWNLOADING HUBERT! NOT ON FILESYSTEM!")
|
||||
LOG.warn("download_file() ...")
|
||||
|
||||
url = "https://huggingface.co/therealvul/so-vits-svc-4.0-init/resolve/main/checkpoint_best_legacy_500.pt"
|
||||
download_file(url, vec_path, desc="Downloading Hubert model")
|
||||
|
||||
LOG.warn("done with download_file()")
|
||||
|
||||
return vec_path
|
||||
|
||||
|
||||
def get_hubert_model():
|
||||
LOG.warn("ensure_hubert_model() ... ")
|
||||
|
||||
vec_path = ensure_hubert_model()
|
||||
from fairseq import checkpoint_utils
|
||||
|
||||
LOG.warn("checkpoint_utils.load_model_ensemble_and_task() ... ")
|
||||
|
||||
models, saved_cfg, task = checkpoint_utils.load_model_ensemble_and_task(
|
||||
[vec_path.as_posix()],
|
||||
suffix="",
|
||||
)
|
||||
model = models[0]
|
||||
|
||||
LOG.warn("model.eval() ... ")
|
||||
model.eval()
|
||||
return model
|
||||
|
||||
|
||||
Reference in New Issue
Block a user