Spaces:
Running on Zero
Running on Zero
Drop the length cap on the recording, keeping the reservation sized to it
Browse filesThe model works through it in segments or chunks, so its length costs time rather than memory. ZeroGPU already refuses a request that the caller's tier or remaining allowance cannot cover, before reserving anything, and tells a free account how to get more. A cap set so that a free account could afford every request therefore only turned away callers who could. The only request refused here now is one whose reservation would outlast PyHARP's 15 minute timeout, which would stop it anyway.
app.py
CHANGED
|
@@ -52,8 +52,11 @@ def load_model(device: str):
|
|
| 52 |
model.eval()
|
| 53 |
return model
|
| 54 |
|
| 55 |
-
# The
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
|
| 59 |
def gpu_seconds(input_file):
|
|
@@ -103,10 +106,10 @@ def process_fn(input_audio_path: str) -> str:
|
|
| 103 |
duration = sf.info(input_audio_path).duration
|
| 104 |
except Exception as exc:
|
| 105 |
raise gr.Error(f"Could not read the audio file: {exc}") from exc
|
| 106 |
-
if
|
| 107 |
raise gr.Error(
|
| 108 |
-
f"The recording is {duration:.
|
| 109 |
-
"minutes
|
| 110 |
)
|
| 111 |
midi_path = transcribe(input_audio_path)
|
| 112 |
return midi_path
|
|
|
|
| 52 |
model.eval()
|
| 53 |
return model
|
| 54 |
|
| 55 |
+
# The recording is transcribed in overlapping segments, so the cost grows with its length
|
| 56 |
+
# PyHARP stops a job that runs past its timeout_s, 15 minutes by default, so a request whose
|
| 57 |
+
# reservation would exceed that is refused rather than started. A shorter one is left to
|
| 58 |
+
# ZeroGPU, which admits it when the caller's own allowance covers it.
|
| 59 |
+
MAX_GPU_SECONDS = 900
|
| 60 |
|
| 61 |
|
| 62 |
def gpu_seconds(input_file):
|
|
|
|
| 106 |
duration = sf.info(input_audio_path).duration
|
| 107 |
except Exception as exc:
|
| 108 |
raise gr.Error(f"Could not read the audio file: {exc}") from exc
|
| 109 |
+
if gpu_seconds(input_audio_path) > MAX_GPU_SECONDS:
|
| 110 |
raise gr.Error(
|
| 111 |
+
f"The recording is {duration:.0f} s long, more than one request can transcribe in "
|
| 112 |
+
f"the {MAX_GPU_SECONDS // 60} minutes it may run. Trim it."
|
| 113 |
)
|
| 114 |
midi_path = transcribe(input_audio_path)
|
| 115 |
return midi_path
|