harp-dev Claude Opus 5.5 commited on
Commit
9d32c13
·
verified ·
1 Parent(s): 4d3ab93

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
@@ -144,6 +144,8 @@ def process_fn(
144
  duration = sf.info(input_audio_path).duration
145
  except Exception as exc:
146
  raise gr.Error(f"Could not read the audio file: {exc}") from exc
 
 
147
  if gpu_seconds(input_audio_path, variant, instruments_text, use_sampling,
148
  temperature) > MAX_GPU_SECONDS:
149
  raise gr.Error(
 
144
  duration = sf.info(input_audio_path).duration
145
  except Exception as exc:
146
  raise gr.Error(f"Could not read the audio file: {exc}") from exc
147
+ if duration == 0:
148
+ raise gr.Error("The audio file is empty.")
149
  if gpu_seconds(input_audio_path, variant, instruments_text, use_sampling,
150
  temperature) > MAX_GPU_SECONDS:
151
  raise gr.Error(