vishnux commited on
Commit
4220f69
1 Parent(s): 9efae4f
Files changed (1) hide show
  1. app.py +35 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from youtube_transcript_api import YouTubeTranscriptApi
2
+ from youtube_transcript_api.formatters import TextFormatter
3
+ import gradio as gr
4
+ from gradio.mix import Series
5
+
6
+ def generate_transcript(url):
7
+
8
+ text = url[url.index("=")+1:]
9
+ transcript = YouTubeTranscriptApi.get_transcript(text)
10
+
11
+ formatter = TextFormatter()
12
+ text_formatted = formatter.format_transcript(transcript)
13
+
14
+ return text_formatted
15
+
16
+ transcriber = gr.Interface(generate_transcript, 'text', 'text')
17
+ summarizer = gr.Interface.load("huggingface/facebook/bart-large-cnn")
18
+
19
+ description = '''
20
+ This application summarizes a youtube video based on its transcript.
21
+ Enter a Youtube video URL and click submit for obtaining a summary.
22
+ '''
23
+
24
+ youtube_url_examples = [['https://www.youtube.com/watch?v=MBRqu0YOH14'],
25
+ ['https://www.youtube.com/watch?v=UjtOGPJ0URM']]
26
+
27
+ iface = Series(transcriber, summarizer,
28
+ inputs = gr.inputs.Textbox(label = "Enter the YouTube URL"),
29
+ outputs = gr.outputs.Textbox(label = "Transcript Summary"),
30
+ examples = youtube_url_examples,
31
+ title = "YouTube Transcript Summarizer",
32
+ theme = "grass",
33
+ description = description)
34
+
35
+ iface.launch()