Spaces:
Running
Running
huu-ontocord
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,19 @@
|
|
1 |
import gradio as gr
|
2 |
import json
|
3 |
|
4 |
-
def save_to_json(text1, text2, text3, agree):
|
5 |
-
"""Saves the input text
|
6 |
if agree:
|
|
|
|
|
|
|
|
|
|
|
7 |
data = {
|
8 |
"text1": text1,
|
9 |
"text2": text2,
|
10 |
-
"text3": text3
|
|
|
11 |
}
|
12 |
with open("data.json", "w") as f:
|
13 |
json.dump(data, f)
|
@@ -21,11 +27,12 @@ iface = gr.Interface(
|
|
21 |
gr.TextArea(lines=5, placeholder="Enter text 1 here..."),
|
22 |
gr.TextArea(lines=5, placeholder="Enter text 2 here..."),
|
23 |
gr.TextArea(lines=5, placeholder="Enter text 3 here..."),
|
24 |
-
gr.
|
|
|
25 |
],
|
26 |
outputs="text",
|
27 |
-
title="Save Text to JSON",
|
28 |
-
description="Enter text
|
29 |
)
|
30 |
|
31 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
import json
|
3 |
|
4 |
+
def save_to_json(text1, text2, text3, video, agree):
|
5 |
+
"""Saves the input text and video to a JSON file if the checkbox is checked."""
|
6 |
if agree:
|
7 |
+
# Save the video to a file (you'll need to decide on a naming scheme)
|
8 |
+
video_filename = "uploaded_video.mp4" # Example filename
|
9 |
+
with open(video_filename, "wb") as f:
|
10 |
+
f.write(video.read())
|
11 |
+
|
12 |
data = {
|
13 |
"text1": text1,
|
14 |
"text2": text2,
|
15 |
+
"text3": text3,
|
16 |
+
"video_filename": video_filename
|
17 |
}
|
18 |
with open("data.json", "w") as f:
|
19 |
json.dump(data, f)
|
|
|
27 |
gr.TextArea(lines=5, placeholder="Enter text 1 here..."),
|
28 |
gr.TextArea(lines=5, placeholder="Enter text 2 here..."),
|
29 |
gr.TextArea(lines=5, placeholder="Enter text 3 here..."),
|
30 |
+
gr.Video(format="mp4"), # Add the video input
|
31 |
+
gr.Checkbox(label="I agree and have the rights to share the content I entered here under the CC-BY license.")
|
32 |
],
|
33 |
outputs="text",
|
34 |
+
title="Save Text and Video to JSON",
|
35 |
+
description="Enter text, upload a video, and click submit to save to a JSON file."
|
36 |
)
|
37 |
|
38 |
iface.launch()
|