Spaces:
Sleeping
Sleeping
feat(app): minor changes
Browse files- app-full.py +14 -17
- app.py +64 -77
- weights/folder_info.json +1 -2
- weights/genshin-impact/cover.jpg +0 -3
app-full.py
CHANGED
@@ -158,12 +158,11 @@ if __name__ == '__main__':
|
|
158 |
for name, info in folder_info.items():
|
159 |
if not info['enable']:
|
160 |
continue
|
161 |
-
title =
|
162 |
folder = info['folder_path']
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
for (title, folder, cover, markdown) in categories:
|
167 |
with open(f"weights/{folder}/model_info.json", "r", encoding="utf-8") as f:
|
168 |
models_info = json.load(f)
|
169 |
for name, info in models_info.items():
|
@@ -171,9 +170,9 @@ if __name__ == '__main__':
|
|
171 |
continue
|
172 |
title = info['title']
|
173 |
author = info.get("author", None)
|
174 |
-
cover = f"weights/{name}/{info['cover']}"
|
175 |
-
index = f"weights/{name}/{info['feature_retrieval_library']}"
|
176 |
-
cpt = torch.load(f"weights/{name}/{name}.pth", map_location="cpu")
|
177 |
tgt_sr = cpt["config"][-1]
|
178 |
cpt["config"][-3] = cpt["weight"]["emb_g.weight"].shape[0] # n_spk
|
179 |
if_f0 = cpt.get("f0", 1)
|
@@ -199,17 +198,15 @@ if __name__ == '__main__':
|
|
199 |
"[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/110kiMZTdP6Ri1lY9-NbQf17GVPPhHyeT?usp=sharing)\n\n"
|
200 |
"[![Original Repo](https://badgen.net/badge/icon/github?icon=github&label=Original%20Repo)](https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI)"
|
201 |
)
|
202 |
-
for (
|
203 |
-
gr.
|
204 |
-
|
205 |
-
|
206 |
-
'<div>'
|
207 |
-
)
|
208 |
-
with gr.TabItem(title):
|
209 |
with gr.Tabs():
|
210 |
-
if not models
|
211 |
gr.Markdown("# <center> No Model Loaded.")
|
212 |
-
|
|
|
213 |
for (name, title, author, cover, vc_fn) in models:
|
214 |
with gr.TabItem(name):
|
215 |
with gr.Row():
|
|
|
158 |
for name, info in folder_info.items():
|
159 |
if not info['enable']:
|
160 |
continue
|
161 |
+
title = info['title']
|
162 |
folder = info['folder_path']
|
163 |
+
description = info['description']
|
164 |
+
categories.append([title, folder, description])
|
165 |
+
for (title, folder, description) in categories:
|
|
|
166 |
with open(f"weights/{folder}/model_info.json", "r", encoding="utf-8") as f:
|
167 |
models_info = json.load(f)
|
168 |
for name, info in models_info.items():
|
|
|
170 |
continue
|
171 |
title = info['title']
|
172 |
author = info.get("author", None)
|
173 |
+
cover = f"weights/{folder}/{name}/{info['cover']}"
|
174 |
+
index = f"weights/{folder}/{name}/{info['feature_retrieval_library']}"
|
175 |
+
cpt = torch.load(f"weights/{folder}/{name}/{name}.pth", map_location="cpu")
|
176 |
tgt_sr = cpt["config"][-1]
|
177 |
cpt["config"][-3] = cpt["weight"]["emb_g.weight"].shape[0] # n_spk
|
178 |
if_f0 = cpt.get("f0", 1)
|
|
|
198 |
"[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/110kiMZTdP6Ri1lY9-NbQf17GVPPhHyeT?usp=sharing)\n\n"
|
199 |
"[![Original Repo](https://badgen.net/badge/icon/github?icon=github&label=Original%20Repo)](https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI)"
|
200 |
)
|
201 |
+
for (folder_title, folder, description) in categories:
|
202 |
+
with gr.TabItem(folder_title):
|
203 |
+
if description:
|
204 |
+
gr.Markdown(f"<center>{description}")
|
|
|
|
|
|
|
205 |
with gr.Tabs():
|
206 |
+
if not models:
|
207 |
gr.Markdown("# <center> No Model Loaded.")
|
208 |
+
gr.Markdown("## <center> Please added the model or fix your model path.")
|
209 |
+
continue
|
210 |
for (name, title, author, cover, vc_fn) in models:
|
211 |
with gr.TabItem(name):
|
212 |
with gr.Row():
|
app.py
CHANGED
@@ -97,19 +97,29 @@ def change_to_tts_mode(tts_mode):
|
|
97 |
if __name__ == '__main__':
|
98 |
load_hubert()
|
99 |
models = []
|
|
|
100 |
tts_voice_list = asyncio.get_event_loop().run_until_complete(edge_tts.list_voices())
|
101 |
voices = [f"{v['ShortName']}-{v['Gender']}" for v in tts_voice_list]
|
102 |
-
|
103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
models_info = json.load(f)
|
105 |
for name, info in models_info.items():
|
106 |
if not info['enable']:
|
107 |
continue
|
108 |
title = info['title']
|
109 |
author = info.get("author", None)
|
110 |
-
cover = f"weights/{name}/{info['cover']}"
|
111 |
-
index = f"weights/{name}/{info['feature_retrieval_library']}"
|
112 |
-
cpt = torch.load(f"weights/{name}/{name}.pth", map_location="cpu")
|
113 |
tgt_sr = cpt["config"][-1]
|
114 |
cpt["config"][-3] = cpt["weight"]["emb_g.weight"].shape[0] # n_spk
|
115 |
if_f0 = cpt.get("f0", 1)
|
@@ -118,90 +128,67 @@ if __name__ == '__main__':
|
|
118 |
else:
|
119 |
net_g = SynthesizerTrnMs256NSFsid_nono(*cpt["config"])
|
120 |
del net_g.enc_q
|
121 |
-
print(net_g.load_state_dict(cpt["weight"], strict=False))
|
122 |
-
net_g.eval().to(config.device)
|
123 |
-
if config.is_half:
|
124 |
-
net_g = net_g.half()
|
125 |
-
else:
|
126 |
-
net_g = net_g.float()
|
127 |
-
vc = VC(tgt_sr, config)
|
128 |
-
models.append((name, title, author, cover, create_vc_fn(tgt_sr, net_g, vc, if_f0, index)))
|
129 |
-
else:
|
130 |
-
folder_path = "weights"
|
131 |
-
for name in os.listdir(folder_path):
|
132 |
-
print("check folder: " + name)
|
133 |
-
if name.startswith("."): break
|
134 |
-
cover_path = glob.glob(f"{folder_path}/{name}/*.png") + glob.glob(f"{folder_path}/{name}/*.jpg")
|
135 |
-
index_path = glob.glob(f"{folder_path}/{name}/*.index")
|
136 |
-
checkpoint_path = glob.glob(f"{folder_path}/{name}/*.pth")
|
137 |
-
title = name
|
138 |
-
author = ""
|
139 |
-
if cover_path:
|
140 |
-
cover = cover_path[0]
|
141 |
-
else:
|
142 |
-
cover = ""
|
143 |
-
index = index_path[0]
|
144 |
-
cpt = torch.load(checkpoint_path[0], map_location="cpu")
|
145 |
-
tgt_sr = cpt["config"][-1]
|
146 |
-
cpt["config"][-3] = cpt["weight"]["emb_g.weight"].shape[0] # n_spk
|
147 |
-
if_f0 = cpt.get("f0", 1)
|
148 |
-
if if_f0 == 1:
|
149 |
-
net_g = SynthesizerTrnMs256NSFsid(*cpt["config"], is_half=config.is_half)
|
150 |
-
else:
|
151 |
-
net_g = SynthesizerTrnMs256NSFsid_nono(*cpt["config"])
|
152 |
-
del net_g.enc_q
|
153 |
-
print(net_g.load_state_dict(cpt["weight"], strict=False)) # 不加这一行清不干净, 真奇葩
|
154 |
net_g.eval().to(config.device)
|
155 |
if config.is_half:
|
156 |
net_g = net_g.half()
|
157 |
else:
|
158 |
net_g = net_g.float()
|
159 |
vc = VC(tgt_sr, config)
|
|
|
160 |
models.append((name, title, author, cover, create_vc_fn(tgt_sr, net_g, vc, if_f0, index)))
|
161 |
with gr.Blocks() as app:
|
162 |
gr.Markdown(
|
163 |
"# <center> RVC Models [(Latest Update)](https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI/releases/tag/20230428updated)\n"
|
164 |
"## <center> The input audio should be clean and pure voice without background music.\n"
|
165 |
-
"### <center>
|
166 |
-
"#### <center> Please regenerate your model to latest RVC to fully applied this new rvc.\n"
|
167 |
"[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/110kiMZTdP6Ri1lY9-NbQf17GVPPhHyeT?usp=sharing)\n\n"
|
168 |
"[![Original Repo](https://badgen.net/badge/icon/github?icon=github&label=Original%20Repo)](https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI)"
|
169 |
)
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
)
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
207 |
app.queue(concurrency_count=1, max_size=20, api_open=config.api).launch(share=config.colab)
|
|
|
97 |
if __name__ == '__main__':
|
98 |
load_hubert()
|
99 |
models = []
|
100 |
+
categories = []
|
101 |
tts_voice_list = asyncio.get_event_loop().run_until_complete(edge_tts.list_voices())
|
102 |
voices = [f"{v['ShortName']}-{v['Gender']}" for v in tts_voice_list]
|
103 |
+
with open("weights/folder_info.json", "r", encoding="utf-8") as f:
|
104 |
+
folder_info = json.load(f)
|
105 |
+
for name, info in folder_info.items():
|
106 |
+
if not info['enable']:
|
107 |
+
continue
|
108 |
+
title = info['title']
|
109 |
+
folder = info['folder_path']
|
110 |
+
description = info['description']
|
111 |
+
categories.append([title, folder, description])
|
112 |
+
for (title, folder, description) in categories:
|
113 |
+
with open(f"weights/{folder}/model_info.json", "r", encoding="utf-8") as f:
|
114 |
models_info = json.load(f)
|
115 |
for name, info in models_info.items():
|
116 |
if not info['enable']:
|
117 |
continue
|
118 |
title = info['title']
|
119 |
author = info.get("author", None)
|
120 |
+
cover = f"weights/{folder}/{name}/{info['cover']}"
|
121 |
+
index = f"weights/{folder}/{name}/{info['feature_retrieval_library']}"
|
122 |
+
cpt = torch.load(f"weights/{folder}/{name}/{name}.pth", map_location="cpu")
|
123 |
tgt_sr = cpt["config"][-1]
|
124 |
cpt["config"][-3] = cpt["weight"]["emb_g.weight"].shape[0] # n_spk
|
125 |
if_f0 = cpt.get("f0", 1)
|
|
|
128 |
else:
|
129 |
net_g = SynthesizerTrnMs256NSFsid_nono(*cpt["config"])
|
130 |
del net_g.enc_q
|
131 |
+
print(net_g.load_state_dict(cpt["weight"], strict=False))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
net_g.eval().to(config.device)
|
133 |
if config.is_half:
|
134 |
net_g = net_g.half()
|
135 |
else:
|
136 |
net_g = net_g.float()
|
137 |
vc = VC(tgt_sr, config)
|
138 |
+
print(f"Model loaded: {name}")
|
139 |
models.append((name, title, author, cover, create_vc_fn(tgt_sr, net_g, vc, if_f0, index)))
|
140 |
with gr.Blocks() as app:
|
141 |
gr.Markdown(
|
142 |
"# <center> RVC Models [(Latest Update)](https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI/releases/tag/20230428updated)\n"
|
143 |
"## <center> The input audio should be clean and pure voice without background music.\n"
|
144 |
+
"### <center> This project was inspired by [zomehwh](https://huggingface.co/spaces/zomehwh/rvc-models) and [ardha27](https://huggingface.co/spaces/ardha27/rvc-models)\n"
|
|
|
145 |
"[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/110kiMZTdP6Ri1lY9-NbQf17GVPPhHyeT?usp=sharing)\n\n"
|
146 |
"[![Original Repo](https://badgen.net/badge/icon/github?icon=github&label=Original%20Repo)](https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI)"
|
147 |
)
|
148 |
+
for (folder_title, folder, description) in categories:
|
149 |
+
with gr.TabItem(folder_title):
|
150 |
+
if description:
|
151 |
+
gr.Markdown(f"<center>{description}")
|
152 |
+
with gr.Tabs():
|
153 |
+
if not models:
|
154 |
+
gr.Markdown("# <center> No Model Loaded.")
|
155 |
+
gr.Markdown("## <center> Please added the model or fix your model path.")
|
156 |
+
continue
|
157 |
+
with gr.Tabs():
|
158 |
+
for (name, title, author, cover, vc_fn) in models:
|
159 |
+
with gr.TabItem(name):
|
160 |
+
with gr.Row():
|
161 |
+
gr.Markdown(
|
162 |
+
'<div align="center">'
|
163 |
+
f'<div>{title}</div>\n'+
|
164 |
+
(f'<div>Model author: {author}</div>' if author else "")+
|
165 |
+
(f'<img style="width:auto;height:300px;" src="file/{cover}">' if cover else "")+
|
166 |
+
'</div>'
|
167 |
+
)
|
168 |
+
with gr.Row():
|
169 |
+
with gr.Column():
|
170 |
+
vc_input = gr.Audio(label="Input audio"+' (less than 20 seconds)' if limitation else '')
|
171 |
+
vc_transpose = gr.Number(label="Transpose", value=0)
|
172 |
+
vc_f0method = gr.Radio(
|
173 |
+
label="Pitch extraction algorithm, PM is fast but Harvest is better for low frequencies",
|
174 |
+
choices=["pm", "harvest"],
|
175 |
+
value="pm",
|
176 |
+
interactive=True,
|
177 |
+
)
|
178 |
+
vc_index_ratio = gr.Slider(
|
179 |
+
minimum=0,
|
180 |
+
maximum=1,
|
181 |
+
label="Retrieval feature ratio",
|
182 |
+
value=0.6,
|
183 |
+
interactive=True,
|
184 |
+
)
|
185 |
+
tts_mode = gr.Checkbox(label="tts (use edge-tts as input)", value=False)
|
186 |
+
tts_text = gr.Textbox(visible=False,label="TTS text (100 words limitation)" if limitation else "TTS text")
|
187 |
+
tts_voice = gr.Dropdown(label="Edge-tts speaker", choices=voices, visible=False, allow_custom_value=False, value="en-US-AnaNeural-Female")
|
188 |
+
vc_submit = gr.Button("Generate", variant="primary")
|
189 |
+
with gr.Column():
|
190 |
+
vc_output1 = gr.Textbox(label="Output Message")
|
191 |
+
vc_output2 = gr.Audio(label="Output Audio")
|
192 |
+
vc_submit.click(vc_fn, [vc_input, vc_transpose, vc_f0method, vc_index_ratio, tts_mode, tts_text, tts_voice], [vc_output1, vc_output2])
|
193 |
+
tts_mode.change(change_to_tts_mode, [tts_mode], [vc_input, tts_text, tts_voice])
|
194 |
app.queue(concurrency_count=1, max_size=20, api_open=config.api).launch(share=config.colab)
|
weights/folder_info.json
CHANGED
@@ -3,7 +3,6 @@
|
|
3 |
"enable": true,
|
4 |
"title": "Genshin Impact",
|
5 |
"folder_path": "genshin-impact",
|
6 |
-
"
|
7 |
-
"markdown": ""
|
8 |
}
|
9 |
}
|
|
|
3 |
"enable": true,
|
4 |
"title": "Genshin Impact",
|
5 |
"folder_path": "genshin-impact",
|
6 |
+
"description": ""
|
|
|
7 |
}
|
8 |
}
|
weights/genshin-impact/cover.jpg
DELETED
Git LFS Details
|