Update functions.py
Browse files- functions.py +5 -4
functions.py
CHANGED
@@ -167,6 +167,7 @@ def get_yt_audio(url):
|
|
167 |
|
168 |
return audio_stream, title
|
169 |
|
|
|
170 |
def load_whisper_api(audio):
|
171 |
|
172 |
'''Transcribe YT audio to text using Open AI API'''
|
@@ -226,8 +227,8 @@ def inference(link, upload, _asr_model):
|
|
226 |
transcriptions = []
|
227 |
|
228 |
for i, chunk in enumerate(chunks):
|
229 |
-
chunk.export(f'output/chunk_{i}.mp4', format='mp4')
|
230 |
-
transcriptions.append(load_whisper_api(f'output/chunk_{i}.mp4')['text'])
|
231 |
|
232 |
results = ','.join(transcriptions)
|
233 |
|
@@ -264,8 +265,8 @@ def inference(link, upload, _asr_model):
|
|
264 |
st.info("`Transcribing uploaded audio...`")
|
265 |
|
266 |
for i, chunk in enumerate(chunks):
|
267 |
-
chunk.export(f'output/chunk_{i}.
|
268 |
-
transcriptions.append(load_whisper_api('output/chunk_{i}.
|
269 |
|
270 |
results = ','.join(transcriptions)
|
271 |
|
|
|
167 |
|
168 |
return audio_stream, title
|
169 |
|
170 |
+
@st.cache_data
|
171 |
def load_whisper_api(audio):
|
172 |
|
173 |
'''Transcribe YT audio to text using Open AI API'''
|
|
|
227 |
transcriptions = []
|
228 |
|
229 |
for i, chunk in enumerate(chunks):
|
230 |
+
chunk.export(f'output/chunk_{i}_{link}.mp4', format='mp4')
|
231 |
+
transcriptions.append(load_whisper_api(f'output/chunk_{i}_{link}.mp4')['text'])
|
232 |
|
233 |
results = ','.join(transcriptions)
|
234 |
|
|
|
265 |
st.info("`Transcribing uploaded audio...`")
|
266 |
|
267 |
for i, chunk in enumerate(chunks):
|
268 |
+
chunk.export(f'output/chunk_{i}.mp4', format='mp4')
|
269 |
+
transcriptions.append(load_whisper_api('output/chunk_{i}.mp4')['text'])
|
270 |
|
271 |
results = ','.join(transcriptions)
|
272 |
|