Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import transformers
|
3 |
+
import youtube_transcript_api
|
4 |
+
from transformers import pipeline
|
5 |
+
from youtube_transcript_api import YouTubeTranscriptApi
|
6 |
+
|
7 |
+
def greet(link):
|
8 |
+
try:
|
9 |
+
unique_id = link.split("=")[-1]
|
10 |
+
sub = YouTubeTranscriptApi.get_transcript(unique_id)
|
11 |
+
subtitle = " ".join([w['text'] for w in sub])
|
12 |
+
summary = summarizer(subtitle, max_length=180, min_length=30, do_sample=False)
|
13 |
+
return summary[0]['summary_text']
|
14 |
+
except:
|
15 |
+
return 'Invalid URL'
|
16 |
+
|
17 |
+
demo=gr.Interface(fn=greet, inputs="text", outputs="text")
|
18 |
+
|
19 |
+
if __name__ == "__main__":
|
20 |
+
demo.launch()
|