Skip to content

Commit

Permalink
chore(pre-commit.ci): auto fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Mar 18, 2024
1 parent 1f88da3 commit 0cccd11
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 45 deletions.
76 changes: 46 additions & 30 deletions src/so_vits_svc_fork/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"),
Expand All @@ -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"),),
),
Expand All @@ -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")),
),
Expand Down Expand Up @@ -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"],
Expand All @@ -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(
Expand Down Expand Up @@ -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"],
Expand Down
12 changes: 6 additions & 6 deletions src/so_vits_svc_fork/inference/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down Expand Up @@ -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,
)

Expand Down
10 changes: 6 additions & 4 deletions src/so_vits_svc_fork/preprocessing/preprocess_hubert_f0.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
10 changes: 5 additions & 5 deletions src/so_vits_svc_fork/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()],
Expand Down

0 comments on commit 0cccd11

Please sign in to comment.