File size: 916 Bytes
4fbec80 ac7e5d3 982b0a3 4fbec80 982b0a3 4fbec80 982b0a3 ac7e5d3 982b0a3 4fbec80 982b0a3 4fbec80 982b0a3 4fbec80 ac7e5d3 | 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 | import gradio as gr
from rvc_lib import VoiceConverter
import os
# Load voices folder
voice_folder = "voices"
voices = {f.split(".")[0]: os.path.join(voice_folder, f)
for f in os.listdir(voice_folder) if f.endswith(".pth")}
# Function to convert voice
def convert_voice(input_audio, selected_voice):
if selected_voice not in voices:
return "Voice model not found!"
vc = VoiceConverter(model_path=voices[selected_voice], voice_name=selected_voice)
return vc.convert(input_audio)
# Gradio interface
iface = gr.Interface(
fn=convert_voice,
inputs=[
gr.Audio(source="upload", type="filepath", label="Your Audio"),
gr.Dropdown(list(voices.keys()), label="Select Voice")
],
outputs=gr.Audio(type="filepath", label="Converted Audio"),
title="RVC Voice Swap",
description="Upload your audio, select a voice, and let AI do the magic!"
)
iface.launch() |