harp-dev Claude Opus 5.5 commited on
Commit
a017c1f
·
verified ·
1 Parent(s): 01f0475

Refuse an empty file before the GPU is reserved

Browse files

An audio file of no frames passed the checks in process_fn, since soundfile reads it without complaint and the limits checked are maximums, so it reached the GPU call and failed there, spending the caller's ZeroGPU allowance. It is refused with a message first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +2 -0
app.py CHANGED
@@ -189,6 +189,8 @@ def process_fn(input_audio, sampletemp, periodic_p, dropout, n_mask_codebooks, m
189
  duration = sf.info(input_audio).duration
190
  except Exception as exc:
191
  raise gr.Error(f"Could not read the audio file: {exc}") from exc
 
 
192
  output_seconds = duration * max(1, int(stretch_factor))
193
  if gpu_seconds(input_audio, sampletemp, periodic_p, dropout, n_mask_codebooks, model_choice,
194
  stretch_factor) > MAX_GPU_SECONDS:
 
189
  duration = sf.info(input_audio).duration
190
  except Exception as exc:
191
  raise gr.Error(f"Could not read the audio file: {exc}") from exc
192
+ if duration == 0:
193
+ raise gr.Error("The audio file is empty.")
194
  output_seconds = duration * max(1, int(stretch_factor))
195
  if gpu_seconds(input_audio, sampletemp, periodic_p, dropout, n_mask_codebooks, model_choice,
196
  stretch_factor) > MAX_GPU_SECONDS: