|
|
|
|
|
import gradio as gr |
|
|
import numpy as np |
|
|
import pandas as pd |
|
|
|
|
|
|
|
|
def create_video_from_text(text): |
|
|
|
|
|
return "video_from_text.mp4" |
|
|
|
|
|
|
|
|
def create_video_from_images(images): |
|
|
|
|
|
return "video_from_images.mp4" |
|
|
|
|
|
|
|
|
def create_video_from_pdf(pdf_file): |
|
|
|
|
|
return "video_from_pdf.mp4" |
|
|
|
|
|
|
|
|
def post_to_social_media(video, platform): |
|
|
|
|
|
return f"Posted {video} to {platform}" |
|
|
|
|
|
|
|
|
def process_input(input_type, input_data, platform): |
|
|
if input_type == "text": |
|
|
video = create_video_from_text(input_data) |
|
|
elif input_type == "images": |
|
|
video = create_video_from_images(input_data) |
|
|
elif input_type == "pdf": |
|
|
video = create_video_from_pdf(input_data) |
|
|
else: |
|
|
return "Invalid input type" |
|
|
|
|
|
post_result = post_to_social_media(video, platform) |
|
|
return post_result |
|
|
|
|
|
|
|
|
with gr.Blocks(css="body { background-color: #000; color: #0f0; } .gr-button { background-color: #f00; color: #000; } .gr-input { background-color: #000; color: #0f0; }") as demo: |
|
|
gr.Markdown("# Social Media Automation App") |
|
|
|
|
|
with gr.Row(): |
|
|
input_type = gr.Radio(["text", "images", "pdf"], label="Input Type") |
|
|
|
|
|
with gr.Row(): |
|
|
text_input = gr.Textbox(label="Text Input", visible=False) |
|
|
images_input = gr.File(label="Images Input", file_types=["image/*"], visible=False) |
|
|
pdf_input = gr.File(label="PDF Input", file_types=["application/pdf"], visible=False) |
|
|
|
|
|
with gr.Row(): |
|
|
platform = gr.Radio(["Facebook", "Twitter", "Instagram"], label="Social Media Platform") |
|
|
|
|
|
with gr.Row(): |
|
|
submit_button = gr.Button("Submit") |
|
|
|
|
|
output = gr.Textbox(label="Output") |
|
|
|
|
|
|
|
|
def update_input_visibility(input_type): |
|
|
if input_type == "text": |
|
|
return gr.Textbox.update(visible=True), gr.File.update(visible=False), gr.File.update(visible=False) |
|
|
elif input_type == "images": |
|
|
return gr.Textbox.update(visible=False), gr.File.update(visible=True), gr.File.update(visible=False) |
|
|
elif input_type == "pdf": |
|
|
return gr.Textbox.update(visible=False), gr.File.update(visible=False), gr.File.update(visible=True) |
|
|
|
|
|
input_type.change(fn=update_input_visibility, inputs=input_type, outputs=[text_input, images_input, pdf_input]) |
|
|
|
|
|
submit_button.click(fn=process_input, inputs=[input_type, text_input, images_input, pdf_input, platform], outputs=output) |
|
|
|
|
|
if __name__ == "__main__": |
|
|
demo.launch(show_error=True) |