harp-dev Claude Opus 5.5 commited on
Commit
f35abfe
·
verified ·
1 Parent(s): 6146979

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
@@ -96,6 +96,8 @@ def process_fn(
96
  duration = sf.info(input_audio_path).duration
97
  except Exception as exc:
98
  raise gr.Error(f"Could not read the audio file: {exc}") from exc
 
 
99
  if gpu_seconds(input_audio_path) > MAX_GPU_SECONDS:
100
  raise gr.Error(
101
  f"The recording is {duration:.0f} s long, more than one request can restore in the "
 
96
  duration = sf.info(input_audio_path).duration
97
  except Exception as exc:
98
  raise gr.Error(f"Could not read the audio file: {exc}") from exc
99
+ if duration == 0:
100
+ raise gr.Error("The audio file is empty.")
101
  if gpu_seconds(input_audio_path) > MAX_GPU_SECONDS:
102
  raise gr.Error(
103
  f"The recording is {duration:.0f} s long, more than one request can restore in the "