File size: 1,037 Bytes
2aee50d 5165e58 0c20337 5165e58 0c20337 5165e58 0c20337 5165e58 0c20337 5165e58 0c20337 5165e58 0c20337 |
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 |
import os
os.environ["NUMBA_DISABLE_CACHE"] = "1"
import gradio as gr
import os
import torch
# Add openvoice path
import sys
sys.path.append("openvoice")
from openvoice.api import ToneColorConverter
from openvoice.inference import voice_conversion
# Set up paths
ckpt_converter = './checkpoints/converter'
device = "cuda" if torch.cuda.is_available() else "cpu"
converter = ToneColorConverter(f"{ckpt_converter}/config.json", device=device)
converter.load_ckpt(f"{ckpt_converter}/converter.ckpt")
def convert_voice(audio_file, text_prompt):
output_path = "./results/output.wav"
# You must clone reference audio using clone.sh or similar step in Dockerfile
voice_conversion(converter, audio_file.name, text_prompt, output_path, device)
return output_path
iface = gr.Interface(
fn=convert_voice,
inputs=[
gr.Audio(type="filepath", label="Input Voice (WAV)"),
gr.Textbox(label="Prompt (e.g., 'Speak in a cheerful tone')"),
],
outputs=gr.Audio(label="Converted Voice")
)
iface.launch()
|