Spaces:
Sleeping
Sleeping
import gradio as gr | |
from youtube_scraper import get_youtube_info | |
from score_model import score_fit | |
def compute_scores(url, goal, mode): | |
info = get_youtube_info(url) | |
meta_text = f"{info['title']} {info['description']}" | |
transcript = " ".join(s['text'] for s in info['captions']) | |
full_text = f"{meta_text} {transcript}" | |
score_meta = score_fit(meta_text, goal) | |
score_full = score_fit(full_text, goal) | |
# Display transcript plain, no timestamps | |
transcript_display = transcript or "(no captions)" | |
return ( | |
info['title'], | |
info['description'], | |
transcript_display, | |
score_meta if mode == "Meta" else score_full | |
) | |
app = gr.Interface( | |
fn=compute_scores, | |
inputs=[ | |
gr.Textbox(label="YouTube URL"), | |
gr.Textbox(label="Your Goal", lines=2), | |
gr.Radio(["Meta","Full"], label="Scoring Mode") | |
], | |
outputs=[ | |
gr.Textbox(label="Title"), | |
gr.Textbox(label="Description"), | |
gr.Textbox(label="Transcript"), | |
gr.Number(label="Fit Score (0–100)") | |
], | |
title="YouTube Video Fit Score", | |
description="Enter a YouTube URL and your goal; choose Meta or Full scoring." | |
) | |
if __name__ == "__main__": | |
app.launch() | |