|
import gradio as gr |
|
from pathlib import Path |
|
from dotenv import load_dotenv |
|
from scipy.io import wavfile |
|
from rvc.modules.vc.modules import VC |
|
import os |
|
|
|
|
|
os.system("rvc dlmodel") |
|
os.system("rvc env create") |
|
os.system("rvc init") |
|
|
|
|
|
|
|
|
|
def process_audio(input_audio, model_path): |
|
vc = VC() |
|
vc.get_vc(model_path) |
|
tgt_sr, audio_opt, times, _ = vc.vc_single(1, Path(input_audio)) |
|
output_path = "output.wav" |
|
wavfile.write(output_path, tgt_sr, audio_opt) |
|
return output_path |
|
|
|
def main(): |
|
with gr.Blocks() as demo: |
|
gr.Markdown("# RVC Audio Processor") |
|
with gr.Row(): |
|
input_audio = gr.Audio(type="filepath", label="Input Audio") |
|
model_path = gr.File(label="Model Path (.pth file)") |
|
output_audio = gr.Audio(label="Output Audio") |
|
process_button = gr.Button("Process Audio") |
|
process_button.click(fn=process_audio, inputs=[input_audio, model_path], outputs=output_audio) |
|
|
|
demo.launch() |
|
|
|
if __name__ == "__main__": |
|
load_dotenv() |
|
main() |