Spaces:
Runtime error
Runtime error
owaiskha9654
commited on
Commit
Β·
bf4e114
1
Parent(s):
88d368f
Update app.py
Browse files
app.py
CHANGED
@@ -4,38 +4,42 @@ import gradio as gr
|
|
4 |
|
5 |
def summarize(Youtube_Video_Link):
|
6 |
video_id = Youtube_Video_Link.split("=")[1]
|
7 |
-
|
8 |
-
|
9 |
-
summarizer = pipeline('summarization',model='sshleifer/distilbart-cnn-12-6')
|
10 |
-
|
11 |
-
input_text = ""
|
12 |
-
for i in transcript:
|
13 |
-
input_text += ' ' + i['text']
|
14 |
-
|
15 |
-
num_iters = int(len(input_text)/1000)
|
16 |
-
summarized_text = []
|
17 |
-
for i in range(0, num_iters + 1):
|
18 |
-
start = 0
|
19 |
-
start = i * 1000
|
20 |
-
end = (i + 1) * 1000
|
21 |
-
print("input text \n" + input_text[start:end])
|
22 |
-
out = summarizer(input_text[start:end])
|
23 |
-
out = out[0]
|
24 |
-
out = out['summary_text']
|
25 |
-
print("Summarized text\n"+out)
|
26 |
-
summarized_text.append(out)
|
27 |
-
|
28 |
-
# inp = input_text.replace('\n','')
|
29 |
-
output_text=' '.join(summarized_text)
|
30 |
-
return output_text
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
title = "YouTube Live π Video Summarization"
|
33 |
examples = [
|
34 |
("https://www.youtube.com/watch?v=zKvd1JwJ4Po"),
|
35 |
("https://www.youtube.com/watch?v=9izcbNYmP8M"),
|
36 |
]
|
37 |
text1 = (
|
38 |
-
"<center>
|
|
|
39 |
"<center> Kaggle Profile <a href=\"https://www.kaggle.com/owaiskhan9654\">Link</a> <br> </center>"
|
40 |
)
|
41 |
description = "Get Youtube Video Summarization. Just Enter Youtube Video link below. Make sure Video has Captions and it is not very Long as Model Computation time will Increase."
|
|
|
4 |
|
5 |
def summarize(Youtube_Video_Link):
|
6 |
video_id = Youtube_Video_Link.split("=")[1]
|
7 |
+
try:
|
8 |
+
transcript = YouTubeTranscriptApi.get_transcript(video_id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
+
summarizer = pipeline('summarization',model='sshleifer/distilbart-cnn-12-6')
|
11 |
+
|
12 |
+
input_text = ""
|
13 |
+
for i in transcript:
|
14 |
+
input_text += ' ' + i['text']
|
15 |
+
|
16 |
+
num_iters = int(len(input_text)/1000)
|
17 |
+
summarized_text = []
|
18 |
+
for i in range(0, num_iters + 1):
|
19 |
+
start = 0
|
20 |
+
start = i * 1000
|
21 |
+
end = (i + 1) * 1000
|
22 |
+
print("input text \n" + input_text[start:end])
|
23 |
+
out = summarizer(input_text[start:end])
|
24 |
+
out = out[0]
|
25 |
+
out = out['summary_text']
|
26 |
+
print("Summarized text\n"+out)
|
27 |
+
summarized_text.append(out)
|
28 |
+
|
29 |
+
# inp = input_text.replace('\n','')
|
30 |
+
output_text=' '.join(summarized_text)
|
31 |
+
return output_text
|
32 |
+
except:
|
33 |
+
return "Some Error has occurred either with Video link passed is invalid or No Captions present for this video"
|
34 |
+
|
35 |
title = "YouTube Live π Video Summarization"
|
36 |
examples = [
|
37 |
("https://www.youtube.com/watch?v=zKvd1JwJ4Po"),
|
38 |
("https://www.youtube.com/watch?v=9izcbNYmP8M"),
|
39 |
]
|
40 |
text1 = (
|
41 |
+
"<center> Deployed by: Owais Ahmad Data Scientist at <b> Thoucentric </b> <a href=\"https://www.linkedin.com/in/owaiskhan9654/\">Visit Profile</a> <br></center>"
|
42 |
+
"<center> Model Used : Meta/Facebook's <b>distilbart-cnn-12-6</b> Documentation <a href=\"https://huggingface.co/docs/transformers/model_doc/bart#bart/\">Link</a><br></center>"
|
43 |
"<center> Kaggle Profile <a href=\"https://www.kaggle.com/owaiskhan9654\">Link</a> <br> </center>"
|
44 |
)
|
45 |
description = "Get Youtube Video Summarization. Just Enter Youtube Video link below. Make sure Video has Captions and it is not very Long as Model Computation time will Increase."
|