amarkc commited on
Commit
351ec52
1 Parent(s): 4918985

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py CHANGED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/sshleifer/distilbart-cnn-12-6")
20
+
21
+ gradio_ui = Series(transcriber, summarizer,
22
+ inputs = gr.inputs.Textbox(label = "Enter the YouTube URL below:"),
23
+ outputs = gr.outputs.Textbox(label = "Transcript Summary"),
24
+ examples = ["https://www.youtube.com/watch?v=Cu3R5it4cQs&list", "https://www.youtube.com/watch?v=HB4I2CgkcCo"],
25
+ title = "YouTube Transcript Summarizer",
26
+ theme = "peach",
27
+ 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.")
28
+
29
+ gradio_ui.launch()