diff --git a/src/so_vits_svc_fork/gui.py b/src/so_vits_svc_fork/gui.py index 1d58b155..86a533b3 100644 --- a/src/so_vits_svc_fork/gui.py +++ b/src/so_vits_svc_fork/gui.py @@ -86,9 +86,11 @@ def get_supported_file_types() -> tuple[tuple[str, str], ...]: common_file_types = ["WAV", "MP3", "FLAC", "OGG", "M4A", "WMA"] res = sorted( res, - key=lambda x: common_file_types.index(x[0]) - if x[0] in common_file_types - else len(common_file_types), + key=lambda x: ( + common_file_types.index(x[0]) + if x[0] in common_file_types + else len(common_file_types) + ), ) return res @@ -187,15 +189,19 @@ def main(): sg.Push(), sg.InputText( key="model_path", - default_text=model_candidates[-1].absolute().as_posix() - if model_candidates - else "", + default_text=( + model_candidates[-1].absolute().as_posix() + if model_candidates + else "" + ), enable_events=True, ), sg.FileBrowse( - initial_folder=Path("./logs/44k/").absolute - if Path("./logs/44k/").exists() - else Path(".").absolute().as_posix(), + initial_folder=( + Path("./logs/44k/").absolute + if Path("./logs/44k/").exists() + else Path(".").absolute().as_posix() + ), key="model_path_browse", file_types=( ("PyTorch", "G_*.pth G_*.pt"), @@ -208,15 +214,19 @@ def main(): sg.Push(), sg.InputText( key="config_path", - default_text=Path("./configs/44k/config.json").absolute().as_posix() - if Path("./configs/44k/config.json").exists() - else "", + default_text=( + Path("./configs/44k/config.json").absolute().as_posix() + if Path("./configs/44k/config.json").exists() + else "" + ), enable_events=True, ), sg.FileBrowse( - initial_folder=Path("./configs/44k/").as_posix() - if Path("./configs/44k/").exists() - else Path(".").absolute().as_posix(), + initial_folder=( + Path("./configs/44k/").as_posix() + if Path("./configs/44k/").exists() + else Path(".").absolute().as_posix() + ), key="config_path_browse", file_types=(("JSON", "*.json"),), ), @@ -226,15 +236,17 @@ def main(): sg.Push(), sg.InputText( key="cluster_model_path", - default_text=Path("./logs/44k/kmeans.pt").absolute().as_posix() - if Path("./logs/44k/kmeans.pt").exists() - else "", + default_text=( + Path("./logs/44k/kmeans.pt").absolute().as_posix() + if Path("./logs/44k/kmeans.pt").exists() + else "" + ), enable_events=True, ), sg.FileBrowse( - initial_folder="./logs/44k/" - if Path("./logs/44k/").exists() - else ".", + initial_folder=( + "./logs/44k/" if Path("./logs/44k/").exists() else "." + ), key="cluster_model_path_browse", file_types=(("PyTorch", "*.pt"), ("Pickle", "*.pt *.pth *.pkl")), ), @@ -735,9 +747,11 @@ def apply_preset(name: str) -> None: recursive=True, # svc config speaker=values["speaker"], - cluster_model_path=Path(values["cluster_model_path"]) - if values["cluster_model_path"] - else None, + cluster_model_path=( + Path(values["cluster_model_path"]) + if values["cluster_model_path"] + else None + ), transpose=values["transpose"], auto_predict_f0=values["auto_predict_f0"], cluster_infer_ratio=values["cluster_infer_ratio"], @@ -749,9 +763,9 @@ def apply_preset(name: str) -> None: chunk_seconds=values["chunk_seconds"], absolute_thresh=values["absolute_thresh"], max_chunk_seconds=values["max_chunk_seconds"], - device="cpu" - if not values["use_gpu"] - else get_optimal_device(), + device=( + "cpu" if not values["use_gpu"] else get_optimal_device() + ), ), ) infer_future.add_done_callback( @@ -782,9 +796,11 @@ def apply_preset(name: str) -> None: config_path=Path(values["config_path"]), speaker=values["speaker"], # svc config - cluster_model_path=Path(values["cluster_model_path"]) - if values["cluster_model_path"] - else None, + cluster_model_path=( + Path(values["cluster_model_path"]) + if values["cluster_model_path"] + else None + ), transpose=values["transpose"], auto_predict_f0=values["auto_predict_f0"], cluster_infer_ratio=values["cluster_infer_ratio"], diff --git a/src/so_vits_svc_fork/inference/main.py b/src/so_vits_svc_fork/inference/main.py index 0fe93b44..0a95cb34 100644 --- a/src/so_vits_svc_fork/inference/main.py +++ b/src/so_vits_svc_fork/inference/main.py @@ -75,9 +75,9 @@ def infer( svc_model = Svc( net_g_path=model_path.as_posix(), config_path=config_path.as_posix(), - cluster_model_path=cluster_model_path.as_posix() - if cluster_model_path - else None, + cluster_model_path=( + cluster_model_path.as_posix() if cluster_model_path else None + ), device=device, ) @@ -148,9 +148,9 @@ def realtime( svc_model = Svc( net_g_path=model_path.as_posix(), config_path=config_path.as_posix(), - cluster_model_path=cluster_model_path.as_posix() - if cluster_model_path - else None, + cluster_model_path=( + cluster_model_path.as_posix() if cluster_model_path else None + ), device=device, ) diff --git a/src/so_vits_svc_fork/preprocessing/preprocess_hubert_f0.py b/src/so_vits_svc_fork/preprocessing/preprocess_hubert_f0.py index 69c2a693..363c17db 100644 --- a/src/so_vits_svc_fork/preprocessing/preprocess_hubert_f0.py +++ b/src/so_vits_svc_fork/preprocessing/preprocess_hubert_f0.py @@ -131,10 +131,12 @@ def preprocess_hubert_f0( memory = get_total_gpu_memory("total") n_jobs = min( max( - memory - // (HUBERT_MEMORY_CREPE if f0_method == "crepe" else HUBERT_MEMORY) - if memory is not None - else 1, + ( + memory + // (HUBERT_MEMORY_CREPE if f0_method == "crepe" else HUBERT_MEMORY) + if memory is not None + else 1 + ), 1, ), cpu_count(), diff --git a/src/so_vits_svc_fork/train.py b/src/so_vits_svc_fork/train.py index 13be8dbe..6ca0e454 100644 --- a/src/so_vits_svc_fork/train.py +++ b/src/so_vits_svc_fork/train.py @@ -104,11 +104,11 @@ def train( val_check_interval=hparams.train.eval_interval, max_epochs=hparams.train.epochs, check_val_every_n_epoch=None, - precision="16-mixed" - if hparams.train.fp16_run - else "bf16-mixed" - if hparams.train.get("bf16_run", False) - else 32, + precision=( + "16-mixed" + if hparams.train.fp16_run + else "bf16-mixed" if hparams.train.get("bf16_run", False) else 32 + ), strategy=strategy, callbacks=([pl.callbacks.RichProgressBar()] if not is_notebook() else []) + [DeviceStatsMonitor()],