crypto-code commited on
Commit
9013494
β€’
1 Parent(s): 7270a13

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -250,21 +250,21 @@ def predict(
250
  video = read_video_pyav(container=container, indices=indices)
251
 
252
  if uid in generated_audio_files and len(generated_audio_files[uid]) != 0:
253
- audio_length_in_s = get_audio_length(generated_audio_files[uid][-1])
254
  sample_rate = 24000
255
  waveform, sr = torchaudio.load(generated_audio_files[uid][-1])
256
  if sample_rate != sr:
257
  waveform = torchaudio.functional.resample(waveform, orig_freq=sr, new_freq=sample_rate)
258
  audio = torch.mean(waveform, 0)
259
- audio_length_in_s = int(len(audio)//sample_rate)
260
  print(f"Audio Length: {audio_length_in_s}")
261
  else:
262
  generated_audio_files[uid] = []
263
  if video_path is not None:
264
- audio_length_in_s = get_video_length(video_path)
265
  print(f"Video Length: {audio_length_in_s}")
266
  if audio_path is not None:
267
- audio_length_in_s = get_audio_length(audio_path)
268
  generated_audio_files[uid].append(audio_path)
269
  print(f"Audio Length: {audio_length_in_s}")
270
 
 
250
  video = read_video_pyav(container=container, indices=indices)
251
 
252
  if uid in generated_audio_files and len(generated_audio_files[uid]) != 0:
253
+ audio_length_in_s = min(get_audio_length(generated_audio_files[uid][-1]), 30)
254
  sample_rate = 24000
255
  waveform, sr = torchaudio.load(generated_audio_files[uid][-1])
256
  if sample_rate != sr:
257
  waveform = torchaudio.functional.resample(waveform, orig_freq=sr, new_freq=sample_rate)
258
  audio = torch.mean(waveform, 0)
259
+ audio_length_in_s = min(int(len(audio)//sample_rate), 30)
260
  print(f"Audio Length: {audio_length_in_s}")
261
  else:
262
  generated_audio_files[uid] = []
263
  if video_path is not None:
264
+ audio_length_in_s = min(get_video_length(video_path), 30)
265
  print(f"Video Length: {audio_length_in_s}")
266
  if audio_path is not None:
267
+ audio_length_in_s = min(get_audio_length(audio_path), 30)
268
  generated_audio_files[uid].append(audio_path)
269
  print(f"Audio Length: {audio_length_in_s}")
270