Update app.py
Browse files
app.py
CHANGED
@@ -1,53 +1,29 @@
|
|
1 |
-
from pathlib import Path
|
2 |
-
import subprocess
|
3 |
-
|
4 |
-
from dotenv import load_dotenv
|
5 |
-
from scipy.io import wavfile
|
6 |
import gradio as gr
|
|
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
subprocess.run(["rvc", "dlmodel"], check=True)
|
14 |
-
subprocess.run(["rvc", "env", "create"], check=True)
|
15 |
-
return "RVC initialized, model downloaded, and environment created."
|
16 |
-
|
17 |
-
|
18 |
-
def process_audio(model_path, input_audio, output_path):
|
19 |
-
vc = VC()
|
20 |
-
vc.get_vc(model_path)
|
21 |
-
tgt_sr, audio_opt, times, _ = vc.vc_single(1, Path(input_audio))
|
22 |
-
wavfile.write(output_path, tgt_sr, audio_opt)
|
23 |
-
return "Processing complete!"
|
24 |
-
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
fn=initialize_rvc,
|
33 |
-
inputs=[],
|
34 |
-
outputs=[init_message]
|
35 |
-
)
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
process_button = gr.Button("Process")
|
42 |
-
output_message = gr.Textbox(label="Output Message", interactive=False)
|
43 |
-
process_button.click(
|
44 |
-
fn=process_audio,
|
45 |
-
inputs=[model_path, input_audio, output_path],
|
46 |
-
outputs=[output_message]
|
47 |
-
)
|
48 |
|
49 |
-
|
|
|
|
|
50 |
|
|
|
|
|
51 |
|
52 |
-
|
53 |
-
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import subprocess
|
3 |
|
4 |
+
def rvc_infer(model, input_wav, fu):
|
5 |
+
output_wav = "output.wav" # Define a path for the output file
|
6 |
+
command = f"rvc infer -m {model} -i {input_wav} -o {output_wav} -fu {fu}"
|
7 |
+
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
8 |
+
return output_wav, result.stdout
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
+
with gr.Blocks() as demo:
|
11 |
+
gr.Markdown("# RVC Infer")
|
12 |
+
|
13 |
+
with gr.Row():
|
14 |
+
model_path = gr.Textbox(label="Model Path", placeholder="Enter model path (e.g., model.pth)")
|
15 |
+
input_audio = gr.Audio(label="Input Audio", type="filepath")
|
|
|
|
|
|
|
|
|
16 |
|
17 |
+
fu_value = gr.Slider(label="pitch", minimum=-12, maximum=12, step=1, value=0)
|
18 |
+
|
19 |
+
output_audio = gr.Audio(label="Output Audio")
|
20 |
+
command_output = gr.Textbox(label="Command Output")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
+
def infer(model, input_wav, fu):
|
23 |
+
output_wav, result = rvc_infer(model, input_wav, fu)
|
24 |
+
return output_wav, result
|
25 |
|
26 |
+
infer_button = gr.Button("Run Inference")
|
27 |
+
infer_button.click(infer, inputs=[model_path, input_audio, fu_value], outputs=[output_audio, command_output])
|
28 |
|
29 |
+
demo.launch()
|
|