| 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() |
|
|
|
|
| def run(text, language, voice): |
| if 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, 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\n" |
| "Fine-tuned XTTS-v2 text-to-speech with voice cloning.\n\n" |
| "⚠️ Inherits the base model's **CPML license (non-commercial use only)**." |
| ) |
| with gr.Row(): |
| with gr.Column(): |
| text_in = gr.Textbox(label="Text", lines=4, 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="Output", type="filepath") |
| status = gr.Textbox(label="Status", interactive=False) |
|
|
| submit.click(run, inputs=[text_in, language_in, voice_in], outputs=[audio_out, status]) |
|
|
| if __name__ == "__main__": |
| demo.launch() |
|
|