import gradio as gr from src.process import url_process, video_process def process_input(topic, url, video, method): transcript = "请选择一种方式输入,并选择一个图像生成方法" post, desc = "", "" images = None if topic != "" and method: transcript = "" elif url != "" and method: transcript, post, desc, images= url_process(url, method) elif video and method: transcript, post, desc, images = video_process(video, method) return transcript, post, desc, images def clear_context(): return "", "", None, "", "", "", None with gr.Blocks() as demo: gr.Markdown("#
Post Generation

") with gr.Row(): # Input Tabs with gr.Column(scale=1): gr.Markdown("##
Input
") with gr.Tab("Topic"): topic = gr.Textbox(lines=5) with gr.Tab("Video URL"): url = gr.Textbox(lines=2) with gr.Tab("Video File"): video = gr.File(file_types=[".mp4"], label="Video File") method = gr.Radio(["OpenAI", "Retrieval"], label="Method", info="which method to generate images?") with gr.Row(): submit = gr.Button("Submit") clear = gr.Button("Clear") # Output Tabs with gr.Column(scale=2): gr.Markdown("##
Output
") with gr.Tab("Transcript"): script = gr.TextArea(lines=13, label="Transcript") with gr.Tab("Post"): post = gr.TextArea(lines=13, label="Post") with gr.Tab("Description"): desc = gr.TextArea(lines=13, label="Description") with gr.Tab("Image"): gallery = gr.Gallery(label="Images")#.style(columns=[2], rows=[1], object_fit="contain", height="auto") # Sumit Functions submit.click(fn=process_input, inputs=[topic, url, video, method], outputs=[script, post, desc, gallery]) clear.click(fn=clear_context, inputs=[], outputs=[topic, url, video, script, post, desc, gallery]) if __name__ == "__main__": demo.launch(auth=("decoda.ai", "ai.decoda")) # demo.launch()