File size: 1,659 Bytes
a5a266c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import gradio as gr

from src.inference import generate, list_voices

# XTTS-v2's 17 languages with real voice cloning support
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()