Skip to content

vllm.entrypoints.speech_to_text.base.utils

Shared utilities for speech-to-text API routes.

Functions:

read_upload_with_limit(file, max_size_mb=None) async

Read an uploaded file enforcing a size limit before full materialization.

The function first checks the Content-Length header (file.size) when available. Regardless, it then performs a chunked read that stops as soon as the accumulated bytes exceed the limit, ensuring that an oversized upload never fully materializes in memory.

Parameters:

  • file

    (UploadFile) –

    The FastAPI/Starlette UploadFile object.

  • max_size_mb

    (float | None, default: None ) –

    Maximum allowed compressed file size in megabytes. Defaults to envs.VLLM_MAX_AUDIO_CLIP_FILESIZE_MB.

Returns:

  • bytes –

    The file content as bytes.

Raises: