jipenaflor commited on
Commit
d327f28
·
1 Parent(s): abd60ad

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from youtube_transcript_api import YouTubeTranscriptApi
2
+ import gradio as gr
3
+ from gradio.mix import Series
4
+
5
+ def generate_transcript(url):
6
+ id = url[url.index("=")+1:]
7
+
8
+ transcript = YouTubeTranscriptApi.get_transcript(id)
9
+ script = ""
10
+
11
+ for text in transcript:
12
+ t = text["text"]
13
+ if t != '[Music]':
14
+ script += t + " "
15
+
16
+ return script
17
+
18
+ transcriber = gr.Interface(generate_transcript, 'text', 'text')
19
+ summarizer = gr.Interface.load("huggingface/facebook/bart-large-cnn")
20
+
21
+ gradio_ui = Series(transcriber, summarizer,
22
+ inputs = gr.inputs.Textbox(label = "Enter the Youtube URL below:"),
23
+ outputs = "text",
24
+ title = "Youtube Video Summarizer",
25
+ theme = "grass",
26
+ description = "This application uses facebook/bart-large-cnn to summarize a Youtube video based on its transcript. ")
27
+
28
+ gradio_ui.launch()