Spaces:
Running on Zero
Running on Zero
Fit inference limits to ZeroGPU xlarge quota
Browse files
app.py
CHANGED
|
@@ -212,8 +212,9 @@ TASK_PROMPTS = {
|
|
| 212 |
"Answer a question about the audio": "What is being said in this audio, and what is the tone?",
|
| 213 |
}
|
| 214 |
GREEDY_TASKS = {"Transcribe (ASR)", "Translate speech to English"}
|
| 215 |
-
MAX_AUDIO_DURATION_SECONDS =
|
| 216 |
-
|
|
|
|
| 217 |
|
| 218 |
|
| 219 |
def _probe_audio_duration(audio: str | None) -> float:
|
|
@@ -238,12 +239,16 @@ def _estimate(
|
|
| 238 |
**kwargs: object,
|
| 239 |
) -> int:
|
| 240 |
audio_duration = _probe_audio_duration(audio)
|
| 241 |
-
if
|
|
|
|
|
|
|
|
|
|
|
|
|
| 242 |
return 10
|
| 243 |
|
| 244 |
clip_duration = float(getattr(config, "sound_clip_duration", 30.0))
|
| 245 |
num_clips = max(1, math.ceil(audio_duration / clip_duration))
|
| 246 |
-
duration =
|
| 247 |
return int(min(MAX_GPU_DURATION_SECONDS, math.ceil(duration)))
|
| 248 |
|
| 249 |
|
|
@@ -267,6 +272,8 @@ def _generate(
|
|
| 267 |
f"Audio is {audio_duration / 60:.1f} minutes long; "
|
| 268 |
f"this demo supports up to {MAX_AUDIO_DURATION_SECONDS / 60:.0f} minutes."
|
| 269 |
)
|
|
|
|
|
|
|
| 270 |
|
| 271 |
input_features = extract_whisper_features(
|
| 272 |
feature_extractor, wav, sample_rate=sr,
|
|
@@ -333,7 +340,7 @@ def run(
|
|
| 333 |
|
| 334 |
Predefined ASR and translation tasks use the model's recommended greedy
|
| 335 |
decoding. Other tasks and custom instructions use the sampling controls.
|
| 336 |
-
Audio may be up to
|
| 337 |
|
| 338 |
Returns:
|
| 339 |
The final answer and, when enabled, the reasoning trace.
|
|
@@ -371,7 +378,7 @@ with gr.Blocks(title="Nemotron-Labs-Audex-30B-A3B") as demo:
|
|
| 371 |
with gr.Column():
|
| 372 |
audio_in = gr.Audio(
|
| 373 |
type="filepath",
|
| 374 |
-
label="Input audio (up to
|
| 375 |
sources=["upload", "microphone"],
|
| 376 |
)
|
| 377 |
task = gr.Radio(
|
|
@@ -387,7 +394,13 @@ with gr.Blocks(title="Nemotron-Labs-Audex-30B-A3B") as demo:
|
|
| 387 |
run_btn = gr.Button("Run", variant="primary")
|
| 388 |
with gr.Accordion("Advanced options", open=False):
|
| 389 |
reasoning = gr.Checkbox(value=False, label="Enable reasoning (<think>) mode")
|
| 390 |
-
max_new_tokens = gr.Slider(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 391 |
temperature = gr.Slider(0.1, 1.5, value=0.7, step=0.05, label="Temperature")
|
| 392 |
top_p = gr.Slider(0.1, 1.0, value=0.9, step=0.05, label="Top-p")
|
| 393 |
gr.Markdown(
|
|
|
|
| 212 |
"Answer a question about the audio": "What is being said in this audio, and what is the tone?",
|
| 213 |
}
|
| 214 |
GREEDY_TASKS = {"Transcribe (ASR)", "Translate speech to English"}
|
| 215 |
+
MAX_AUDIO_DURATION_SECONDS = 120.0
|
| 216 |
+
MAX_NEW_TOKENS = 512
|
| 217 |
+
MAX_GPU_DURATION_SECONDS = 60
|
| 218 |
|
| 219 |
|
| 220 |
def _probe_audio_duration(audio: str | None) -> float:
|
|
|
|
| 239 |
**kwargs: object,
|
| 240 |
) -> int:
|
| 241 |
audio_duration = _probe_audio_duration(audio)
|
| 242 |
+
if (
|
| 243 |
+
audio is None
|
| 244 |
+
or audio_duration > MAX_AUDIO_DURATION_SECONDS
|
| 245 |
+
or int(max_new_tokens) > MAX_NEW_TOKENS
|
| 246 |
+
):
|
| 247 |
return 10
|
| 248 |
|
| 249 |
clip_duration = float(getattr(config, "sound_clip_duration", 30.0))
|
| 250 |
num_clips = max(1, math.ceil(audio_duration / clip_duration))
|
| 251 |
+
duration = 45 + (num_clips - 1) * 3 + (int(max_new_tokens) / MAX_NEW_TOKENS) * 10
|
| 252 |
return int(min(MAX_GPU_DURATION_SECONDS, math.ceil(duration)))
|
| 253 |
|
| 254 |
|
|
|
|
| 272 |
f"Audio is {audio_duration / 60:.1f} minutes long; "
|
| 273 |
f"this demo supports up to {MAX_AUDIO_DURATION_SECONDS / 60:.0f} minutes."
|
| 274 |
)
|
| 275 |
+
if max_new_tokens > MAX_NEW_TOKENS:
|
| 276 |
+
raise gr.Error(f"This demo supports up to {MAX_NEW_TOKENS} output tokens.")
|
| 277 |
|
| 278 |
input_features = extract_whisper_features(
|
| 279 |
feature_extractor, wav, sample_rate=sr,
|
|
|
|
| 340 |
|
| 341 |
Predefined ASR and translation tasks use the model's recommended greedy
|
| 342 |
decoding. Other tasks and custom instructions use the sampling controls.
|
| 343 |
+
Audio may be up to two minutes long, with up to 512 output tokens.
|
| 344 |
|
| 345 |
Returns:
|
| 346 |
The final answer and, when enabled, the reasoning trace.
|
|
|
|
| 378 |
with gr.Column():
|
| 379 |
audio_in = gr.Audio(
|
| 380 |
type="filepath",
|
| 381 |
+
label="Input audio (up to 2 minutes)",
|
| 382 |
sources=["upload", "microphone"],
|
| 383 |
)
|
| 384 |
task = gr.Radio(
|
|
|
|
| 394 |
run_btn = gr.Button("Run", variant="primary")
|
| 395 |
with gr.Accordion("Advanced options", open=False):
|
| 396 |
reasoning = gr.Checkbox(value=False, label="Enable reasoning (<think>) mode")
|
| 397 |
+
max_new_tokens = gr.Slider(
|
| 398 |
+
16,
|
| 399 |
+
MAX_NEW_TOKENS,
|
| 400 |
+
value=256,
|
| 401 |
+
step=16,
|
| 402 |
+
label="Max new tokens",
|
| 403 |
+
)
|
| 404 |
temperature = gr.Slider(0.1, 1.5, value=0.7, step=0.05, label="Temperature")
|
| 405 |
top_p = gr.Slider(0.1, 1.0, value=0.9, step=0.05, label="Top-p")
|
| 406 |
gr.Markdown(
|