Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from openvoice import OpenVoice
|
| 3 |
+
|
| 4 |
+
# Load OpenVoice model (adjust to your setup)
|
| 5 |
+
model = OpenVoice(language="en")
|
| 6 |
+
|
| 7 |
+
def clone_and_speak(audio, text):
|
| 8 |
+
output_path = "output.wav"
|
| 9 |
+
model.clone_voice(
|
| 10 |
+
source_audio_path=audio.name,
|
| 11 |
+
target_text=text,
|
| 12 |
+
output_path=output_path
|
| 13 |
+
)
|
| 14 |
+
return output_path
|
| 15 |
+
|
| 16 |
+
with gr.Blocks() as demo:
|
| 17 |
+
gr.Markdown("# OpenVoice TTS - Hugging Face Space")
|
| 18 |
+
with gr.Row():
|
| 19 |
+
audio_input = gr.Audio(label="Upload voice to clone", type="file")
|
| 20 |
+
text_input = gr.Textbox(label="Enter text to synthesize")
|
| 21 |
+
with gr.Row():
|
| 22 |
+
generate_btn = gr.Button("Generate Audio")
|
| 23 |
+
audio_output = gr.Audio(label="Synthesized Output", type="filepath")
|
| 24 |
+
|
| 25 |
+
generate_btn.click(fn=clone_and_speak, inputs=[audio_input, text_input], outputs=audio_output)
|
| 26 |
+
|
| 27 |
+
demo.launch()
|