File size: 1,959 Bytes
deaa4a8
0c1b49d
fd20222
063006a
fd20222
 
 
 
 
deaa4a8
063006a
 
 
 
 
 
 
c17e167
0c1b49d
c17e167
0c1b49d
 
deaa4a8
0c1b49d
c17e167
0c1b49d
 
c17e167
 
0c1b49d
c17e167
 
 
c364417
deaa4a8
bd0e55e
 
 
90a4866
bd0e55e
90a4866
bd0e55e
 
0c1b49d
 
 
deaa4a8
2374bce
c17e167
0c1b49d
deaa4a8
0c1b49d
c17e167
deaa4a8
0c1b49d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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()