vllm_omni.utils.qwen3_force_align_processor ¶
Qwen3 forced-aligner text/timestamp processor.
This is the model-specific half of upstream's Qwen3ForceAlignProcessor: it turns text into the aligner's word units and prompt, repairs the predicted timestamp bins, and resolves the marker token id. The generic "run a vLLM pooling model" half lives in :mod:vllm_omni.utils.forced_aligner, which calls into this module.
Keeping the Qwen-specific pieces here marks the seam for the model-agnostic aligner the issue asks for: a different aligner family would supply its own processor exposing the same small surface — :func:segment_words, :func:build_prompt, :func:fix_timestamp, :func:resolve_timestamp_token_id.
Word segmentation prefers qwen_asr's official Qwen3ForceAlignProcessor when installed (full multilingual fidelity, incl. Japanese/Korean) and otherwise uses the faithful port below: exact for whitespace-delimited and Chinese-mixed text; Japanese/Korean degrade to whitespace splitting.
AUDIO_PLACEHOLDER module-attribute ¶
build_prompt ¶
Wrap segmented words in the Qwen3 aligner prompt template.
Each word gets two trailing <timestamp> markers (start + end); the model classifies each marker into an audio time bin.
fix_timestamp ¶
Repair non-monotonic timestamp bins via LIS + interpolation.
The model occasionally emits out-of-order bins; this snaps anomalies back onto the longest non-decreasing subsequence (interpolating longer runs) so paired start/end markers stay ordered. Port of Qwen3ForceAlignProcessor.fix_timestamp (Apache-2.0).
resolve_timestamp_token_id ¶
resolve_timestamp_token_id(
tokenizer: Any, timestamp_token: str = TIMESTAMP_TOKEN
) -> int
Look up the integer id of the timestamp special token.
segment_words ¶
Split text into the aligner's word units.
Prefers qwen_asr's official processor (full multilingual fidelity); falls back to the built-in port otherwise. language follows the official naming — "japanese" / "korean" (or codes like ja / ko) trigger language-specific tokenisers; anything else (incl. None / "auto") uses the whitespace + Chinese-mixed path.