Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from pathlib import Path
|
3 |
+
from dotenv import load_dotenv
|
4 |
+
from scipy.io import wavfile
|
5 |
+
from rvc.modules.vc.modules import VC
|
6 |
+
import os
|
7 |
+
|
8 |
+
|
9 |
+
os.system("rvc dlmodel")
|
10 |
+
os.system("rvc env create")
|
11 |
+
os.system("rvc init")
|
12 |
+
|
13 |
+
|
14 |
+
|
15 |
+
|
16 |
+
def process_audio(input_audio, model_path):
|
17 |
+
vc = VC()
|
18 |
+
vc.get_vc(model_path)
|
19 |
+
tgt_sr, audio_opt, times, _ = vc.vc_single(1, Path(input_audio))
|
20 |
+
output_path = "output.wav"
|
21 |
+
wavfile.write(output_path, tgt_sr, audio_opt)
|
22 |
+
return output_path
|
23 |
+
|
24 |
+
def main():
|
25 |
+
with gr.Blocks() as demo:
|
26 |
+
gr.Markdown("# RVC Audio Processor")
|
27 |
+
with gr.Row():
|
28 |
+
input_audio = gr.Audio(type="filepath", label="Input Audio")
|
29 |
+
model_path = gr.Textbox(label="Model Path (.pth file)")
|
30 |
+
output_audio = gr.Audio(label="Output Audio")
|
31 |
+
process_button = gr.Button("Process Audio")
|
32 |
+
process_button.click(fn=process_audio, inputs=[input_audio, model_path], outputs=output_audio)
|
33 |
+
|
34 |
+
demo.launch()
|
35 |
+
|
36 |
+
if __name__ == "__main__":
|
37 |
+
load_dotenv()
|
38 |
+
main()
|