Skip to content

Open-source speech recognition toolkit for training, inference, streaming ASR, VAD, punctuation, speaker diarization pipelines, and OpenAI-compatible/MCP serving.

fix(fun-asr-nano): normalize ISO language hints

LauraGPT9f3a00218cc8
diff --git a/funasr/models/fun_asr_nano/inference_vllm.py b/funasr/models/fun_asr_nano/inference_vllm.py
index 331ba90cf..78f567c2d 100644
--- a/funasr/models/fun_asr_nano/inference_vllm.py
+++ b/funasr/models/fun_asr_nano/inference_vllm.py
@@ -39,6 +39,13 @@ logger = logging.getLogger(__name__)
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."""
@@ -462,6 +469,8 @@ class FunASRNanoVLLM:
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)
diff --git a/tests/test_fun_asr_nano_vllm_prompt.py b/tests/test_fun_asr_nano_vllm_prompt.py
new file mode 100644
index 000000000..903a8af77
--- /dev/null
+++ b/tests/test_fun_asr_nano_vllm_prompt.py
@@ -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="粤语") == "语音转写成粤语:"