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

Size the GPU reservation by measured cost.

Browse files
Files changed (1) hide show
  1. app.py +3 -7
app.py CHANGED
@@ -120,9 +120,10 @@ def _resolve_instruments(text: str) -> tuple[list[str] | None, str]:
120
 
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
 
124
  MAX_INPUT_SECONDS = 600
125
- SECONDS_PER_INPUT_SECOND = {"small": 0.5, "medium": 1.0, "large": 2.0}
126
 
127
 
128
  def gpu_seconds(input_audio_path, variant, instruments_text, use_sampling, temperature):
@@ -150,11 +151,6 @@ def process_fn(
150
  f"The music is {duration:.1f} s long. Trim it to {MAX_INPUT_SECONDS // 60} minutes "
151
  "or less."
152
  )
153
- if gpu_seconds(input_audio_path, variant, instruments_text, use_sampling, temperature) > 200:
154
- raise gr.Error(
155
- f"The {variant} model would need more GPU time for {duration:.0f} s of music than a "
156
- "request can reserve. Choose a smaller model or trim the music."
157
- )
158
  return transcribe(input_audio_path, variant, instruments_text, use_sampling, temperature)
159
 
160
 
 
120
 
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
 
129
  def gpu_seconds(input_audio_path, variant, instruments_text, use_sampling, temperature):
 
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
 
156