Skip to content

Commit d090cef

Browse files
authored
fix(runtime): release ONNX hotword and timestamp fixes as 0.4.11
Publish the already accepted #3869/#3871/#3882 standalone wrapper fixes with hosted regression coverage. Signed-off-by: LauraGPT <zhifu.gzf@alibaba-inc.com>
1 parent 9fbcf4d commit d090cef

5 files changed

Lines changed: 82 additions & 8 deletions

File tree

‎.github/workflows/test-funasr-onnx-package.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ jobs:
8686
import importlib.util
8787
from importlib.metadata import requires, version
8888
89-
assert version("funasr-onnx") == "0.4.10"
89+
assert version("funasr-onnx") == "0.4.11"
9090
assert importlib.util.find_spec("torch") is None
9191
9292
requirements = requires("funasr-onnx") or []
@@ -130,7 +130,7 @@ jobs:
130130
if: matrix.python-version == '3.12'
131131
uses: actions/upload-artifact@v7
132132
with:
133-
name: funasr-onnx-0.4.10
133+
name: funasr-onnx-0.4.11
134134
path: dist/funasr-onnx/*
135135
if-no-files-found: error
136136

‎runtime/python/onnxruntime/README.md‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ does not update the installed ONNX wrappers. Check their versions separately
77
with `python -m pip show funasr-onnx funasr`; use the source installation below
88
when a required wrapper fix is newer than the published PyPI package.
99

10+
Version 0.4.11 keeps timestamps independent of padded samples in a batch
11+
(#3871), bounds Contextual/Seaco hotwords to the exported ten-character
12+
embedding input and skips whitespace-only entries (#3882), and preserves
13+
terminal abbreviations and their timestamps (#3869). These are wrapper and
14+
postprocessing fixes, not model-weight updates or ASR accuracy claims.
15+
1016
Version 0.4.10 restores direct librosa decoding for non-WAV audio in offline
1117
and streaming Paraformer, SenseVoice and offline VAD (#3865), without creating a WAV sidecar
1218
or treating every non-WAV input as MP3. Codec support still depends on the
@@ -45,9 +51,9 @@ and postprocessing fixes, not a model-weight update or an ASR accuracy claim.
4551
install from pip
4652

4753
```shell
48-
pip install -U "funasr-onnx>=0.4.10"
54+
pip install -U "funasr-onnx>=0.4.11"
4955
# For the users in China, you could install with the command:
50-
# pip install -U "funasr-onnx>=0.4.10" -i https://mirror.sjtu.edu.cn/pypi/web/simple
56+
# pip install -U "funasr-onnx>=0.4.11" -i https://mirror.sjtu.edu.cn/pypi/web/simple
5157
# If you want to export .onnx file, you should install modelscope and funasr
5258
pip install -U modelscope funasr
5359
# For the users in China, you could install with the command:

‎runtime/python/onnxruntime/setup.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def get_readme():
1313

1414

1515
MODULE_NAME = "funasr_onnx"
16-
VERSION_NUM = "0.4.10"
16+
VERSION_NUM = "0.4.11"
1717

1818
setuptools.setup(
1919
name=MODULE_NAME,

‎tests/test_funasr_onnx_installed.py‎

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,71 @@ class InstalledOnnxPackageTest(unittest.TestCase):
4141
LOADERS = (funasr_onnx.Paraformer, ParaformerOnline,
4242
funasr_onnx.SenseVoiceSmall, funasr_onnx.Fsmn_vad)
4343

44+
def test_long_and_empty_hotwords_stay_within_embedding_bounds(self):
45+
for cls in (funasr_onnx.ContextualParaformer, funasr_onnx.SeacoParaformer):
46+
with self.subTest(wrapper=cls.__name__):
47+
model = cls.__new__(cls)
48+
model.vocab = {'a': 3, 'b': 4}
49+
matrix, positions = model.proc_hotword(' ab abababababab ')
50+
self.assertEqual(matrix.tolist(), [
51+
[3, 4, 0, 0, 0, 0, 0, 0, 0, 0],
52+
[3, 4, 3, 4, 3, 4, 3, 4, 3, 4],
53+
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
54+
])
55+
self.assertEqual(positions.tolist(), [1, 9, 0])
56+
for value in ('', ' \t\n'):
57+
matrix, positions = model.proc_hotword(value)
58+
self.assertEqual(matrix.tolist(), [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0]])
59+
self.assertEqual(positions.tolist(), [0])
60+
61+
def test_batched_timestamps_use_each_input_length(self):
62+
def features(lengths):
63+
return np.zeros((len(lengths), max(lengths), 4), dtype=np.float32), np.array(lengths)
64+
65+
def acoustic_output(feats, lengths):
66+
peaks = np.zeros((len(lengths), feats.shape[1] * 3), dtype=np.float32)
67+
for row, length in enumerate(lengths):
68+
peaks[row, np.linspace(5, length * 3 - 6, 3).round().astype(int)] = 1
69+
return None, None, np.zeros_like(peaks), peaks
70+
71+
# Acoustic outputs are synthetic. The installed batching, timestamp and
72+
# postprocessing code must keep the shorter sample independent of padding.
73+
for cls in (funasr_onnx.Paraformer, funasr_onnx.ContextualParaformer,
74+
funasr_onnx.SeacoParaformer):
75+
with self.subTest(wrapper=cls.__name__):
76+
model = cls.__new__(cls)
77+
model.batch_size = 2
78+
model.plot_timestamp_to = ''
79+
model.language = 'zh'
80+
model.frontend = SimpleNamespace(opts=SimpleNamespace(
81+
frame_opts=SimpleNamespace(samp_freq=16000)))
82+
model.load_data = lambda values, fs: values
83+
model.extract_feat = features
84+
model.decode = lambda scores, lens: [['\u4f60', '\u597d'] for _ in range(model._rows)]
85+
86+
def infer(feats, lengths, *unused):
87+
model._rows = len(lengths)
88+
return acoustic_output(feats, lengths)
89+
90+
model.infer = infer
91+
model.bb_infer = infer
92+
model.vocab = {'a': 3}
93+
model.eb_infer = lambda hotwords, lengths: [np.zeros((10, len(hotwords), 4), dtype=np.float32)]
94+
args = () if cls is funasr_onnx.Paraformer else ('a',)
95+
single = [model([length], *args)[0] for length in [17, 50]]
96+
self.assertEqual([x['timestamp'] for x in single], [
97+
[[70, 470], [470, 945]], [[70, 670], [1450, 2925]],
98+
])
99+
self.assertEqual(model([17, 50], *args), single)
100+
101+
def test_terminal_abbreviation_preserves_text_and_timestamps(self):
102+
from funasr_onnx.utils.postprocess_utils import abbr_dispose
103+
104+
self.assertEqual(abbr_dispose(['a', ' ', 'b']), ['AB'])
105+
self.assertEqual(abbr_dispose(['a', ' ', 'b'], [[0, 100], [100, 200]]),
106+
(['AB'], [[0, 200]]))
107+
self.assertEqual(abbr_dispose(['a', ' ', 'b', ' ', 'c']), ['ABC'])
108+
44109
def test_lossless_non_wav_without_sidecar(self):
45110
samples = (np.arange(4800, dtype=np.int16) - 2400).astype(np.float32) / 32768
46111
with tempfile.TemporaryDirectory() as directory:
@@ -91,7 +156,7 @@ def test_invalid_audio_remains_visible_without_sidecar(self):
91156

92157
def test_installed_distribution_version_and_origin(self):
93158
distribution = importlib.metadata.distribution('funasr-onnx')
94-
self.assertEqual(distribution.version, '0.4.10')
159+
self.assertEqual(distribution.version, '0.4.11')
95160
self.assertEqual(
96161
Path(funasr_onnx.__file__).resolve().parent,
97162
Path(distribution.locate_file('funasr_onnx')).resolve(),

‎tests/test_funasr_onnx_release.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
ROOT = Path(__file__).resolve().parents[1]
88
PACKAGE_ROOT = ROOT / "runtime" / "python" / "onnxruntime"
99
SETUP_PATH = PACKAGE_ROOT / "setup.py"
10-
EXPECTED_VERSION = "0.4.10"
10+
EXPECTED_VERSION = "0.4.11"
1111
REQUIREMENT_NAME_PATTERN = re.compile(r"^\s*([A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?)")
1212

1313

@@ -44,7 +44,7 @@ def normalized_requirement_name(requirement):
4444

4545

4646
class FunASROnnxReleaseContractTest(unittest.TestCase):
47-
def test_release_version_is_0_4_10(self):
47+
def test_release_version_is_0_4_11(self):
4848
self.assertEqual(assigned_literal(read_setup_tree(), "VERSION_NUM"), EXPECTED_VERSION)
4949

5050
def test_standalone_license_preserves_repository_notice(self):
@@ -83,6 +83,9 @@ def test_readme_names_the_standalone_fix_release(self):
8383
self.assertIn("#3847", readme)
8484
self.assertIn("empty or sub-frame", readme)
8585
self.assertIn("preserves the streaming cache", readme)
86+
self.assertIn("#3869", readme)
87+
self.assertIn("#3871", readme)
88+
self.assertIn("#3882", readme)
8689

8790
def test_runtime_dependencies_keep_onnx_install_torch_free(self):
8891
requirements = setup_keyword_literal(read_setup_tree(), "install_requires")

0 commit comments

Comments
 (0)