File size: 1,301 Bytes
4220f69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from youtube_transcript_api import YouTubeTranscriptApi
from youtube_transcript_api.formatters import TextFormatter
import gradio as gr
from gradio.mix import Series

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

    formatter = TextFormatter()
    text_formatted = formatter.format_transcript(transcript)

    return text_formatted
    
transcriber = gr.Interface(generate_transcript, 'text', 'text')
summarizer = gr.Interface.load("huggingface/facebook/bart-large-cnn")

description =  '''
        This application summarizes a youtube video based on its transcript. 
        Enter a Youtube video URL and click submit for obtaining a summary. 
        '''

youtube_url_examples = [['https://www.youtube.com/watch?v=MBRqu0YOH14'],
              ['https://www.youtube.com/watch?v=UjtOGPJ0URM']]
              
iface = Series(transcriber, summarizer,
                  inputs = gr.inputs.Textbox(label = "Enter the YouTube URL"),
                  outputs = gr.outputs.Textbox(label = "Transcript Summary"),
                  examples = youtube_url_examples,
                  title = "YouTube Transcript Summarizer",
                  theme = "grass",
                  description = description)

iface.launch()