| import gradio as gr | |
| import json | |
| from src.pipeline import run_pipeline, search_highlights | |
| from dotenv import load_dotenv | |
| import shutil | |
| load_dotenv() | |
| def extract(video_file, game_card_str): | |
| shutil.copy(video_file.name, "uploaded.mp4") | |
| result = run_pipeline("uploaded.mp4", game_card_str) | |
| return json.dumps(result, indent=2) | |
| def search(query): | |
| return "\n".join(search_highlights(query)) | |
| with gr.Blocks() as demo: | |
| gr.Markdown("# Soccer Highlight Extractor") | |
| with gr.Tab("Extract Highlights"): | |
| video = gr.File(label="Upload Video") | |
| game_card = gr.Textbox(label="Paste Game Card (JSON)", lines=10) | |
| result = gr.Textbox(label="Pipeline Output") | |
| gr.Button("Run Extraction").click(extract, [video, game_card], result) | |
| with gr.Tab("Search Highlights"): | |
| query = gr.Textbox(label="Search Query") | |
| output = gr.Textbox(label="Search Results") | |
| gr.Button("Search").click(search, query, output) | |
| demo.launch() | |