|
import os |
|
os.environ["NUMBA_DISABLE_CACHE"] = "1" |
|
import gradio as gr |
|
from openvoice import OpenVoice |
|
|
|
|
|
model = OpenVoice(language="en") |
|
|
|
def clone_and_speak(audio, text): |
|
output_path = "output.wav" |
|
model.clone_voice( |
|
source_audio_path=audio.name, |
|
target_text=text, |
|
output_path=output_path |
|
) |
|
return output_path |
|
|
|
with gr.Blocks() as demo: |
|
gr.Markdown("# OpenVoice TTS - Hugging Face Space") |
|
with gr.Row(): |
|
audio_input = gr.Audio(label="Upload voice to clone", type="file") |
|
text_input = gr.Textbox(label="Enter text to synthesize") |
|
with gr.Row(): |
|
generate_btn = gr.Button("Generate Audio") |
|
audio_output = gr.Audio(label="Synthesized Output", type="filepath") |
|
|
|
generate_btn.click(fn=clone_and_speak, inputs=[audio_input, text_input], outputs=audio_output) |
|
|
|
demo.launch() |
|
|