Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import yt_dlp
|
| 3 |
+
from transformers import pipeline
|
| 4 |
+
|
| 5 |
+
summarizer = pipeline("summarization")
|
| 6 |
+
|
| 7 |
+
def summarize(url):
|
| 8 |
+
ydl_opts = {"quiet": True}
|
| 9 |
+
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
| 10 |
+
info = ydl.extract_info(url, download=False)
|
| 11 |
+
text = info["description"]
|
| 12 |
+
|
| 13 |
+
out = summarizer(text[:1000])[0]["summary_text"]
|
| 14 |
+
return out
|
| 15 |
+
|
| 16 |
+
gr.Interface(summarize, "text", "text", title="YouTube Summarizer").launch()
|