Blane187 commited on
Commit
deaa4a8
1 Parent(s): 60e54aa

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +53 -0
app.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ from rvc.modules.vc.modules import VC
9
+
10
+
11
+ def initialize_rvc():
12
+ subprocess.run(["rvc", "init"], check=True)
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
+ def main():
27
+ with gr.Blocks() as demo:
28
+ with gr.Tab("Initialize RVC"):
29
+ init_button = gr.Button("Initialize RVC")
30
+ init_message = gr.Textbox(label="Initialization Message", interactive=False)
31
+ init_button.click(
32
+ fn=initialize_rvc,
33
+ inputs=[],
34
+ outputs=[init_message]
35
+ )
36
+
37
+ with gr.Tab("process Audio"):
38
+ model_path = gr.Textbox(label="Model Path", placeholder="Enter model path (e.g., model.pth)")
39
+ input_audio = gr.Audio(label="Input Audio", type="filepath")
40
+ output_path = gr.Textbox(label="Output Path", placeholder="Enter output path (e.g., output.wav)")
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
+ demo.launch()
50
+
51
+
52
+ if __name__ == "__main__":
53
+ main()