Spaces:
Sleeping
Sleeping
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 a file (you'll need to decide on a naming scheme) | |
video_filename = "uploaded_video.mp4" # Example filename | |
with open(video_filename, "wb") as f: | |
f.write(video.read()) | |
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"), # Add the video input | |
gr.Checkbox(label="I agree and have the rights to share the content I entered here 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() |