Spaces:
Runtime error
Runtime error
Update util.py
Browse files
util.py
CHANGED
|
@@ -46,8 +46,8 @@ def get_subtitles(video_url):
|
|
| 46 |
from youtube_transcript_api import YouTubeTranscriptApi
|
| 47 |
|
| 48 |
|
| 49 |
-
def restore_punctuation(text):
|
| 50 |
-
model =
|
| 51 |
result = model.restore_punctuation(text)
|
| 52 |
return result
|
| 53 |
|
|
@@ -124,19 +124,3 @@ def display(text):
|
|
| 124 |
return formatted_sentences
|
| 125 |
|
| 126 |
|
| 127 |
-
|
| 128 |
-
def pipeline(url, model, tokenizer):
|
| 129 |
-
trans, sub = get_subtitles(url)
|
| 130 |
-
sub = restore_punctuation(sub)
|
| 131 |
-
vie_sub = translate_long(sub)
|
| 132 |
-
vie_sub = processed(vie_sub)
|
| 133 |
-
chunks = split_into_chunks(vie_sub, 700, 2)
|
| 134 |
-
sum_para = []
|
| 135 |
-
for i in chunks:
|
| 136 |
-
tmp = summarize(i, model, tokenizer, num_beams=3)
|
| 137 |
-
sum_para.append(tmp)
|
| 138 |
-
suma = ''.join(sum_para)
|
| 139 |
-
del sub, vie_sub, sum_para, chunks
|
| 140 |
-
suma = post_processing(suma)
|
| 141 |
-
re = display(suma)
|
| 142 |
-
return re
|
|
|
|
| 46 |
from youtube_transcript_api import YouTubeTranscriptApi
|
| 47 |
|
| 48 |
|
| 49 |
+
def restore_punctuation(text, model_restore):
|
| 50 |
+
model = model_restore
|
| 51 |
result = model.restore_punctuation(text)
|
| 52 |
return result
|
| 53 |
|
|
|
|
| 124 |
return formatted_sentences
|
| 125 |
|
| 126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|