Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,6 +8,7 @@ import numpy as np
|
|
| 8 |
import uuid
|
| 9 |
import base64
|
| 10 |
import torch
|
|
|
|
| 11 |
|
| 12 |
# Auto-select device: GPU if available
|
| 13 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
@@ -195,15 +196,28 @@ def process(video_file):
|
|
| 195 |
html_output_path = os.path.join(base_dir, f"{video_id}.html")
|
| 196 |
final_html = generate_html(entries, video_id, video_path, screenshots_dir, plots_dir, html_output_path)
|
| 197 |
|
| 198 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
|
| 200 |
# Gradio UI
|
| 201 |
demo = gr.Interface(
|
| 202 |
fn=process,
|
| 203 |
inputs=[gr.File(label="Upload Video", file_types=[".mp4", ".mov", ".mkv"])],
|
| 204 |
-
outputs=
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
title="Video Annotated Transcript",
|
| 206 |
-
description="🎥 Upload a video file
|
| 207 |
)
|
| 208 |
|
| 209 |
if __name__ == "__main__":
|
|
|
|
| 8 |
import uuid
|
| 9 |
import base64
|
| 10 |
import torch
|
| 11 |
+
import shutil
|
| 12 |
|
| 13 |
# Auto-select device: GPU if available
|
| 14 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
|
| 196 |
html_output_path = os.path.join(base_dir, f"{video_id}.html")
|
| 197 |
final_html = generate_html(entries, video_id, video_path, screenshots_dir, plots_dir, html_output_path)
|
| 198 |
|
| 199 |
+
# Create ZIP of screenshots
|
| 200 |
+
zip_path = os.path.join(base_dir, f"{video_id}_screenshots.zip")
|
| 201 |
+
shutil.make_archive(zip_path.replace(".zip", ""), "zip", screenshots_dir)
|
| 202 |
+
|
| 203 |
+
# Return HTML content (for preview), HTML file (for download), and screenshots zip
|
| 204 |
+
with open(final_html, "r", encoding="utf-8") as f:
|
| 205 |
+
html_content = f.read()
|
| 206 |
+
|
| 207 |
+
return html_content, final_html, zip_path
|
| 208 |
+
|
| 209 |
|
| 210 |
# Gradio UI
|
| 211 |
demo = gr.Interface(
|
| 212 |
fn=process,
|
| 213 |
inputs=[gr.File(label="Upload Video", file_types=[".mp4", ".mov", ".mkv"])],
|
| 214 |
+
outputs=[
|
| 215 |
+
gr.HTML(label="Preview Annotated Transcript"),
|
| 216 |
+
gr.File(label="Download Annotated HTML"),
|
| 217 |
+
gr.File(label="Download Screenshots (ZIP)")
|
| 218 |
+
],
|
| 219 |
title="Video Annotated Transcript",
|
| 220 |
+
description="🎥 Upload a video file. The tool transcribes speech, captures screenshots, analyzes sound intensity, and generates an editable HTML transcript."
|
| 221 |
)
|
| 222 |
|
| 223 |
if __name__ == "__main__":
|