diff --git a/funasr/utils/postprocess_utils.py b/funasr/utils/postprocess_utils.py index beaa87cb4e..28c5d4546d 100644 --- a/funasr/utils/postprocess_utils.py +++ b/funasr/utils/postprocess_utils.py @@ -353,7 +353,7 @@ def sentence_postprocess_sentencepiece(words): "<|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 eb4e2232e3..a5a90f74a3 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 @@ def sentence_postprocess(words: List[Any], time_stamp: List[List] = None): "<|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 d144d31aba..d065b69fef 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 @@ def sentence_postprocess_sentencepiece(words): "<|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 0000000000..8e07de09eb --- /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 + + +@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"