Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -14,14 +14,36 @@ from huggingface_hub import hf_hub_download, list_repo_files
|
|
14 |
from so_vits_svc_fork.hparams import HParams
|
15 |
from so_vits_svc_fork.inference.core import Svc
|
16 |
|
|
|
|
|
|
|
|
|
|
|
17 |
repo_ids = ["nijisakai/sunyanzi", "kevinwang676/jay"]
|
|
|
|
|
18 |
ckpt_name = None
|
|
|
|
|
19 |
cluster_model_name = None
|
|
|
|
|
|
|
|
|
20 |
default_f0_method = "crepe"
|
|
|
|
|
|
|
21 |
default_cluster_infer_ratio = 0.5
|
|
|
|
|
|
|
|
|
22 |
duration_limit = int(os.environ.get("MAX_DURATION_SECONDS", 9e9))
|
|
|
23 |
|
24 |
models = []
|
|
|
25 |
for repo_id in repo_ids:
|
26 |
# Figure out the latest generator by taking highest value one.
|
27 |
# Ex. if the repo has: G_0.pth, G_100.pth, G_200.pth, we'd use G_200.pth
|
@@ -47,7 +69,7 @@ for repo_id in repo_ids:
|
|
47 |
generator_path = hf_hub_download(repo_id, ckpt_name)
|
48 |
config_path = hf_hub_download(repo_id, "config.json")
|
49 |
hparams = HParams(**json.loads(Path(config_path).read_text()))
|
50 |
-
speakers
|
51 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
52 |
model = Svc(net_g_path=generator_path, config_path=config_path, device=device, cluster_model_path=cluster_model_path)
|
53 |
models.append(model)
|
|
|
14 |
from so_vits_svc_fork.hparams import HParams
|
15 |
from so_vits_svc_fork.inference.core import Svc
|
16 |
|
17 |
+
|
18 |
+
###################################################################
|
19 |
+
# REPLACE THESE VALUES TO CHANGE THE MODEL REPO/CKPT NAME/SETTINGS
|
20 |
+
###################################################################
|
21 |
+
# The Hugging Face Hub repo ID - 在这里修改repo_id,可替换成任何已经训练好的模型!
|
22 |
repo_ids = ["nijisakai/sunyanzi", "kevinwang676/jay"]
|
23 |
+
|
24 |
+
# If None, Uses latest ckpt in the repo
|
25 |
ckpt_name = None
|
26 |
+
|
27 |
+
# If None, Uses "kmeans.pt" if it exists in the repo
|
28 |
cluster_model_name = None
|
29 |
+
|
30 |
+
# Set the default f0 type to use - use the one it was trained on.
|
31 |
+
# The default for so-vits-svc-fork is "dio".
|
32 |
+
# Options: "crepe", "crepe-tiny", "parselmouth", "dio", "harvest"
|
33 |
default_f0_method = "crepe"
|
34 |
+
|
35 |
+
# The default ratio of cluster inference to SVC inference.
|
36 |
+
# If cluster_model_name is not found in the repo, this is set to 0.
|
37 |
default_cluster_infer_ratio = 0.5
|
38 |
+
|
39 |
+
# Limit on duration of audio at inference time. increase if you can
|
40 |
+
# In this parent app, we set the limit with an env var to 30 seconds
|
41 |
+
# If you didnt set env var + you go OOM try changing 9e9 to <=300ish
|
42 |
duration_limit = int(os.environ.get("MAX_DURATION_SECONDS", 9e9))
|
43 |
+
###################################################################
|
44 |
|
45 |
models = []
|
46 |
+
speakers = []
|
47 |
for repo_id in repo_ids:
|
48 |
# Figure out the latest generator by taking highest value one.
|
49 |
# Ex. if the repo has: G_0.pth, G_100.pth, G_200.pth, we'd use G_200.pth
|
|
|
69 |
generator_path = hf_hub_download(repo_id, ckpt_name)
|
70 |
config_path = hf_hub_download(repo_id, "config.json")
|
71 |
hparams = HParams(**json.loads(Path(config_path).read_text()))
|
72 |
+
speakers.extend(list(hparams.spk.keys()))
|
73 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
74 |
model = Svc(net_g_path=generator_path, config_path=config_path, device=device, cluster_model_path=cluster_model_path)
|
75 |
models.append(model)
|