Spaces:
Running
Running
Read the recording before the GPU is reserved
Browse filesThe recording was first read inside gpu_seconds, unwrapped, so an unreadable file failed with an uncaught exception and an empty one reached the GPU call. process_fn now reads it first and refuses either with a message.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
app.py
CHANGED
|
@@ -65,6 +65,14 @@ def process_fn(input_audio_path, prompt, num_inference_steps, guidance_scale,
|
|
| 65 |
|
| 66 |
# Checked before the GPU is reserved, so a request the model cannot take spends none of the
|
| 67 |
# caller's ZeroGPU allowance
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
if not (prompt or "").strip():
|
| 69 |
raise gr.Error("Describe what to change about the audio.")
|
| 70 |
if gpu_seconds(input_audio_path, prompt, num_inference_steps) > MAX_GPU_SECONDS:
|
|
|
|
| 65 |
|
| 66 |
# Checked before the GPU is reserved, so a request the model cannot take spends none of the
|
| 67 |
# caller's ZeroGPU allowance
|
| 68 |
+
if not input_audio_path:
|
| 69 |
+
raise gr.Error("Provide the recording to treat.")
|
| 70 |
+
try:
|
| 71 |
+
info = sf.info(input_audio_path)
|
| 72 |
+
except Exception as exc:
|
| 73 |
+
raise gr.Error(f"Could not read the audio file: {exc}") from exc
|
| 74 |
+
if info.frames == 0:
|
| 75 |
+
raise gr.Error("The audio file is empty.")
|
| 76 |
if not (prompt or "").strip():
|
| 77 |
raise gr.Error("Describe what to change about the audio.")
|
| 78 |
if gpu_seconds(input_audio_path, prompt, num_inference_steps) > MAX_GPU_SECONDS:
|