Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -5,8 +5,23 @@ from datetime import datetime
|
|
5 |
os.environ["rmvpe_root"] = "assets/rmvpe"
|
6 |
os.environ['index_root']="logs"
|
7 |
os.environ['weight_root']="assets/weights"
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
gr.Warning("Your audio is being converted. Please wait.")
|
11 |
now = datetime.now().strftime("%d%m%Y%H%M%S")
|
12 |
index_files = glob.glob(f"logs/{index_picker}/*.index")
|
@@ -16,20 +31,21 @@ def convert(audio_picker,model_picker,index_picker,index_rate,pitch):
|
|
16 |
gr.Warning("Sorry, I couldn't find your .index file.")
|
17 |
print("Did not find a matching .index file")
|
18 |
index_files = [f'logs/{model_picker}/fake_index.index']
|
|
|
19 |
command = [
|
20 |
"python",
|
21 |
"tools/infer_cli.py",
|
22 |
"--f0up_key", str(pitch),
|
23 |
"--input_path", f"audios/{audio_picker}",
|
24 |
"--index_path", index_files[0],
|
25 |
-
"--f0method",
|
26 |
"--opt_path", f"audios/cli_output_{now}.wav",
|
27 |
"--model_name", f"{model_picker}",
|
28 |
"--index_rate", str(float(index_rate)),
|
29 |
-
"--device",
|
30 |
"--filter_radius", "3",
|
31 |
"--resample_sr", "0",
|
32 |
-
"--rms_mix_rate", "0.
|
33 |
"--protect", "0"
|
34 |
]
|
35 |
|
@@ -161,7 +177,7 @@ def update_audio_player(choice):
|
|
161 |
with gr.Blocks() as app:
|
162 |
with gr.Row():
|
163 |
with gr.Column():
|
164 |
-
gr.HTML("<img src='file/a.png' alt='
|
165 |
with gr.Column():
|
166 |
gr.HTML("<a href='https://ko-fi.com/rejekts' target='_blank'><img src='file/kofi_button.png' alt='Support Me'></a>")
|
167 |
with gr.Row():
|
@@ -170,6 +186,7 @@ with gr.Blocks() as app:
|
|
170 |
with gr.TabItem("1.Choose a voice model:"):
|
171 |
model_picker = gr.Dropdown(label="Model: ",choices=show_available('assets/weights','.pth'),value=show_available('assets/weights','.pth')[0],interactive=True,allow_custom_value=True)
|
172 |
index_picker = gr.Dropdown(label="Index:",interactive=True,choices=show_available('logs'),value=show_available('logs')[0],allow_custom_value=True)
|
|
|
173 |
with gr.TabItem("(Or download a model here)"):
|
174 |
with gr.Row():
|
175 |
url = gr.Textbox(label="Paste the URL here:",value="",placeholder="(i.e. https://huggingface.co/repo/model/resolve/main/model.zip)")
|
@@ -182,6 +199,7 @@ with gr.Blocks() as app:
|
|
182 |
with gr.TabItem("Advanced"):
|
183 |
index_rate = gr.Slider(label='Index Rate: ',minimum=0,maximum=1,value=0.66,step=0.01)
|
184 |
pitch = gr.Slider(label='Pitch (-12 lowers it an octave, 0 keeps the original pitch, 12 lifts it an octave): ',minimum =-12, maximum=12, step=1, value=0, interactive=True)
|
|
|
185 |
|
186 |
with gr.Row():
|
187 |
with gr.Tabs():
|
@@ -197,7 +215,8 @@ with gr.Blocks() as app:
|
|
197 |
convert_button = gr.Button("Convert")
|
198 |
with gr.Row():
|
199 |
audio_player = gr.Audio()
|
|
|
200 |
audio_picker.change(fn=update_audio_player, inputs=[audio_picker],outputs=[audio_player])
|
201 |
-
convert_button.click(convert, inputs=
|
202 |
|
203 |
app.queue().launch()
|
|
|
5 |
os.environ["rmvpe_root"] = "assets/rmvpe"
|
6 |
os.environ['index_root']="logs"
|
7 |
os.environ['weight_root']="assets/weights"
|
8 |
+
from infer.modules.vc.modules import VC
|
9 |
+
from configs.config import Config
|
10 |
+
import torch
|
11 |
+
config = Config()
|
12 |
+
vc = VC(config)
|
13 |
|
14 |
+
def load_model(model_picker,index_picker):
|
15 |
+
logs = show_available("logs")
|
16 |
+
if model_picker.replace(".pth","") in logs:
|
17 |
+
log = model_picker.replace(".pth","")
|
18 |
+
else:
|
19 |
+
log = index_picker
|
20 |
+
gr.Warning("Could not find a matching index file.")
|
21 |
+
vc.get_vc(model_picker,0,0)
|
22 |
+
return {"choices":logs,"value":log,"__type__": "update"}
|
23 |
+
|
24 |
+
def convert(audio_picker,model_picker,index_picker,index_rate,pitch,method):
|
25 |
gr.Warning("Your audio is being converted. Please wait.")
|
26 |
now = datetime.now().strftime("%d%m%Y%H%M%S")
|
27 |
index_files = glob.glob(f"logs/{index_picker}/*.index")
|
|
|
31 |
gr.Warning("Sorry, I couldn't find your .index file.")
|
32 |
print("Did not find a matching .index file")
|
33 |
index_files = [f'logs/{model_picker}/fake_index.index']
|
34 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
35 |
command = [
|
36 |
"python",
|
37 |
"tools/infer_cli.py",
|
38 |
"--f0up_key", str(pitch),
|
39 |
"--input_path", f"audios/{audio_picker}",
|
40 |
"--index_path", index_files[0],
|
41 |
+
"--f0method", method,
|
42 |
"--opt_path", f"audios/cli_output_{now}.wav",
|
43 |
"--model_name", f"{model_picker}",
|
44 |
"--index_rate", str(float(index_rate)),
|
45 |
+
"--device", device,
|
46 |
"--filter_radius", "3",
|
47 |
"--resample_sr", "0",
|
48 |
+
"--rms_mix_rate", "0.0",
|
49 |
"--protect", "0"
|
50 |
]
|
51 |
|
|
|
177 |
with gr.Blocks() as app:
|
178 |
with gr.Row():
|
179 |
with gr.Column():
|
180 |
+
gr.HTML("<div><img src='file/a.png' alt='easyGUI'></div>")
|
181 |
with gr.Column():
|
182 |
gr.HTML("<a href='https://ko-fi.com/rejekts' target='_blank'><img src='file/kofi_button.png' alt='Support Me'></a>")
|
183 |
with gr.Row():
|
|
|
186 |
with gr.TabItem("1.Choose a voice model:"):
|
187 |
model_picker = gr.Dropdown(label="Model: ",choices=show_available('assets/weights','.pth'),value=show_available('assets/weights','.pth')[0],interactive=True,allow_custom_value=True)
|
188 |
index_picker = gr.Dropdown(label="Index:",interactive=True,choices=show_available('logs'),value=show_available('logs')[0],allow_custom_value=True)
|
189 |
+
model_picker.change(fn=load_model,inputs=[model_picker,index_picker],outputs=[index_picker])
|
190 |
with gr.TabItem("(Or download a model here)"):
|
191 |
with gr.Row():
|
192 |
url = gr.Textbox(label="Paste the URL here:",value="",placeholder="(i.e. https://huggingface.co/repo/model/resolve/main/model.zip)")
|
|
|
199 |
with gr.TabItem("Advanced"):
|
200 |
index_rate = gr.Slider(label='Index Rate: ',minimum=0,maximum=1,value=0.66,step=0.01)
|
201 |
pitch = gr.Slider(label='Pitch (-12 lowers it an octave, 0 keeps the original pitch, 12 lifts it an octave): ',minimum =-12, maximum=12, step=1, value=0, interactive=True)
|
202 |
+
method = gr.Dropdown(label="Method:",choices=["rmvpe","pm"],value="rmvpe")
|
203 |
|
204 |
with gr.Row():
|
205 |
with gr.Tabs():
|
|
|
215 |
convert_button = gr.Button("Convert")
|
216 |
with gr.Row():
|
217 |
audio_player = gr.Audio()
|
218 |
+
inputs = [audio_picker,model_picker,index_picker,index_rate,pitch,method]
|
219 |
audio_picker.change(fn=update_audio_player, inputs=[audio_picker],outputs=[audio_player])
|
220 |
+
convert_button.click(convert, inputs=inputs,outputs=[audio_picker,audio_player])
|
221 |
|
222 |
app.queue().launch()
|