Skip to content

vllm.model_executor.models.ming_audio

Reusable Ming audio tower and checkpoint-compatible projector.

Functions:

get_audio_token_count(config, num_frames, chunk_frames)

Count projected frames with independent encoder positions for each chunk.

Source code in vllm/model_executor/models/ming_audio.py
def get_audio_token_count(
    config: MingAudioConfig, num_frames: int, chunk_frames: int
) -> int:
    """Count projected frames with independent encoder positions for each chunk."""
    if num_frames <= 0:
        raise ValueError("Audio must contain at least one mel frame")
    params = _get_audio_projector_params(config)

    def output_length(length: int) -> int:
        length = (length + 1) // 2
        for kernel, stride, padding in params:
            length = (length + 2 * padding - kernel) // stride + 1
        if length <= 0:
            raise ValueError("Audio chunk is too short for its projector")
        return length

    num_chunks, tail = divmod(num_frames, chunk_frames)
    return (num_chunks * output_length(chunk_frames) if num_chunks else 0) + (
        output_length(tail) if tail else 0
    )