Spaces:
Build error
Build error
import gradio as gr | |
from TTS.api import TTS | |
import tempfile | |
# Load viXTTS model | |
tts = TTS(model_path="ntdgo/ttsvi", progress_bar=False, gpu=True) | |
def synthesize_tts(audio_file, text): | |
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as tmp_output: | |
tts.tts_to_file( | |
text=text, | |
speaker_wav=audio_file, | |
language="vi", | |
file_path=tmp_output.name | |
) | |
return tmp_output.name | |
with gr.Blocks() as demo: | |
gr.Markdown("## 🇻🇳 Vietnamese Emotional TTS with Voice Cloning") | |
with gr.Row(): | |
audio_input = gr.Audio(label="🎤 Upload your voice (WAV only)", type="filepath") | |
text_input = gr.Textbox(label="📝 Vietnamese Text", value="Xin chào! Tôi rất vui được gặp bạn.") | |
output_audio = gr.Audio(label="🗣️ Generated Voice Output") | |
run_btn = gr.Button("Generate") | |
run_btn.click(fn=synthesize_tts, inputs=[audio_input, text_input], outputs=output_audio) | |
demo.launch() | |