Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions funasr/models/fun_asr_nano/inference_vllm.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@

dtype_map = {"bf16": torch.bfloat16, "fp16": torch.float16, "fp32": torch.float32}

_LANGUAGE_PROMPT_ALIASES = {
"zh": "中文",
"en": "英文",
"ja": "日文",
"ko": "韩文",
}


def _resolve_vllm_dtype(dtype: str) -> str:
"""Use a numerically stable dtype for the Qwen3 language model."""
Expand Down Expand Up @@ -462,6 +469,8 @@ def _build_prompt_text(
itn: bool = True,
) -> str:
"""Build the ASR prompt string."""
if language:
language = _LANGUAGE_PROMPT_ALIASES.get(language.lower(), language)
hotwords = hotwords or []
if len(hotwords) > 0:
hotwords_str = ", ".join(hotwords)
Expand Down
14 changes: 14 additions & 0 deletions tests/test_fun_asr_nano_vllm_prompt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from funasr.models.fun_asr_nano.inference_vllm import FunASRNanoVLLM


def test_iso_language_aliases_use_documented_prompt_names():
model = object.__new__(FunASRNanoVLLM)

assert model._build_prompt_text(language="zh") == "语音转写成中文:"
assert model._build_prompt_text(language="en") == "语音转写成英文:"


def test_custom_language_prompt_is_preserved():
model = object.__new__(FunASRNanoVLLM)

assert model._build_prompt_text(language="粤语") == "语音转写成粤语:"
Loading