import gradio as gr from src.inference import generate, list_voices LANGUAGES = [ "en", "es", "fr", "de", "it", "pt", "pl", "tr", "ru", "nl", "cs", "ar", "zh-cn", "ja", "hu", "ko", "hi" ] VOICES = list_voices() EXAMPLES = [ ["Hello! Welcome to FroxAI Flex-Audio.", "en"], ["This is a multilingual text to speech demonstration.", "en"], ["नमस्ते! यह FroxAI Flex-Audio का डेमो है।", "hi"], ["Bonjour ! Bienvenue dans la démonstration FroxAI.", "fr"], ] def run(text, language, voice): if not text or not text.strip(): return None, "Enter some text first." if not voice: return None, "No voices found — make sure voice_refs/ is included in the repo." try: path = generate(text.strip(), language, voice) return path, f"Generated with voice '{voice}' in language '{language}'." except Exception as e: return None, f"Error: {e}" with gr.Blocks(title="FroxAI Flex-Audio") as demo: gr.Markdown( """ # 🦊 FroxAI — Flex-Audio **Fine-tuned XTTS-v2 text-to-speech with voice cloning.** Enter text, choose a language and voice, then click **Generate**. > ⚠️ This model inherits the base model's **CPML license (non-commercial use only)**. """ ) with gr.Row(): with gr.Column(): text_in = gr.Textbox( label="Text", lines=5, placeholder="Type something to speak..." ) language_in = gr.Dropdown( choices=LANGUAGES, value="en", label="Language" ) voice_in = gr.Dropdown( choices=VOICES, value=VOICES[0] if VOICES else None, label="Voice" ) submit = gr.Button("🔊 Generate", variant="primary") with gr.Column(): audio_out = gr.Audio(label="Generated Audio", type="filepath") status = gr.Textbox(label="Status", interactive=False) gr.Markdown("## 🎙️ Demo examples") gr.Examples( examples=EXAMPLES, inputs=[text_in, language_in], label="Click an example to load it, then select a voice and press Generate." ) submit.click( run, inputs=[text_in, language_in, voice_in], outputs=[audio_out, status] ) text_in.submit( run, inputs=[text_in, language_in, voice_in], outputs=[audio_out, status] ) if __name__ == "__main__": demo.launch()