import gradio as gr import subprocess import os import requests os.system("rvc init") os.system("rvc env create") os.system("rvc dlmodel") def download_pth(url): response = requests.get(url) file_path = "model.pth" with open(file_path, 'wb') as f: f.write(response.content) return file_path def rvc_infer(model, input_wav, fu, fmethod): output_wav = "output.wav" # Define a path for the output file command = f"rvc infer -m {model} -i {input_wav} -o {output_wav} -fu {fu} -fm {fmethod}" result = subprocess.run(command, shell=True, capture_output=True, text=True) return output_wav, result.stdout with gr.Blocks() as demo: gr.Markdown("# RVC `pip` Demo") with gr.Row(): model_path = gr.File(label="Model file") with gr.Row(): input_audio = gr.Audio(label="Input Audio", type="filepath") with gr.Row(): fu_value = gr.Slider(label="pitch", minimum=-12, maximum=12, step=1, value=0) with gr.Row(): f0_value = gr.Dropdown(choices=["pm", "crepe", "rmvpe"], label="F0 method", value="rmvpe") with gr.Accordion(" download A pth file"): with gr.Row(): gr.Markdown(" get pth file from huggingface, example `https://huggingface.co/sail-rvc/hitzeed-ch/blob/main/model.pth` ") with gr.Row(): url = gr.Textbox(label=" url pth") with gr.Row(): dowoad_but = gr.Button("download") dowoad_but.click(download_pth, inputs=[url], outputs=[model_path]) output_audio = gr.Audio(label="Output Audio") command_output = gr.Textbox(label="Command Output") def infer(model, input_wav, fu, fmethod): output_wav, result = rvc_infer(model, input_wav, fu,fmethod) return output_wav, result infer_button = gr.Button("Run Inference") infer_button.click(infer, inputs=[model_path, input_audio, fu_value,f0_value], outputs=[output_audio, command_output]) demo.launch()