Spaces:
Running on Zero
Running on Zero
Size ZeroGPU reservation by audio length
Browse files
app.py
CHANGED
|
@@ -63,7 +63,16 @@ def _pruefe(key):
|
|
| 63 |
return bool(key) and key == APP_KEY
|
| 64 |
|
| 65 |
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
def _analyse_gpu(audio_path, num_speakers):
|
| 68 |
kwargs = {}
|
| 69 |
if num_speakers and int(num_speakers) > 0:
|
|
|
|
| 63 |
return bool(key) and key == APP_KEY
|
| 64 |
|
| 65 |
|
| 66 |
+
def _gpu_dauer(audio_path, num_speakers):
|
| 67 |
+
"""Reserviert GPU-Zeit passend zur Audiolänge statt pauschal zu viel."""
|
| 68 |
+
try:
|
| 69 |
+
laenge = loader.get_duration(audio_path)
|
| 70 |
+
except Exception:
|
| 71 |
+
laenge = 600
|
| 72 |
+
return int(min(120, max(30, 15 + laenge / 6)))
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
@spaces.GPU(duration=_gpu_dauer)
|
| 76 |
def _analyse_gpu(audio_path, num_speakers):
|
| 77 |
kwargs = {}
|
| 78 |
if num_speakers and int(num_speakers) > 0:
|