@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 63d92abb7c
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 14, 23:45 UTC

[Frontend] Set MAX_AUDIO_CLIP_FILESIZE_MB via env var instead of hardcoding (#21374)

Signed-off-by: Deven Labovitch <deven@videa.ai>

deven-labovitch committed Jul 23, 2025 at 23:22 UTC 63d92abb7ce6597abb4215f5869bb48b7acc2f73
3 files changed +16 -5
docs/serving/openai_compatible_server.md
+5
@@ -351,6 +351,11 @@ you can use the [official OpenAI Python client](https://github.com/openai/openai
351 Code example: <gh-file:examples/online_serving/openai_transcription_client.py>
352 <!-- TODO: api enforced limits + uploading audios -->
353
354 +#### API Enforced Limits
355 +
356 +Set the maximum audio file size (in MB) that VLLM will accept, via the
357 +`VLLM_MAX_AUDIO_CLIP_FILESIZE_MB` environment variable. Default is 25 MB.
358 +
359 #### Extra Parameters
360
361 The following [sampling parameters][sampling-params] are supported.
vllm/entrypoints/openai/speech_to_text.py
+4 -5
@@ -11,6 +11,7 @@ from typing import Callable, Literal, Optional, TypeVar, Union, cast
11 import numpy as np
12 from fastapi import Request
13
14 +import vllm.envs as envs
15 from vllm.config import ModelConfig
16 from vllm.engine.protocol import EngineClient
17 from vllm.entrypoints.logger import RequestLogger
@@ -38,10 +39,6 @@ T = TypeVar("T", bound=SpeechToTextResponse)
39
40 logger = init_logger(__name__)
41
41 -# As per https://platform.openai.com/docs/guides/speech-to-text#overview.
42 -# TODO configurable
43 -MAX_AUDIO_CLIP_FILESIZE_MB = 25
44 -
42
43 class OpenAISpeechToText(OpenAIServing):
44 """Base class for speech-to-text operations like transcription and
@@ -70,6 +67,8 @@ class OpenAISpeechToText(OpenAIServing):
67 self.asr_config = self.model_cls.get_speech_to_text_config(
68 model_config, task_type)
69
70 + self.max_audio_filesize_mb = envs.VLLM_MAX_AUDIO_CLIP_FILESIZE_MB
71 +
72 if self.default_sampling_params:
73 logger.info(
74 "Overwriting default completion sampling param with: %s",
@@ -93,7 +92,7 @@ class OpenAISpeechToText(OpenAIServing):
92 lang = request.language or "en"
93 self.model_cls.validate_language(lang)
94
96 - if len(audio_data) / 1024**2 > MAX_AUDIO_CLIP_FILESIZE_MB:
95 + if len(audio_data) / 1024**2 > self.max_audio_filesize_mb:
96 raise ValueError("Maximum file size exceeded.")
97
98 with io.BytesIO(audio_data) as bytes_:
vllm/envs.py
+7
@@ -61,6 +61,7 @@ if TYPE_CHECKING:
61 VLLM_IMAGE_FETCH_TIMEOUT: int = 5
62 VLLM_VIDEO_FETCH_TIMEOUT: int = 30
63 VLLM_AUDIO_FETCH_TIMEOUT: int = 10
64 + VLLM_MAX_AUDIO_CLIP_FILESIZE_MB: int = 25
65 VLLM_VIDEO_LOADER_BACKEND: str = "opencv"
66 VLLM_MM_INPUT_CACHE_GIB: int = 8
67 VLLM_TARGET_DEVICE: str = "cuda"
@@ -519,6 +520,12 @@ environment_variables: dict[str, Callable[[], Any]] = {
520 "VLLM_AUDIO_FETCH_TIMEOUT":
521 lambda: int(os.getenv("VLLM_AUDIO_FETCH_TIMEOUT", "10")),
522
523 + # Maximum filesize in MB for a single audio file when processing
524 + # speech-to-text requests. Files larger than this will be rejected.
525 + # Default is 25 MB
526 + "VLLM_MAX_AUDIO_CLIP_FILESIZE_MB":
527 + lambda: int(os.getenv("VLLM_MAX_AUDIO_CLIP_FILESIZE_MB", "25")),
528 +
529 # Backend for Video IO
530 # - "opencv": Default backend that uses OpenCV stream buffered backend.
531 #