Update core.py
Browse files
core.py
CHANGED
|
@@ -5,6 +5,10 @@ import whisper
|
|
| 5 |
|
| 6 |
import datetime
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
transformers.utils.move_cache()
|
| 9 |
|
| 10 |
# ====================================
|
|
@@ -75,4 +79,22 @@ def text_summarize(text_input, lang):
|
|
| 75 |
elif lang == 'Vietnamese':
|
| 76 |
return text_summarize_vi(text_input)
|
| 77 |
else:
|
| 78 |
-
return ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
import datetime
|
| 7 |
|
| 8 |
+
import os
|
| 9 |
+
import gradio as gr
|
| 10 |
+
from pytube import YouTube
|
| 11 |
+
|
| 12 |
transformers.utils.move_cache()
|
| 13 |
|
| 14 |
# ====================================
|
|
|
|
| 79 |
elif lang == 'Vietnamese':
|
| 80 |
return text_summarize_vi(text_input)
|
| 81 |
else:
|
| 82 |
+
return ""
|
| 83 |
+
|
| 84 |
+
def load_video_url(url):
|
| 85 |
+
current_dir = os.getcwd()
|
| 86 |
+
|
| 87 |
+
try:
|
| 88 |
+
yt = YouTube(url)
|
| 89 |
+
except:
|
| 90 |
+
print("Connection Error")
|
| 91 |
+
raise gr.Error("Connection Error")
|
| 92 |
+
try:
|
| 93 |
+
highest_audio = yt.streams.filter(progressive=False).get_highest_resolution().itag
|
| 94 |
+
file_url = os.path.join(current_dir, "audio", "temp.mp4")
|
| 95 |
+
yt.streams.get_by_itag(highest_audio).download(output_path=os.path.join(current_dir, "audio"), filename = "temp.mp4")
|
| 96 |
+
except :
|
| 97 |
+
print("Download video error")
|
| 98 |
+
raise gr.Error("Download video error")
|
| 99 |
+
|
| 100 |
+
return file_url
|