huu-ontocord's picture
Update app.py
9f2ebbe verified
raw
history blame
1.16 kB
import gradio as gr
import json
def save_to_json(text1, text2, text3, video, agree):
"""Saves the input text and video to a JSON file if the checkbox is checked."""
if agree:
# Save the video to an mp4 file
video_filename = "uploaded_video.mp4"
video.save(video_filename)
data = {
"text1": text1,
"text2": text2,
"text3": text3,
"video_filename": video_filename
}
with open("data.json", "w") as f:
json.dump(data, f)
return "Data saved to data.json"
else:
return "Please agree to the terms before submitting."
iface = gr.Interface(
fn=save_to_json,
inputs=[
gr.TextArea(lines=5, placeholder="Enter text 1 here..."),
gr.TextArea(lines=5, placeholder="Enter text 2 here..."),
gr.TextArea(lines=5, placeholder="Enter text 3 here..."),
gr.Video(format="mp4"),
gr.Checkbox(label="I agree and have the rights to share these prompts under the CC-BY license.")
],
outputs="text",
title="Save Text and Video to JSON",
description="Enter text, upload a video, and click submit to save to a JSON file."
)
iface.launch()