harp-dev Claude Opus 5.5 commited on
Commit
2674bc9
·
verified ·
1 Parent(s): 4061195

Refuse an empty file

Browse files

An audio file of no frames reached the model and failed there with a decoding error. It is refused with a message instead.

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

Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -181,9 +181,11 @@ def process_fn(audio_path, threshold):
181
  if not audio_path:
182
  raise gr.Error("Provide the audio to clean.")
183
  try:
184
- sf.info(audio_path)
185
  except Exception as exc:
186
  raise gr.Error(f"Could not read the audio file: {exc}") from exc
 
 
187
 
188
  out_path = match_input_format(remove_effects(audio_path, threshold), audio_path)
189
 
 
181
  if not audio_path:
182
  raise gr.Error("Provide the audio to clean.")
183
  try:
184
+ info = sf.info(audio_path)
185
  except Exception as exc:
186
  raise gr.Error(f"Could not read the audio file: {exc}") from exc
187
+ if info.frames == 0:
188
+ raise gr.Error("The audio file is empty.")
189
 
190
  out_path = match_input_format(remove_effects(audio_path, threshold), audio_path)
191