Update functions.py
Browse files- functions.py +5 -5
functions.py
CHANGED
@@ -292,7 +292,7 @@ def get_spacy():
|
|
292 |
return nlp
|
293 |
|
294 |
@st.cache_data
|
295 |
-
def inference(link, title,
|
296 |
'''Convert Youtube video or Audio upload to text'''
|
297 |
|
298 |
try:
|
@@ -335,22 +335,22 @@ def inference(link, title, upload, _asr_model):
|
|
335 |
|
336 |
return results, title
|
337 |
|
338 |
-
elif
|
339 |
|
340 |
#Get size of audio file
|
341 |
-
audio_size = round(os.path.getsize(
|
342 |
|
343 |
#Check if file is > 24mb, if not then use Whisper API
|
344 |
if audio_size <= 25:
|
345 |
|
346 |
#Use whisper API
|
347 |
-
results = load_whisper_api(
|
348 |
|
349 |
else:
|
350 |
|
351 |
st.write('File size larger than 24mb, applying chunking and transcription')
|
352 |
|
353 |
-
song = AudioSegment.from_file(
|
354 |
|
355 |
# PyDub handles time in milliseconds
|
356 |
twenty_minutes = 20 * 60 * 1000
|
|
|
292 |
return nlp
|
293 |
|
294 |
@st.cache_data
|
295 |
+
def inference(link, title, _upload, _asr_model):
|
296 |
'''Convert Youtube video or Audio upload to text'''
|
297 |
|
298 |
try:
|
|
|
335 |
|
336 |
return results, title
|
337 |
|
338 |
+
elif _upload:
|
339 |
|
340 |
#Get size of audio file
|
341 |
+
audio_size = round(os.path.getsize(_upload)/(1024*1024),1)
|
342 |
|
343 |
#Check if file is > 24mb, if not then use Whisper API
|
344 |
if audio_size <= 25:
|
345 |
|
346 |
#Use whisper API
|
347 |
+
results = load_whisper_api(_upload)['text']
|
348 |
|
349 |
else:
|
350 |
|
351 |
st.write('File size larger than 24mb, applying chunking and transcription')
|
352 |
|
353 |
+
song = AudioSegment.from_file(_upload)
|
354 |
|
355 |
# PyDub handles time in milliseconds
|
356 |
twenty_minutes = 20 * 60 * 1000
|