harp-dev commited on
Commit
0ee1134
·
verified ·
1 Parent(s): c5c0a6a

Drop the length cap on the music, keeping the reservation sized to it

Browse files

The 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.

Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -121,8 +121,11 @@ def _resolve_instruments(text: str) -> tuple[list[str] | None, str]:
121
 
122
  # The audio is transcribed in five-second segments, so the cost grows with its length, and with the
123
  # size of the model. Measured at 9 s for both 20 s and 60 s of audio on medium, which batches the
124
- # segments, and at 7 s and 14 s on large, padded, so ten minutes stays under 200 s on every size
125
- MAX_INPUT_SECONDS = 600
 
 
 
126
  SECONDS_PER_INPUT_SECOND = {"small": 0.1, "medium": 0.15, "large": 0.3}
127
 
128
 
@@ -146,10 +149,11 @@ def process_fn(
146
  duration = sf.info(input_audio_path).duration
147
  except Exception as exc:
148
  raise gr.Error(f"Could not read the audio file: {exc}") from exc
149
- if duration > MAX_INPUT_SECONDS:
 
150
  raise gr.Error(
151
- f"The music is {duration:.1f} s long. Trim it to {MAX_INPUT_SECONDS // 60} minutes "
152
- "or less."
153
  )
154
  return transcribe(input_audio_path, variant, instruments_text, use_sampling, temperature)
155
 
 
121
 
122
  # The audio is transcribed in five-second segments, so the cost grows with its length, and with the
123
  # size of the model. Measured at 9 s for both 20 s and 60 s of audio on medium, which batches the
124
+ # segments, and at 7 s and 14 s on large, and at 58 s for 600 s on medium, padded
125
+ # PyHARP stops a job that runs past its timeout_s, 15 minutes by default, so a request whose
126
+ # reservation would exceed that is refused rather than started. A shorter one is left to
127
+ # ZeroGPU, which admits it when the caller's own allowance covers it.
128
+ MAX_GPU_SECONDS = 900
129
  SECONDS_PER_INPUT_SECOND = {"small": 0.1, "medium": 0.15, "large": 0.3}
130
 
131
 
 
149
  duration = sf.info(input_audio_path).duration
150
  except Exception as exc:
151
  raise gr.Error(f"Could not read the audio file: {exc}") from exc
152
+ if gpu_seconds(input_audio_path, variant, instruments_text, use_sampling,
153
+ temperature) > MAX_GPU_SECONDS:
154
  raise gr.Error(
155
+ f"The music is {duration:.0f} s long, more than one request can transcribe in the "
156
+ f"{MAX_GPU_SECONDS // 60} minutes it may run. Trim it, or use a smaller model."
157
  )
158
  return transcribe(input_audio_path, variant, instruments_text, use_sampling, temperature)
159