nickmuchi commited on
Commit
46d8fce
1 Parent(s): b915b56

Update functions.py

Browse files
Files changed (1) hide show
  1. functions.py +6 -5
functions.py CHANGED
@@ -196,11 +196,12 @@ def inference(link, upload, _asr_model):
196
 
197
  audio_file, title = get_yt_audio(link)
198
 
199
- if 'audio' not in st.session_state:
200
- st.session_state['audio'] = audio_file
 
201
 
202
  #Get size of audio file
203
- audio_size = round(os.path.getsize(audio_file)/(1024*1024),1)
204
 
205
  #Check if file is > 24mb, if not then use Whisper API
206
  if audio_size <= 25:
@@ -208,13 +209,13 @@ def inference(link, upload, _asr_model):
208
  st.info("`Transcribing YT audio...`")
209
 
210
  #Use whisper API
211
- results = load_whisper_api(audio_file)['text']
212
 
213
  else:
214
 
215
  st.warning('File size larger than 24mb, applying chunking and transcription',icon="⚠️")
216
 
217
- song = AudioSegment.from_file(audio_file, format='mp4')
218
 
219
  # PyDub handles time in milliseconds
220
  twenty_minutes = 20 * 60 * 1000
 
196
 
197
  audio_file, title = get_yt_audio(link)
198
 
199
+ print(f'audio_file:{audio_file}')
200
+
201
+ st.session_state['audio'] = audio_file
202
 
203
  #Get size of audio file
204
+ audio_size = round(os.path.getsize(st.session_state['audio'])/(1024*1024),1)
205
 
206
  #Check if file is > 24mb, if not then use Whisper API
207
  if audio_size <= 25:
 
209
  st.info("`Transcribing YT audio...`")
210
 
211
  #Use whisper API
212
+ results = load_whisper_api(st.session_state['audio'])['text']
213
 
214
  else:
215
 
216
  st.warning('File size larger than 24mb, applying chunking and transcription',icon="⚠️")
217
 
218
+ song = AudioSegment.from_file(st.session_state['audio'], format='mp4')
219
 
220
  # PyDub handles time in milliseconds
221
  twenty_minutes = 20 * 60 * 1000