-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
37 lines (27 loc) · 1.31 KB
/
app.py
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
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']]
#Videos taken from Kurzgesagt – In a Nutshell
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 = "Distil YouTube",
theme = "grass",
description = description)
iface.launch()