File size: 1,837 Bytes
106478e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
45
#!/usr/bin/env python3
import os
import sys
import gradio as gr

# Add src to path
current_dir = os.path.dirname(os.path.abspath(__file__))
src_dir = os.path.join(current_dir, "src")
if src_dir not in sys.path:
    sys.path.insert(0, src_dir)

def create_demo():
    """Create the main demo interface"""
    try:
        from f5_tts.f5_tts_webui import F5TTSWebUI
        app = F5TTSWebUI()
        return app.create_gradio_interface()
    except Exception as e:
        # Fallback interface if imports fail
        with gr.Blocks(title="F5-TTS Thai") as demo:
            gr.Markdown("# F5-TTS ภาษาไทย 🎤")
            gr.Markdown("## ⚠️ กำลังโหลดระบบ...")
            gr.Markdown(f"**Status:** กำลังดาวน์โหลดและเตรียมโมเดล")
            gr.Markdown("""
            ### กรุณารอสักครู่...
            - ระบบกำลังดาวน์โหลด dependencies
            - กำลังโหลดโมเดล F5-TTS
            - โปรเซสนี้อาจใช้เวลา 2-5 นาที
            
            **หากยังไม่ทำงาน กรุณารีเฟรชหน้าใหม่**
            """)
            
            with gr.Row():
                status_text = gr.Textbox(label="สถานะ", value="กำลังเตรียมระบบ...", interactive=False)
                refresh_btn = gr.Button("🔄 รีเฟรช", variant="primary")
                refresh_btn.click(fn=lambda: "รีเฟรชแล้ว", outputs=status_text)
        
        return demo

# Create the demo - THIS IS IMPORTANT FOR HF SPACES
demo = create_demo()

# Launch settings
if __name__ == "__main__":
    demo.launch()