harp-dev Claude Opus 5.5 commited on
Commit
4ceb571
·
verified ·
1 Parent(s): c31ecc7

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
@@ -133,6 +133,8 @@ def process_fn(input_audio_path: str, ddim_steps: int, guidance_scale: float, se
133
  info = sf.info(input_audio_path)
134
  except Exception as exc:
135
  raise gr.Error(f"Could not read the audio file: {exc}") from exc
 
 
136
  if gpu_seconds(input_audio_path, ddim_steps, guidance_scale, 0) > MAX_GPU_SECONDS:
137
  raise gr.Error(
138
  f"{int(ddim_steps)} DDIM steps on {info.duration:.0f} s of audio need more GPU time than "
 
133
  info = sf.info(input_audio_path)
134
  except Exception as exc:
135
  raise gr.Error(f"Could not read the audio file: {exc}") from exc
136
+ if info.frames == 0:
137
+ raise gr.Error("The audio file is empty.")
138
  if gpu_seconds(input_audio_path, ddim_steps, guidance_scale, 0) > MAX_GPU_SECONDS:
139
  raise gr.Error(
140
  f"{int(ddim_steps)} DDIM steps on {info.duration:.0f} s of audio need more GPU time than "