File size: 1,238 Bytes
298dafd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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()