Spaces:
Sleeping
Sleeping
Upload interface.py
Browse files- interface.py +49 -0
interface.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from app import download_youtube_video, process_video
|
| 4 |
+
|
| 5 |
+
def smartscribe_interface(video_file, youtube_link, services):
|
| 6 |
+
if not video_file and not youtube_link:
|
| 7 |
+
return "β Please upload a video or paste a YouTube link.", None, None, None, None
|
| 8 |
+
|
| 9 |
+
input_path = "input_video.mp4"
|
| 10 |
+
if youtube_link:
|
| 11 |
+
download_youtube_video(youtube_link, filename=input_path)
|
| 12 |
+
else:
|
| 13 |
+
video_file.save(input_path)
|
| 14 |
+
|
| 15 |
+
results = process_video(input_path, services)
|
| 16 |
+
|
| 17 |
+
return (
|
| 18 |
+
results.get("transcription", "N/A"),
|
| 19 |
+
results.get("summary", "N/A"),
|
| 20 |
+
results.get("subtitles", "N/A"),
|
| 21 |
+
results.get("quiz", "N/A"),
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
with gr.Blocks() as demo:
|
| 25 |
+
gr.Markdown("# π SmartScribe - AI-Powered Learning Assistant")
|
| 26 |
+
|
| 27 |
+
with gr.Row():
|
| 28 |
+
video_input = gr.Video(label="π€ Upload a Video File (MP4)")
|
| 29 |
+
youtube_input = gr.Textbox(label="π Or Paste a YouTube Link")
|
| 30 |
+
|
| 31 |
+
services = gr.CheckboxGroup(
|
| 32 |
+
["Transcription", "Summary", "Subtitles", "Quiz"],
|
| 33 |
+
label="π οΈ Select Services"
|
| 34 |
+
)
|
| 35 |
+
|
| 36 |
+
submit_btn = gr.Button("π Process Video")
|
| 37 |
+
|
| 38 |
+
transcription_output = gr.Textbox(label="π Transcription")
|
| 39 |
+
summary_output = gr.Textbox(label="π Summary")
|
| 40 |
+
subtitle_output = gr.Textbox(label="π¬ Subtitles (SRT or Text)")
|
| 41 |
+
quiz_output = gr.Textbox(label="β Auto-Generated Quiz")
|
| 42 |
+
|
| 43 |
+
submit_btn.click(
|
| 44 |
+
smartscribe_interface,
|
| 45 |
+
inputs=[video_input, youtube_input, services],
|
| 46 |
+
outputs=[transcription_output, summary_output, subtitle_output, quiz_output]
|
| 47 |
+
)
|
| 48 |
+
|
| 49 |
+
demo.launch()
|