Update functions.py
Browse files- functions.py +14 -18
functions.py
CHANGED
@@ -119,19 +119,7 @@ def load_prompt():
|
|
119 |
|
120 |
# return audio_file, title
|
121 |
|
122 |
-
|
123 |
-
@st.cache_data
|
124 |
-
def get_yt_audio(url):
|
125 |
-
|
126 |
-
yt = YouTube(url)
|
127 |
-
|
128 |
-
# Get the first available audio stream and download it
|
129 |
-
audio_stream = yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().first().download()
|
130 |
-
title = audio_stream.split('\\')[-1].split('.')[0]
|
131 |
-
|
132 |
-
return audio_stream, title
|
133 |
-
|
134 |
-
|
135 |
@st.cache_resource
|
136 |
def load_models():
|
137 |
|
@@ -151,14 +139,22 @@ def load_models():
|
|
151 |
|
152 |
return sent_pipe, sum_pipe, ner_pipe, cross_encoder, kg_model, kg_tokenizer, emb_tokenizer, sbert
|
153 |
|
154 |
-
@st.
|
155 |
-
def
|
156 |
-
|
157 |
-
|
158 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
|
160 |
@st.cache_data
|
161 |
def load_whisper_api(audio):
|
|
|
|
|
162 |
file = open(audio, "rb")
|
163 |
transcript = openai.Audio.translate("whisper-1", file)
|
164 |
|
|
|
119 |
|
120 |
# return audio_file, title
|
121 |
|
122 |
+
#load all required models and cache
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
@st.cache_resource
|
124 |
def load_models():
|
125 |
|
|
|
139 |
|
140 |
return sent_pipe, sum_pipe, ner_pipe, cross_encoder, kg_model, kg_tokenizer, emb_tokenizer, sbert
|
141 |
|
142 |
+
@st.cache_data
|
143 |
+
def get_yt_audio(url):
|
144 |
+
|
145 |
+
'''Get YT video from given URL link'''
|
146 |
+
yt = YouTube(url)
|
147 |
+
|
148 |
+
# Get the first available audio stream and download it
|
149 |
+
audio_stream = yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().first().download()
|
150 |
+
title = audio_stream.split('\\')[-1].split('.')[0]
|
151 |
+
|
152 |
+
return audio_stream, title
|
153 |
|
154 |
@st.cache_data
|
155 |
def load_whisper_api(audio):
|
156 |
+
|
157 |
+
'''Transcribe YT audio to text using Open AI API'''
|
158 |
file = open(audio, "rb")
|
159 |
transcript = openai.Audio.translate("whisper-1", file)
|
160 |
|