Taf2023's picture
Upload folder using huggingface_hub
7962c79 verified
raw
history blame
3.21 kB
import gradio as gr
import os
from utils import process_pipeline
# Define the UI
with gr.Blocks(theme=gr.themes.Soft()) as demo:
# Header
with gr.Row():
gr.Markdown(
"""
# 🇹🇭 Thai to AI Media Generator
### แปลงข้อความไทยเป็นภาพและเสียงด้วย AI (Translate Thai -> Image & Audio)
[Built with anycoder](https://huggingface.co/spaces/akhaliq/anycoder)
"""
)
with gr.Row():
with gr.Column(scale=1):
# Input Section
input_text = gr.Textbox(
label="ใส่ข้อความภาษาไทย (Input Thai Text)",
placeholder="ตัวอย่าง: แมวน่ารักใส่แว่นกันแดดนั่งอยู่บนชายหาด",
lines=3
)
style_dropdown = gr.Dropdown(
choices=["None", "Cinematic", "Anime", "3D Model", "Oil Painting", "Pixel Art"],
value="None",
label="สไตล์ภาพ (Image Style)"
)
submit_btn = gr.Button("✨ สร้างผลงาน (Generate)", variant="primary", size="lg")
gr.Markdown(
"""
**หมายเหตุ:**
- ระบบจะใช้โมเดลฟรีบน Hugging Face
- การประมวลผลอาจใช้เวลา 10-30 วินาทีขึ้นอยู่กับความหนาแน่นของ Server
"""
)
with gr.Column(scale=1):
# Output Section
with gr.Group():
gr.Markdown("### 1. ผลลัพธ์การแปล (Translation)")
output_translation = gr.Textbox(label="English Translation", interactive=False)
with gr.Group():
gr.Markdown("### 2. ภาพที่สร้างได้ (Generated Image)")
output_image = gr.Image(label="AI Image", type="pil")
with gr.Group():
gr.Markdown("### 3. เสียงบรรยาย (Generated Audio)")
output_audio = gr.Audio(label="AI Speech", type="filepath")
# Logic Connection
submit_btn.click(
fn=process_pipeline,
inputs=[input_text, style_dropdown],
outputs=[output_translation, output_image, output_audio]
)
# Add examples
gr.Examples(
examples=[
["เด็กผู้หญิงใส่ชุดไทยยืนอยู่หน้าวัดอรุณ", "Cinematic"],
["หุ่นยนต์แห่งโลกอนาคตกำลังทำอาหารในครัว", "3D Model"],
["ป่ามหัศจรรย์ที่มีต้นไม้เรืองแสง", "Oil Painting"]
],
inputs=[input_text, style_dropdown]
)
if __name__ == "__main__":
demo.launch()