File size: 1,282 Bytes
351ec52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from youtube_transcript_api import YouTubeTranscriptApi
import gradio as gr
from gradio.mix import Series

def generate_transcript(url):
    id = url[url.index("=")+1:]
        
    transcript = YouTubeTranscriptApi.get_transcript(id)
    script = ""

    for text in transcript:
        t = text["text"]
        if t != '[Music]':
            script += t + " "
		
    return script

transcriber = gr.Interface(generate_transcript, 'text', 'text')
summarizer = gr.Interface.load("huggingface/sshleifer/distilbart-cnn-12-6")

gradio_ui = Series(transcriber, summarizer,
                  inputs = gr.inputs.Textbox(label = "Enter the YouTube URL below:"),
                  outputs = gr.outputs.Textbox(label = "Transcript Summary"),
                  examples = ["https://www.youtube.com/watch?v=Cu3R5it4cQs&list", "https://www.youtube.com/watch?v=HB4I2CgkcCo"],
                  title = "YouTube Transcript Summarizer",
                  theme = "peach",
                  description = "This application uses the sshleifer/distilbart-cnn-12-6 model to summarize a short YouTube video that has English subtitles. For it to work, the input URL must follow the format similar to the given examples, specifically having the video's ID at the end.")
               
gradio_ui.launch()