Spaces:
Running on Zero
Running on Zero
Size the GPU reservation by measured cost.
Browse files119 unmodified lines12012112212312412512612712821 unmodified lines150151152153154155156157158159160119 unmodified lines# The audio is transcribed in five-second segments, so the cost grows with its length, and with the# size of the modelMAX_INPUT_SECONDS = 600SECONDS_PER_INPUT_SECOND = {"small": 0.5, "medium": 1.0, "large": 2.0}def gpu_seconds(input_audio_path, variant, instruments_text, use_sampling, temperature):21 unmodified linesf"The music is {duration:.1f} s long. Trim it to {MAX_INPUT_SECONDS // 60} minutes ""or less.")if gpu_seconds(input_audio_path, variant, instruments_text, use_sampling, temperature) > 200:raise gr.Error(f"The {variant} model would need more GPU time for {duration:.0f} s of music than a ""request can reserve. Choose a smaller model or trim the music.")return transcribe(input_audio_path, variant, instruments_text, use_sampling, temperature)119 unmodified lines12012112212312412512612712812921 unmodified lines151152153154155156119 unmodified lines# The audio is transcribed in five-second segments, so the cost grows with its length, and with the# size of the model. Measured at 9 s for both 20 s and 60 s of audio on medium, which batches the# segments, and at 7 s and 14 s on large, padded, so ten minutes stays under 200 s on every sizeMAX_INPUT_SECONDS = 600SECONDS_PER_INPUT_SECOND = {"small": 0.1, "medium": 0.15, "large": 0.3}def gpu_seconds(input_audio_path, variant, instruments_text, use_sampling, temperature):21 unmodified linesf"The music is {duration:.1f} s long. Trim it to {MAX_INPUT_SECONDS // 60} minutes ""or less.")return transcribe(input_audio_path, variant, instruments_text, use_sampling, temperature)
app.py+3-7