Skip to content

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

fix(sensevoice): stop rendering the Cough event as the Sneeze emoji (#3747)

Mohammad Hijjawi217d10aa9958
diff --git a/funasr/utils/postprocess_utils.py b/funasr/utils/postprocess_utils.py
index beaa87cb4..28c5d4546 100644
--- a/funasr/utils/postprocess_utils.py
+++ b/funasr/utils/postprocess_utils.py
@@ -353,7 +353,7 @@ event_dict = {
"<|Cry|>": "😭",
"<|Sneeze|>": "🀧",
"<|Breath|>": "",
- "<|Cough|>": "🀧",
+ "<|Cough|>": "😷",
}
lang_dict = {
diff --git a/runtime/python/libtorch/funasr_torch/utils/postprocess_utils.py b/runtime/python/libtorch/funasr_torch/utils/postprocess_utils.py
index eb4e2232e..a5a90f74a 100644
--- a/runtime/python/libtorch/funasr_torch/utils/postprocess_utils.py
+++ b/runtime/python/libtorch/funasr_torch/utils/postprocess_utils.py
@@ -262,7 +262,7 @@ event_dict = {
"<|Cry|>": "😭",
"<|Sneeze|>": "🀧",
"<|Breath|>": "",
- "<|Cough|>": "🀧",
+ "<|Cough|>": "😷",
}
lang_dict = {
diff --git a/runtime/python/onnxruntime/funasr_onnx/utils/postprocess_utils.py b/runtime/python/onnxruntime/funasr_onnx/utils/postprocess_utils.py
index d144d31ab..d065b69fe 100644
--- a/runtime/python/onnxruntime/funasr_onnx/utils/postprocess_utils.py
+++ b/runtime/python/onnxruntime/funasr_onnx/utils/postprocess_utils.py
@@ -316,7 +316,7 @@ event_dict = {
"<|Cry|>": "😭",
"<|Sneeze|>": "🀧",
"<|Breath|>": "",
- "<|Cough|>": "🀧",
+ "<|Cough|>": "😷",
}
lang_dict = {
diff --git a/tests/test_rich_transcription_postprocess.py b/tests/test_rich_transcription_postprocess.py
new file mode 100644
index 000000000..8e07de09e
--- /dev/null
+++ b/tests/test_rich_transcription_postprocess.py
@@ -0,0 +1,34 @@
+"""Regression tests for SenseVoice rich transcription postprocessing."""
+
+import importlib.util
+from pathlib import Path
+
+import pytest
+
+REPO_ROOT = Path(__file__).resolve().parents[1]
+RUNTIME_PYTHON = REPO_ROOT / "runtime" / "python"
+POSTPROCESS_UTILS = [
+ REPO_ROOT / "funasr" / "utils" / "postprocess_utils.py",
+ RUNTIME_PYTHON / "onnxruntime" / "funasr_onnx" / "utils" / "postprocess_utils.py",
+ RUNTIME_PYTHON / "libtorch" / "funasr_torch" / "utils" / "postprocess_utils.py",
+]
+
+
+def _load(path):
+ spec = importlib.util.spec_from_file_location(f"_postprocess_utils_{path.parts[-3]}", path)
+ module = importlib.util.module_from_spec(spec)
+ spec.loader.exec_module(module)
+ return module
+
+
[email protected]("path", POSTPROCESS_UTILS, ids=lambda path: path.parts[-3])
+ "event, emoji",
+ [("<|Cough|>", "😷"), ("<|Sneeze|>", "🀧")],
+)
+def test_cough_and_sneeze_events_render_distinct_emojis(path, event, emoji):
+ module = _load(path)
+
+ text = module.rich_transcription_postprocess(f"<|en|><|NEUTRAL|>{event}<|woitn|>hello")
+
+ assert text == f"{emoji}hello"