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

rich_transcription_postprocess() maps SenseVoice event tags through
event_dict, which used 🤧 for both <|Sneeze|> and <|Cough|>, so coughs
were displayed as sneezes. emoji_dict and event_set already use 😷 for
coughs; use it in event_dict too, in funasr and in the funasr_onnx and
funasr_torch runtime copies.
This commit is contained in:
Mohammad Hijjawi
2026-10-01 12:49:24 +08:00
committed by GitHub
parent b0fa25b12c
commit 217d10aa99
4 changed files with 37 additions and 3 deletions
+1 -1
View File
@@ -353,7 +353,7 @@ event_dict = {
"<|Cry|>": "😭",
"<|Sneeze|>": "🤧",
"<|Breath|>": "",
"<|Cough|>": "🤧",
"<|Cough|>": "😷",
}
lang_dict = {
@@ -262,7 +262,7 @@ event_dict = {
"<|Cry|>": "😭",
"<|Sneeze|>": "🤧",
"<|Breath|>": "",
"<|Cough|>": "🤧",
"<|Cough|>": "😷",
}
lang_dict = {
@@ -316,7 +316,7 @@ event_dict = {
"<|Cry|>": "😭",
"<|Sneeze|>": "🤧",
"<|Breath|>": "",
"<|Cough|>": "🤧",
"<|Cough|>": "😷",
}
lang_dict = {
@@ -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
@pytest.mark.parametrize("path", POSTPROCESS_UTILS, ids=lambda path: path.parts[-3])
@pytest.mark.parametrize(
"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"