Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -73,63 +73,62 @@ css = """
|
|
| 73 |
.required {background-color: #FFCCCB !important, font-size: 24px !important}
|
| 74 |
"""
|
| 75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
-
|
| 78 |
-
# gr.Markdown(
|
| 79 |
-
# """# Start and stop times generator
|
| 80 |
-
# Please, fill the Video URL and Clip texts textboxes and click the Run button"""
|
| 81 |
-
# ),
|
| 82 |
-
iface = gr.Interface(
|
| 83 |
-
fn=calculate_times,
|
| 84 |
-
inputs=[
|
| 85 |
-
gr.Textbox(
|
| 86 |
-
lines=1,
|
| 87 |
-
placeholder="Video URL...",
|
| 88 |
-
label="Video URL",
|
| 89 |
-
elem_classes=["required"],
|
| 90 |
-
),
|
| 91 |
-
gr.Textbox(
|
| 92 |
-
lines=5,
|
| 93 |
-
max_lines=10,
|
| 94 |
-
placeholder="List of clip texts...",
|
| 95 |
-
label="Clip texts",
|
| 96 |
-
elem_classes=["required"],
|
| 97 |
-
),
|
| 98 |
-
gr.Slider(
|
| 99 |
-
minimum=0,
|
| 100 |
-
maximum=1000,
|
| 101 |
-
step=50,
|
| 102 |
-
value=0,
|
| 103 |
-
label="Milliseconds BEFORE each clip",
|
| 104 |
-
),
|
| 105 |
-
gr.Slider(
|
| 106 |
-
minimum=0,
|
| 107 |
-
maximum=1000,
|
| 108 |
-
step=50,
|
| 109 |
-
value=500,
|
| 110 |
-
label="Milliseconds AFTER each clip",
|
| 111 |
-
),
|
| 112 |
-
# gr.Button(value="Run", variant="primary", size="sm"),
|
| 113 |
-
# gr.Video(
|
| 114 |
-
# format="mp4", label="Video file", show_label=True, interactive=False
|
| 115 |
-
# )
|
| 116 |
-
],
|
| 117 |
-
outputs=[
|
| 118 |
-
gr.File(
|
| 119 |
-
label="Clips", show_label=True, interactive=False, file_count="single"
|
| 120 |
-
),
|
| 121 |
-
gr.Textbox(
|
| 122 |
-
lines=10, label="Clips", interactive=False, show_copy_button=True
|
| 123 |
-
),
|
| 124 |
-
gr.Dataframe(
|
| 125 |
-
label="Clips",
|
| 126 |
-
headers=["text", "start", "stop", "file"],
|
| 127 |
-
datatype=["str", "str", "str", "str"],
|
| 128 |
-
row_count=0,
|
| 129 |
-
)
|
| 130 |
-
],
|
| 131 |
-
description="# Start and stop times",
|
| 132 |
-
css=css
|
| 133 |
-
)
|
| 134 |
-
|
| 135 |
-
iface.launch()
|
|
|
|
| 73 |
.required {background-color: #FFCCCB !important, font-size: 24px !important}
|
| 74 |
"""
|
| 75 |
|
| 76 |
+
with gr.Blocks(title="Start and stop times", css=css) as app:
|
| 77 |
+
gr.Markdown(
|
| 78 |
+
"""# Start and stop times generator
|
| 79 |
+
Please, fill the Video URL and Clip texts textboxes and click the Run button"""
|
| 80 |
+
)
|
| 81 |
+
with gr.Row():
|
| 82 |
+
with gr.Column(scale=3):
|
| 83 |
+
text1 = gr.Textbox(
|
| 84 |
+
lines=1,
|
| 85 |
+
placeholder="Video URL...",
|
| 86 |
+
label="Video URL",
|
| 87 |
+
elem_classes=["required"],
|
| 88 |
+
)
|
| 89 |
+
text2 = gr.Textbox(
|
| 90 |
+
lines=5,
|
| 91 |
+
max_lines=10,
|
| 92 |
+
placeholder="List of clip texts...",
|
| 93 |
+
label="Clip texts",
|
| 94 |
+
elem_classes=["required"],
|
| 95 |
+
)
|
| 96 |
+
slider1 = gr.Slider(
|
| 97 |
+
minimum=0,
|
| 98 |
+
maximum=1000,
|
| 99 |
+
step=50,
|
| 100 |
+
value=0,
|
| 101 |
+
label="Milliseconds BEFORE each clip",
|
| 102 |
+
)
|
| 103 |
+
slider2 = gr.Slider(
|
| 104 |
+
minimum=0,
|
| 105 |
+
maximum=1000,
|
| 106 |
+
step=50,
|
| 107 |
+
value=500,
|
| 108 |
+
label="Milliseconds AFTER each clip",
|
| 109 |
+
)
|
| 110 |
+
btn_submit = gr.Button(value="Run", variant="primary", size="sm")
|
| 111 |
+
video = gr.Video(
|
| 112 |
+
format="mp4", label="Video file", show_label=True, interactive=False
|
| 113 |
+
)
|
| 114 |
+
with gr.Column(scale=5):
|
| 115 |
+
file = gr.File(
|
| 116 |
+
label="Clips", show_label=True, interactive=False, file_count="single"
|
| 117 |
+
)
|
| 118 |
+
lines = gr.Textbox(
|
| 119 |
+
lines=10, label="Clips", interactive=False, show_copy_button=True
|
| 120 |
+
)
|
| 121 |
+
data = gr.Dataframe(
|
| 122 |
+
label="Clips",
|
| 123 |
+
headers=["text", "start", "stop", "file"],
|
| 124 |
+
datatype=["str", "str", "str", "str"],
|
| 125 |
+
row_count=0,
|
| 126 |
+
)
|
| 127 |
+
btn_submit.click(
|
| 128 |
+
calculate_times,
|
| 129 |
+
inputs=[text1, text2, slider1, slider2],
|
| 130 |
+
outputs=[lines, file, data],
|
| 131 |
+
)
|
| 132 |
+
text1.blur(load_video, inputs=[text1], outputs=[video])
|
| 133 |
|
| 134 |
+
app.queue().launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|