From eb8cb1443a55382e8e65b0fc2882e34a7347e17c Mon Sep 17 00:00:00 2001 From: zhifu gao Date: Fri, 13 Nov 2026 17:47:30 +0800 Subject: [PATCH] docs(site): explain hotword protocols and standalone runtime upgrades Publish one dated bilingual article with checked examples and explicit evidence limits. Preserve established navigation. Signed-off-by: LauraGPT --- .../product-site/content/legacy-manifest.json | 4 +- web-pages/product-site/data/blog.json | 13 +++ .../blog/hotwords-package-boundaries.html | 86 +++++++++++++++++++ .../en/blog/hotwords-package-boundaries.html | 86 +++++++++++++++++++ .../tests/browser/blog-editorial.spec.ts | 9 +- .../tests/test_hotword_release_article.py | 78 +++++++++++++++++ 6 files changed, 274 insertions(+), 2 deletions(-) create mode 100644 web-pages/product-site/legacy/blog/hotwords-package-boundaries.html create mode 100644 web-pages/product-site/legacy/en/blog/hotwords-package-boundaries.html create mode 100644 web-pages/product-site/tests/test_hotword_release_article.py diff --git a/web-pages/product-site/content/legacy-manifest.json b/web-pages/product-site/content/legacy-manifest.json index 20e7c98acf..f35c31d1ef 100644 --- a/web-pages/product-site/content/legacy-manifest.json +++ b/web-pages/product-site/content/legacy-manifest.json @@ -138,6 +138,8 @@ "static/online/wav.js": "63344c3e282b80349bdc64f7508f32346ce783609881dbfbc97827a36d594c35", "static/online/wsconnecter.js": "a619a1cab5e111c5ff4b77ec8e68e47f9dde6ba5d7a62ca2db0c1b083c33e8ca", "voice/index.html": "1a6bae9e1637fea91f2f97506f5847ebd0ce429136444afa61f0a75da0beea0b", - "vs-whisper.html": "7d73ff1f771e4c17117108b172c2ce1952e98738787bb7101f061bf51aa8f03c" + "vs-whisper.html": "7d73ff1f771e4c17117108b172c2ce1952e98738787bb7101f061bf51aa8f03c", + "blog/hotwords-package-boundaries.html": "be0aaad687d18fc9387fb35ed10f44272bd47e161ae3e489cb68ca4c860d4307", + "en/blog/hotwords-package-boundaries.html": "4eae4e3f485e5fd8c7ab1b64d6e2fb28e0e529d821b02e87f040a0a73bbd3085" } } diff --git a/web-pages/product-site/data/blog.json b/web-pages/product-site/data/blog.json index 270e0f26f9..e9899ea89e 100644 --- a/web-pages/product-site/data/blog.json +++ b/web-pages/product-site/data/blog.json @@ -9,6 +9,19 @@ ], "lead_image": "/img/funclip-v2-1-0-interface.jpg", "articles": [ + { + "slug": "hotwords-package-boundaries", + "category": "explanations", + "reviewed": true, + "zh": { + "title": "热词没有生效?先核对传递链路和安装包", + "summary": "从 WebSocket 消息到 Torch 独立运行时,核对热词格式、安装版本和批次时间戳,避免把接口修复当作准确率保证。" + }, + "en": { + "title": "Hotwords not working? Check the request path and installed package", + "summary": "Check hotword encoding, standalone package versions and batched timestamps, without confusing interface fixes with recognition accuracy guarantees." + } + }, { "slug": "sensevoice-finetuning-acceptance", "category": "explanations", diff --git a/web-pages/product-site/legacy/blog/hotwords-package-boundaries.html b/web-pages/product-site/legacy/blog/hotwords-package-boundaries.html new file mode 100644 index 0000000000..13c692ede1 --- /dev/null +++ b/web-pages/product-site/legacy/blog/hotwords-package-boundaries.html @@ -0,0 +1,86 @@ + + + +热词没有生效?先核对传递链路和安装包 | FunASR + + + + + + + +

热词没有生效?先核对传递链路和安装包

+ +

团队接入语音识别时,产品名和人名常常需要热词提示。识别结果不理想,不一定是词表不够大:先确认客户端传出的词,确实以模型支持的形式到达了推理入口。

+

例如,客户端把两个术语放进带权重的 JSON 对象,再将它编码成 WebSocket 消息中的字符串。服务端不能把大括号、引号和数字一起当作热词正文。下面沿着消息、服务脚本和独立运行时三层,给出可核对的路径。

+

热词是提示,不是强制替换或正确率保证。本文解释已经验证的协议和运行时边界,不提供新的识别准确率、性能排名或生产部署承诺。

+

一、先分清你使用的入口

+ + + + +
入口应核对的对象
Python WebSocket 服务仓库中的 runtime/python/websocket/funasr_wss_server.py 和实际运行的源码提交。
Torch 独立运行时funasr-torch==0.1.7;导入名是 funasr_torch。
ONNX 独立运行时funasr-onnx==0.4.11;导入名是 funasr_onnx。
+

这三个入口不是同一个发布物。升级根包 funasr,不会自动更新你复制的服务脚本,也不能替代独立运行时的安装。WebSocket 热词修复见 #3892(保留 #3880 作者历史);不要仅凭一个版本号推断整个服务已升级。

+

二、让 JSON 热词成为模型实际接收的词

+

以下只展示消息编码,不会启动服务、下载权重或发送音频:

+
import json
+
+hotwords = {"阿里巴巴": 20, "通义实验室": 30}
+message = {"hotwords": json.dumps(hotwords, ensure_ascii=False)}
+assert json.loads(message["hotwords"]) == hotwords
+print(json.dumps(message, ensure_ascii=False))
+

修复后的 Python 服务会把 JSON 对象的键整理为以空格分隔的词,分别写入离线和在线模型参数;空对象变为空字符串。普通字符串及不能解析成 JSON 的字符串仍按原文本传递。这里的 AutoModel 接口不接收数值权重,因此 20 和 30 不会成为模型的相对偏置强度。需要权重能力时,应单独核对所选模型与部署协议,不能把另一套运行时的约定直接搬过来。

+

线上的完整消息还需要按相应客户端协议设置音频和分块参数。上述片段不是完整的流式客户端,其他格式也不能仅凭此示例认定兼容。部署时还需配置 TLS、鉴权、资源限制,并避免把私人音频、转录或敏感词表写进公开日志。

+

三、检查真正安装和导入的 Torch 包

+

在独立测试环境中安装指定版本,再查看包元数据和实际导入位置。不要直接改动正在服务的共享环境:

+
python -m pip install "funasr-torch==0.1.7"
+python -m pip check
+python -c 'import importlib.metadata as m, funasr_torch; print(m.version("funasr-torch")); print(funasr_torch.__file__)'
+

Contextual 和 Seaco 包装器使用的导出热词嵌入宽度为 10。0.1.7 会忽略空白条目,长热词保留前十个字符,并将索引限制在对应嵌入范围内。这解决的是运行时边界,不代表超长词的剩余部分仍能参与提示。请优先使用业务中有区分度的短词,并用获得授权的录音检查收益与误触发。

+

四、用单条与批次结果检查时间戳

+

把短音频与长音频分别运行一次,再组成同一批次运行。输出数量、文本和短音频的时间戳都应按各自录音核对。0.1.7 的 Paraformer 修复会按每条输入的特征长度截取峰值序列,防止填充帧拉长短音频的末尾时间戳。同一版本还包括末尾缩写合并及富转录片段词间空格修复。

+

发布前分别测试了 wheel 和源码分发包的安装后行为。真实 GPU 证据使用既有合成夹具,且逐文件绑定运行时代码;它不是新的预训练模型准确率评测,也不是任意模型和硬件的完整兼容性证明。将自己常用的语言、噪声和长短录音纳入验收,仍然不可省略。

+

发布物与下一步

+

查看 Torch 0.1.7 Release 与校验清单、PyPI 安装包及 ONNX 0.4.11 Release。源码修复分别记录在 #3882、#3871和 #3869。

+

下一步,用你有权处理的一小组录音,按会议转写验收清单检查术语、遗漏和时间戳,再决定何时更新自己的服务。

+
+
FunASR · 通义实验室开源语音识别 · GitHub
+ + diff --git a/web-pages/product-site/legacy/en/blog/hotwords-package-boundaries.html b/web-pages/product-site/legacy/en/blog/hotwords-package-boundaries.html new file mode 100644 index 0000000000..3311387553 --- /dev/null +++ b/web-pages/product-site/legacy/en/blog/hotwords-package-boundaries.html @@ -0,0 +1,86 @@ + + + +Hotwords not working? Check the request path and installed package | FunASR + + + + + + + +

Hotwords not working? Check the request path and installed package

+ +

Your team may use hotwords for product names and personal names. Before expanding the vocabulary, check that the terms sent by the client actually reach the model in a supported form.

+

A client may encode two weighted terms as a JSON object, then place that JSON string inside a WebSocket message. The server must not treat braces, quotes and numbers as the terms themselves. Here is how to check the message, server script and standalone runtime separately.

+

Hotwords are hints, not forced replacements or accuracy guarantees. This article describes verified protocol and runtime boundaries, not a new recognition benchmark, speed ranking or production deployment guarantee.

+

1. Identify the entry point you actually use

+ + + + +
Entry pointWhat to check
Python WebSocket serverThe actual source revision of runtime/python/websocket/funasr_wss_server.py.
Standalone Torch runtimefunasr-torch==0.1.7, imported as funasr_torch.
Standalone ONNX runtimefunasr-onnx==0.4.11, imported as funasr_onnx.
+

These are separate deliverables. Updating the root funasr package does not update a copied server script or replace a standalone runtime installation. The WebSocket fix is tracked in #3892, preserving the original #3880 author history. One version number is not proof that the entire service was upgraded.

+

2. Turn JSON hotwords into model input

+

This example only encodes a message. It does not start a server, download weights or transmit audio:

+
import json
+
+hotwords = {"阿里巴巴": 20, "通义实验室": 30}
+message = {"hotwords": json.dumps(hotwords, ensure_ascii=False)}
+assert json.loads(message["hotwords"]) == hotwords
+print(json.dumps(message, ensure_ascii=False))
+

The fixed Python server joins JSON object keys with spaces and supplies them to both offline and online model parameters. An empty object becomes an empty string. Plain strings and strings that cannot be parsed as JSON retain their original text. This AutoModel interface does not accept numeric hotword weights, so 20 and 30 do not become relative model bias strengths. Check the chosen model and deployment protocol separately if weighted biasing is required.

+

A complete client must also follow its audio and chunking protocol. The snippet is not a complete streaming client, nor proof that other message formats are compatible. Configure TLS, authentication and resource limits for deployment. Do not put private audio, transcripts or sensitive vocabulary into public logs.

+

3. Verify the installed and imported Torch package

+

Use a dedicated test environment, install the pinned version, then inspect package metadata and the import location. Do not modify a shared serving environment directly:

+
python -m pip install "funasr-torch==0.1.7"
+python -m pip check
+python -c 'import importlib.metadata as m, funasr_torch; print(m.version("funasr-torch")); print(funasr_torch.__file__)'
+

The exported embedding used by the Contextual and Seaco wrappers has a hotword width of ten. Version 0.1.7 removes empty whitespace entries, retains the first ten characters of longer terms, and keeps indexes within that embedding range. This fixes a runtime boundary; it does not preserve the truncated suffix as a hint. Prefer short, distinctive terms and check both useful matches and false triggers on recordings you are authorized to process.

+

4. Compare individual and batched timestamps

+

Run a short recording and a long recording individually, then together in a batch. Check output count, text and timestamps against each recording. The Paraformer change in 0.1.7 slices each peak sequence by its own feature length, preventing padded frames from extending the shorter recording's final timestamp. The package also includes terminal abbreviation grouping and word-boundary fixes for rich-transcription segments.

+

Installed behavior is tested separately for the wheel and source distribution. Existing real GPU evidence uses synthetic fixtures and is bound to the runtime source file by file. It is not a new pretrained-model accuracy evaluation or a full compatibility guarantee for every model and device. Your own languages, noise conditions and recording lengths still need acceptance testing.

+

Release artifacts and your next step

+

See the Torch 0.1.7 release and checksums, PyPI package and ONNX 0.4.11 release. Source changes are tracked in #3882, #3871 and #3869.

+

Next, use a small set of authorized recordings and the meeting-transcript acceptance checklist to inspect terminology, omissions and timestamps before upgrading your service.

+
+ + + diff --git a/web-pages/product-site/tests/browser/blog-editorial.spec.ts b/web-pages/product-site/tests/browser/blog-editorial.spec.ts index 586657b2fe..2fbf8c6ad1 100644 --- a/web-pages/product-site/tests/browser/blog-editorial.spec.ts +++ b/web-pages/product-site/tests/browser/blog-editorial.spec.ts @@ -1,4 +1,8 @@ import { expect, test } from '@playwright/test'; +import { readFileSync } from 'node:fs'; +import { resolve } from 'node:path'; + +const catalogue = JSON.parse(readFileSync(resolve(__dirname, '../../data/blog.json'), 'utf8')); for (const prefix of ['', 'en/']) { for (const width of [390, 1440]) { @@ -78,7 +82,10 @@ for (const prefix of ['', 'en/']) { } await page.locator(`[data-blog-more] a[href="/${prefix}blog/archive/"]`).click(); const archive = page.locator('[data-blog-view="archive"]'); - await expect(archive.locator('[data-blog-story]')).toHaveCount(37); + await expect(archive.locator('[data-blog-story]')).toHaveCount(catalogue.articles.length); + for (const { slug } of catalogue.articles) { + await expect(archive.locator(`[data-blog-story][href="/${prefix}blog/${slug}.html"]`)).toHaveCount(1); + } await page.screenshot({ path: testInfo.outputPath('archive.png') }); await archive.locator(`a[href="/${prefix}blog/self-hosted-deepgram-assemblyai-alternative.html"]`).click(); await expect(page.locator('article h1')).toBeVisible(); diff --git a/web-pages/product-site/tests/test_hotword_release_article.py b/web-pages/product-site/tests/test_hotword_release_article.py new file mode 100644 index 0000000000..efcf56369e --- /dev/null +++ b/web-pages/product-site/tests/test_hotword_release_article.py @@ -0,0 +1,78 @@ +"""Keep the daily integration article bilingual, reproducible and bounded.""" +import contextlib +import io +import json +from pathlib import Path +import sys + +from bs4 import BeautifulSoup +import pytest + +SITE = Path(__file__).resolve().parents[1] +sys.path.insert(0, str(SITE)) +from build import build + +SLUG = "hotwords-package-boundaries" + + +def test_catalogue_contains_daily_article_once(): + data = json.loads((SITE / "data/blog.json").read_text()) + entries = [row for row in data["articles"] if row["slug"] == SLUG] + assert len(entries) == 1 + assert entries[0]["reviewed"] and entries[0]["category"] == "explanations" + assert data["selected"] == [ + "meeting-transcript-acceptance", "fun-asr-nano-transformers", + "self-hosted-openai-whisper-api-alternative", "funasr-transcribe-long-audio", + ] + + +@pytest.fixture(scope="module", params=["source", "built"]) +def tree(request, tmp_path_factory): + if request.param == "source": + return SITE / "legacy" + output = tmp_path_factory.mktemp("hotword-article") + build(output) + return output + + +@pytest.fixture(params=["", "en/"]) +def article(request, tree): + prefix = request.param + path = tree / prefix / "blog" / (SLUG + ".html") + return prefix, BeautifulSoup(path.read_text(), "html.parser") + + +def test_article_metadata_and_package_boundaries(article): + prefix, soup = article + metadata = json.loads(soup.select_one('script[type="application/ld+json"]').get_text()) + assert metadata["datePublished"] == metadata["dateModified"] == "2026-11-13" + assert metadata["headline"] == soup.select_one("article h1").get_text() + assert soup.select_one('link[rel="canonical"]')["href"] == f"https://www.funasr.com/{prefix}blog/{SLUG}.html" + links = {a["href"] for a in soup.select("article a[href]")} + assert "https://pypi.org/project/funasr-torch/0.1.7/" in links + assert "https://github.com/modelscope/FunASR/releases/tag/runtime-torch-v0.1.7" in links + assert "https://github.com/modelscope/FunASR/pull/3892" in links + text = soup.select_one("article").get_text(" ", strip=True) + assert "funasr-torch==0.1.7" in text and "funasr-onnx==0.4.11" in text + assert soup.select_one('[data-editorial="boundary"]') + assert len(soup.select('[data-editorial="next-step"] a')) == 1 + + +def test_json_example_executes_without_a_model_or_network(article): + _, soup = article + code = soup.select_one('code[data-language="python"]').get_text() + scope = {} + with contextlib.redirect_stdout(io.StringIO()) as output: + exec(compile(code, "article-example", "exec"), scope) + message = json.loads(output.getvalue()) + assert json.loads(message["hotwords"]) == {"\u963f\u91cc\u5df4\u5df4": 20, "\u901a\u4e49\u5b9e\u9a8c\u5ba4": 30} + + +@pytest.mark.parametrize("prefix", ["", "en/"]) +def test_new_article_is_discoverable_without_removing_existing_entrypoints(prefix, tmp_path): + build(tmp_path) + for category in ("archive", "explanations"): + soup = BeautifulSoup((tmp_path / prefix / "blog" / category / "index.html").read_text(), "html.parser") + cards = soup.select(f'a[href="/{prefix}blog/{SLUG}.html"]') + assert len(cards) == 1 + assert cards[0].select_one('time[datetime="2026-11-13"]')