Skip to content

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

ci: integrate WebSocket protocol hotwords on current main

zhifu gaoff881eda1886
diff --git a/.github/workflows/test-funasr-onnx-package.yml b/.github/workflows/test-funasr-onnx-package.yml
index 226421da6..18f0b4e54 100644
--- a/.github/workflows/test-funasr-onnx-package.yml
+++ b/.github/workflows/test-funasr-onnx-package.yml
@@ -86,7 +86,7 @@ jobs:
import importlib.util
from importlib.metadata import requires, version
- assert version("funasr-onnx") == "0.4.10"
+ assert version("funasr-onnx") == "0.4.11"
assert importlib.util.find_spec("torch") is None
requirements = requires("funasr-onnx") or []
@@ -130,7 +130,7 @@ jobs:
if: matrix.python-version == '3.12'
uses: actions/upload-artifact@v7
with:
- name: funasr-onnx-0.4.10
+ name: funasr-onnx-0.4.11
path: dist/funasr-onnx/*
if-no-files-found: error
diff --git a/.github/workflows/test-python-websocket.yml b/.github/workflows/test-python-websocket.yml
new file mode 100644
index 000000000..d083808a3
--- /dev/null
+++ b/.github/workflows/test-python-websocket.yml
@@ -0,0 +1,55 @@
+name: Validate Python WebSocket
+
+on:
+ pull_request:
+ paths:
+ - "runtime/python/websocket/funasr_wss_server.py"
+ - "runtime/python/websocket/funasr_wss_client.py"
+ - "tests/test_websocket_server_asr_model.py"
+ - "tests/test_websocket_server_hotwords.py"
+ - "tests/test_websocket_file_finalization.py"
+ - ".github/workflows/test-python-websocket.yml"
+ push:
+ branches:
+ - main
+ paths:
+ - "runtime/python/websocket/funasr_wss_server.py"
+ - "runtime/python/websocket/funasr_wss_client.py"
+ - "tests/test_websocket_server_asr_model.py"
+ - "tests/test_websocket_server_hotwords.py"
+ - "tests/test_websocket_file_finalization.py"
+ - ".github/workflows/test-python-websocket.yml"
+
+permissions:
+ contents: read
+
+jobs:
+ websocket:
+ runs-on: ubuntu-latest
+ timeout-minutes: 5
+ strategy:
+ fail-fast: false
+ matrix:
+ python-version: ["3.10", "3.11", "3.12"]
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-python@v5
+ with:
+ python-version: ${{ matrix.python-version }}
+ - name: Install isolated protocol test dependencies
+ run: |
+ python -m pip install pytest numpy scipy websockets
+ python -m pip install torch --index-url https://download.pytorch.org/whl/cpu
+ - name: Run constructor, hotword and file-finalization regressions
+ run: >-
+ python -m pytest -q
+ tests/test_websocket_server_asr_model.py
+ tests/test_websocket_server_hotwords.py
+ tests/test_websocket_file_finalization.py
+ --junitxml=websocket-test-results.xml
+ - uses: actions/upload-artifact@v4
+ if: always()
+ with:
+ name: websocket-tests-py${{ matrix.python-version }}
+ path: websocket-test-results.xml
+ if-no-files-found: error
diff --git a/README.md b/README.md
index 108711e43..53c94fa55 100644
--- a/README.md
+++ b/README.md
@@ -364,7 +364,8 @@ recordings with the same evaluation scope.
## What's new
- **MOSS-Transcribe-Diarize** brings long-form ASR, timestamps, and anonymous speaker labels to FunASR services, Docker, Kubernetes, vLLM/SGLang workflows, and FunClip. [Deploy MOSS ->](./docs/moss_transcribe_diarize.md)
-- **FunASR 1.4.25** restores Python 3.12 boolean argument parsing without `distutils` and preserves normalized error messages; removes synthetic leading spaces from Latin sentence timestamps while preserving boundaries and raw text. [Fix #3863](https://github.com/modelscope/FunASR/pull/3863), [fix #3866](https://github.com/modelscope/FunASR/pull/3866). Install with `python -m pip install -U "funasr==1.4.25"`. [Release and verification scope ->](https://github.com/modelscope/FunASR/releases/tag/v1.4.25)
+- **FunASR 1.4.26** preserves word spaces between English/Korean VAD segments and returns plain text for HTTP `response_format=text`. [#3874](https://github.com/modelscope/FunASR/pull/3874), [#3883](https://github.com/modelscope/FunASR/pull/3883). `python -m pip install -U "funasr==1.4.26"`. [Release / 验证范围](https://github.com/modelscope/FunASR/releases/tag/v1.4.26)
+ **FunASR 1.4.25** restores Python 3.12 boolean argument parsing without `distutils` and preserves normalized error messages; removes synthetic leading spaces from Latin sentence timestamps while preserving boundaries and raw text. [Fix #3863](https://github.com/modelscope/FunASR/pull/3863), [fix #3866](https://github.com/modelscope/FunASR/pull/3866). Install with `python -m pip install -U "funasr==1.4.25"`. [Release and verification scope ->](https://github.com/modelscope/FunASR/releases/tag/v1.4.25)
**FunASR 1.4.24** ignores empty non-linguistic symbols to prevent tokenizer loops, fixes padded variance normalization, and prevents CIF crashes in mixed batches containing zero-fire samples. [Fix #3852](https://github.com/modelscope/FunASR/pull/3852), [fix #3853](https://github.com/modelscope/FunASR/pull/3853), [fix #3854](https://github.com/modelscope/FunASR/pull/3854). A checkpoint trained with both `norm_means=True` and `norm_vars=True` needs recognition-quality reevaluation because normalized features change; `norm_vars=False` remains the default. Install with `python -m pip install -U "funasr==1.4.24"`. [Release and verification scope ->](https://github.com/modelscope/FunASR/releases/tag/v1.4.24)
**FunASR 1.4.23** fixes the online frontend cursor for `lfr_m=lfr_n=1` and redundant empty final offline VAD chunks. With a supplied `token_list`, SentencePiece `ids2tokens` returns model pieces; use `tokens2text` for text. Without `token_list`, legacy text decoding is unchanged. [Fix #3849](https://github.com/modelscope/FunASR/pull/3849), [fix #3783](https://github.com/modelscope/FunASR/pull/3783). [Release and verification scope ->](https://github.com/modelscope/FunASR/releases/tag/v1.4.23)
**FunASR 1.4.22** honors per-call `merge_length_s` and evaluates dynamic VAD silence thresholds per frame using the current segment duration, preserving the fixed-threshold opt-out. [Fix #3841](https://github.com/modelscope/FunASR/pull/3841), [fix #3833](https://github.com/modelscope/FunASR/pull/3833). [Release and verification scope ->](https://github.com/modelscope/FunASR/releases/tag/v1.4.22)
diff --git a/README_ja.md b/README_ja.md
index 64f634fe6..883faf2c0 100644
--- a/README_ja.md
+++ b/README_ja.md
@@ -112,7 +112,8 @@ CER/WER をそろえて比較してください。オフラインのスループ
## 最新情報
- **MOSS-Transcribe-Diarize** を FunASR service、Docker、Kubernetes、vLLM/SGLang workflow、FunClip に統合し、長時間 ASR、timestamp、匿名 speaker label を一度に処理できます。[MOSS をデプロイ ->](./docs/moss_transcribe_diarize.md)
-- **FunASR 1.4.25** は Python 3.12 の真偽値引数を `distutils` なしで解析し、正規化されたエラーメッセージを維持します。ラテン文字で始まる文のタイムスタンプ出力から余分な先頭空白を除き、時刻境界と原文を保持します。[修正 #3863](https://github.com/modelscope/FunASR/pull/3863)、[修正 #3866](https://github.com/modelscope/FunASR/pull/3866)。`python -m pip install -U "funasr==1.4.25"` でインストールできます。[リリースと検証範囲 ->](https://github.com/modelscope/FunASR/releases/tag/v1.4.25)
+- **FunASR 1.4.26** は英語・韓国語の VAD セグメント間の単語区切りを保持し、HTTP `response_format=text` でプレーンテキストを返します。 [#3874](https://github.com/modelscope/FunASR/pull/3874), [#3883](https://github.com/modelscope/FunASR/pull/3883). `python -m pip install -U "funasr==1.4.26"`. [Release / 验证范围](https://github.com/modelscope/FunASR/releases/tag/v1.4.26)
+ **FunASR 1.4.25** は Python 3.12 の真偽値引数を `distutils` なしで解析し、正規化されたエラーメッセージを維持します。ラテン文字で始まる文のタイムスタンプ出力から余分な先頭空白を除き、時刻境界と原文を保持します。[修正 #3863](https://github.com/modelscope/FunASR/pull/3863)、[修正 #3866](https://github.com/modelscope/FunASR/pull/3866)。`python -m pip install -U "funasr==1.4.25"` でインストールできます。[リリースと検証範囲 ->](https://github.com/modelscope/FunASR/releases/tag/v1.4.25)
**FunASR 1.4.24** は空の非言語記号によるトークナイザーの無限ループ、パディングを含む分散正規化、発火回数ゼロのサンプルを含む混合バッチでの CIF クラッシュを修正します。[修正 #3852](https://github.com/modelscope/FunASR/pull/3852)、[修正 #3853](https://github.com/modelscope/FunASR/pull/3853)、[修正 #3854](https://github.com/modelscope/FunASR/pull/3854)。`norm_means=True` と `norm_vars=True` の両方で学習した checkpoint は正規化特徴が変わるため、認識品質の再評価が必要です。既定値は引き続き `norm_vars=False` です。`python -m pip install -U "funasr==1.4.24"` でインストールできます。[リリースと検証範囲 ->](https://github.com/modelscope/FunASR/releases/tag/v1.4.24)
**FunASR 1.4.23** は `lfr_m=lfr_n=1` のオンライン特徴抽出のフレーム位置と、オフライン VAD の余分な空の最終チャンクを修正します。`token_list` 指定時の SentencePiece `ids2tokens` はモデルのピースを返し、テキストへの変換には `tokens2text` を使います。未指定時の従来のテキスト復号は維持します。[修正 #3849](https://github.com/modelscope/FunASR/pull/3849)、[修正 #3783](https://github.com/modelscope/FunASR/pull/3783)。[リリースと検証範囲 ->](https://github.com/modelscope/FunASR/releases/tag/v1.4.23)
**FunASR 1.4.22** は呼び出しごとの `merge_length_s` を反映し、現在の発話区間の長さに基づいて動的 VAD 無音しきい値をフレーム単位で更新します。固定しきい値モードも維持します。[修正 #3841](https://github.com/modelscope/FunASR/pull/3841)、[修正 #3833](https://github.com/modelscope/FunASR/pull/3833)。[リリースと検証範囲 ->](https://github.com/modelscope/FunASR/releases/tag/v1.4.22)
diff --git a/README_ko.md b/README_ko.md
index caa493859..43e51b4da 100644
--- a/README_ko.md
+++ b/README_ko.md
@@ -111,7 +111,8 @@ checkpoint/revision, 오디오 집합, 하드웨어, 배치, 워밍업, 측정
## 최신 소식
- **MOSS-Transcribe-Diarize**를 FunASR service, Docker, Kubernetes, vLLM/SGLang workflow, FunClip에 통합해 긴 오디오 ASR, timestamp, 익명 speaker label을 한 번에 처리합니다. [MOSS 배포 ->](./docs/moss_transcribe_diarize.md)
-- **FunASR 1.4.25**는 Python 3.12에서 `distutils` 없이 불리언 인수를 처리하고 정규화된 오류 메시지를 유지합니다. 라틴 문자로 시작하는 문장의 타임스탬프 출력에서 불필요한 앞 공백을 제거하며 시간 경계와 원문은 보존합니다. [수정 #3863](https://github.com/modelscope/FunASR/pull/3863), [수정 #3866](https://github.com/modelscope/FunASR/pull/3866). `python -m pip install -U "funasr==1.4.25"`로 설치할 수 있습니다. [릴리스 및 검증 범위 ->](https://github.com/modelscope/FunASR/releases/tag/v1.4.25)
+- **FunASR 1.4.26** 는 영어·한국어 VAD 구간 사이의 단어 공백을 보존하고 HTTP `response_format=text` 요청에 일반 텍스트를 반환합니다. [#3874](https://github.com/modelscope/FunASR/pull/3874), [#3883](https://github.com/modelscope/FunASR/pull/3883). `python -m pip install -U "funasr==1.4.26"`. [Release / 验证范围](https://github.com/modelscope/FunASR/releases/tag/v1.4.26)
+ **FunASR 1.4.25**는 Python 3.12에서 `distutils` 없이 불리언 인수를 처리하고 정규화된 오류 메시지를 유지합니다. 라틴 문자로 시작하는 문장의 타임스탬프 출력에서 불필요한 앞 공백을 제거하며 시간 경계와 원문은 보존합니다. [수정 #3863](https://github.com/modelscope/FunASR/pull/3863), [수정 #3866](https://github.com/modelscope/FunASR/pull/3866). `python -m pip install -U "funasr==1.4.25"`로 설치할 수 있습니다. [릴리스 및 검증 범위 ->](https://github.com/modelscope/FunASR/releases/tag/v1.4.25)
**FunASR 1.4.24**는 빈 비언어 기호로 인한 토크나이저 무한 루프, 패딩이 있는 입력의 분산 정규화 오류, 발화 횟수가 0인 샘플이 섞인 배치의 CIF 충돌을 수정합니다. [수정 #3852](https://github.com/modelscope/FunASR/pull/3852), [수정 #3853](https://github.com/modelscope/FunASR/pull/3853), [수정 #3854](https://github.com/modelscope/FunASR/pull/3854). `norm_means=True`와 `norm_vars=True`를 모두 사용해 학습한 checkpoint는 정규화 특징이 달라지므로 인식 품질을 다시 평가해야 합니다. 기본값은 계속 `norm_vars=False`입니다. `python -m pip install -U "funasr==1.4.24"`로 설치할 수 있습니다. [릴리스 및 검증 범위 ->](https://github.com/modelscope/FunASR/releases/tag/v1.4.24)
**FunASR 1.4.23**은 `lfr_m=lfr_n=1` 온라인 프런트엔드의 프레임 위치와 오프라인 VAD의 불필요한 빈 마지막 청크를 수정합니다. `token_list`를 지정하면 SentencePiece `ids2tokens`는 모델 토큰을 반환하며, 텍스트 변환에는 `tokens2text`를 사용합니다. 미지정 시 기존 텍스트 디코딩은 유지됩니다. [수정 #3849](https://github.com/modelscope/FunASR/pull/3849), [수정 #3783](https://github.com/modelscope/FunASR/pull/3783). [릴리스 및 검증 범위 ->](https://github.com/modelscope/FunASR/releases/tag/v1.4.23)
**FunASR 1.4.22**는 호출별 `merge_length_s`를 반영하고 현재 발화 구간 길이에 따라 동적 VAD 무음 임계값을 프레임마다 갱신합니다. 고정 임계값 모드도 유지합니다. [수정 #3841](https://github.com/modelscope/FunASR/pull/3841), [수정 #3833](https://github.com/modelscope/FunASR/pull/3833). [릴리스 및 검증 범위 ->](https://github.com/modelscope/FunASR/releases/tag/v1.4.22)
diff --git a/README_zh.md b/README_zh.md
index ec13d2f34..efa77d7ca 100644
--- a/README_zh.md
+++ b/README_zh.md
@@ -157,7 +157,8 @@ checkpoint/revision、音频集、硬件、批量大小、预热、计时范围
## 最新动态
- **MOSS-Transcribe-Diarize** 已接入 FunASR 服务、Docker、Kubernetes、vLLM/SGLang 工作流和 FunClip,一次完成长音频转写、时间戳与匿名说话人标注。[部署 MOSS ->](./docs/moss_transcribe_diarize_zh.md)
-- **FunASR 1.4.25** 修复 Python 3.12 下不依赖 `distutils` 的布尔参数解析并保留归一化错误信息;移除拉丁文字句子时间戳中的多余前导空格,保留时间边界和原始文本。[修复 #3863](https://github.com/modelscope/FunASR/pull/3863)、[修复 #3866](https://github.com/modelscope/FunASR/pull/3866)。安装:`python -m pip install -U "funasr==1.4.25"`。[发布说明与验证范围 ->](https://github.com/modelscope/FunASR/releases/tag/v1.4.25)
+- **FunASR 1.4.26** 保留英语、韩语 VAD 分段间的词间空格,并让 HTTP `response_format=text` 返回纯文本。 [#3874](https://github.com/modelscope/FunASR/pull/3874), [#3883](https://github.com/modelscope/FunASR/pull/3883). `python -m pip install -U "funasr==1.4.26"`. [Release / 验证范围](https://github.com/modelscope/FunASR/releases/tag/v1.4.26)
+ **FunASR 1.4.25** 修复 Python 3.12 下不依赖 `distutils` 的布尔参数解析并保留归一化错误信息;移除拉丁文字句子时间戳中的多余前导空格,保留时间边界和原始文本。[修复 #3863](https://github.com/modelscope/FunASR/pull/3863)、[修复 #3866](https://github.com/modelscope/FunASR/pull/3866)。安装:`python -m pip install -U "funasr==1.4.25"`。[发布说明与验证范围 ->](https://github.com/modelscope/FunASR/releases/tag/v1.4.25)
**FunASR 1.4.24** 忽略空的非语言符号以避免分词死循环,修复带填充输入的方差归一化,并避免包含零触发样本的混合批次导致 CIF 崩溃。[修复 #3852](https://github.com/modelscope/FunASR/pull/3852)、[修复 #3853](https://github.com/modelscope/FunASR/pull/3853)、[修复 #3854](https://github.com/modelscope/FunASR/pull/3854)。同时启用 `norm_means=True` 和 `norm_vars=True` 训练的 checkpoint 会收到不同的归一化特征,需要重新评估识别质量;默认仍为 `norm_vars=False`。安装:`python -m pip install -U "funasr==1.4.24"`。[发布说明与验证范围 ->](https://github.com/modelscope/FunASR/releases/tag/v1.4.24)
**FunASR 1.4.23** 修复 `lfr_m=lfr_n=1` 在线前端的帧游标和离线 VAD 多余的空尾块。提供 `token_list` 时,SentencePiece 的 `ids2tokens` 返回模型词元,请用 `tokens2text` 转为文本;未提供 `token_list` 时保持旧有文本解码行为。[修复 #3849](https://github.com/modelscope/FunASR/pull/3849)、[修复 #3783](https://github.com/modelscope/FunASR/pull/3783)。[发布说明与验证范围 ->](https://github.com/modelscope/FunASR/releases/tag/v1.4.23)
**FunASR 1.4.22** 支持逐调用覆盖 `merge_length_s`,并根据当前语音段时长逐帧更新动态 VAD 静音阈值,同时保留固定阈值模式。[修复 #3841](https://github.com/modelscope/FunASR/pull/3841)、[修复 #3833](https://github.com/modelscope/FunASR/pull/3833)。[发布说明与验证范围 ->](https://github.com/modelscope/FunASR/releases/tag/v1.4.22)
diff --git a/docs/repository_roles.md b/docs/repository_roles.md
index bff0e53a9..30178f163 100644
--- a/docs/repository_roles.md
+++ b/docs/repository_roles.md
@@ -5,7 +5,7 @@ This document explains the responsibility boundaries, user entry points, and iss
> **Directional roadmap, not a release promise.**
> This document records shipped capabilities and active work, but does not commit to
> future version numbers or dates. The current Python release is
-> [`funasr==1.4.25`](https://github.com/modelscope/FunASR/releases/tag/v1.4.25).
+> [`funasr==1.4.26`](https://github.com/modelscope/FunASR/releases/tag/v1.4.26).
> Any future breaking release still requires a maintainer-approved milestone and
> migration plan.
diff --git a/docs/repository_roles_zh.md b/docs/repository_roles_zh.md
index fd979aced..013f0669e 100644
--- a/docs/repository_roles_zh.md
+++ b/docs/repository_roles_zh.md
@@ -4,7 +4,7 @@
> **方向性路线图,不是版本承诺。**
> 本文档记录已交付能力与正在推进的工作,但不承诺未来版本号或日期。当前 Python
-> 版本是 [`funasr==1.4.25`](https://github.com/modelscope/FunASR/releases/tag/v1.4.25)。
+> 版本是 [`funasr==1.4.26`](https://github.com/modelscope/FunASR/releases/tag/v1.4.26)。
> 任何未来的 breaking release 仍需 maintainer 确认 milestone 与迁移方案。
---
diff --git a/funasr/utils/postprocess_utils.py b/funasr/utils/postprocess_utils.py
index 6a3cd2336..cd99e1fbb 100644
--- a/funasr/utils/postprocess_utils.py
+++ b/funasr/utils/postprocess_utils.py
@@ -442,6 +442,11 @@ def format_str_v2(s):
return s.strip()
+def _is_spaced_char(ch):
+ """Latin and Hangul text separates words with spaces; CJK text does not."""
+ return (ch.isascii() and not ch.isspace()) or "\uac00" <= ch <= "\ud7a3"
+
+
def rich_transcription_postprocess(s):
"""Rich transcription postprocess.
@@ -481,6 +486,10 @@ def rich_transcription_postprocess(s):
cur_ent_event = get_event(s_list[i])
if get_emo(s_list[i]) != None and get_emo(s_list[i]) == get_emo(new_s):
new_s = new_s[:-1]
- new_s += s_list[i].strip().lstrip()
+ segment = s_list[i].strip()
+ # Each VAD segment is its own <|lang|> block; keep the word boundary between them.
+ if segment and _is_spaced_char(new_s[-1]) and _is_spaced_char(segment[0]):
+ new_s += " "
+ new_s += segment
new_s = new_s.replace("The.", " ")
return new_s.strip()
diff --git a/funasr/version.txt b/funasr/version.txt
index df3487bee..24d07aa70 100644
--- a/funasr/version.txt
+++ b/funasr/version.txt
@@ -1 +1 @@
-1.4.25
+1.4.26
diff --git a/runtime/python/libtorch/funasr_torch/paraformer_bin.py b/runtime/python/libtorch/funasr_torch/paraformer_bin.py
index dc9d2a596..15bab5075 100644
--- a/runtime/python/libtorch/funasr_torch/paraformer_bin.py
+++ b/runtime/python/libtorch/funasr_torch/paraformer_bin.py
@@ -120,10 +120,10 @@ class Paraformer:
pred = sentence_postprocess(pred)
asr_res.append({"preds": pred})
else:
- for pred, us_peaks_ in zip(preds, us_peaks):
+ for pred, us_peaks_, feat_len in zip(preds, us_peaks, feats_len):
raw_tokens = pred
timestamp, timestamp_raw = time_stamp_lfr6_onnx(
- us_peaks_, copy.copy(raw_tokens)
+ us_peaks_[: feat_len * 3], copy.copy(raw_tokens)
)
text_proc, timestamp_proc, _ = sentence_postprocess(
raw_tokens, timestamp_raw
@@ -365,7 +365,10 @@ class ContextualParaformer(Paraformer):
return asr_res
def proc_hotword(self, hotwords):
- hotwords = hotwords.split(" ")
+ # Like the C++ runtime, skip empty hotwords and keep the first max_hotword_len
+ # characters of longer ones: the exported embedding model takes that many per hotword.
+ max_hotword_len = 10
+ hotwords = [hotword[:max_hotword_len] for hotword in hotwords.split()]
hotwords_length = [len(i) - 1 for i in hotwords]
hotwords_length.append(0)
hotwords_length = np.array(hotwords_length)
@@ -385,7 +388,7 @@ class ContextualParaformer(Paraformer):
hotword_int = [word_map(i) for i in hotwords]
hotword_int.append(np.array([1]))
- hotwords = pad_list(hotword_int, pad_value=0, max_len=10)
+ hotwords = pad_list(hotword_int, pad_value=0, max_len=max_hotword_len)
return torch.tensor(hotwords), hotwords_length
def bb_infer(
diff --git a/runtime/python/libtorch/funasr_torch/utils/postprocess_utils.py b/runtime/python/libtorch/funasr_torch/utils/postprocess_utils.py
index 34180841c..d5b7a6ffb 100644
--- a/runtime/python/libtorch/funasr_torch/utils/postprocess_utils.py
+++ b/runtime/python/libtorch/funasr_torch/utils/postprocess_utils.py
@@ -347,6 +347,11 @@ def format_str_v2(s):
return s.strip()
+def _is_spaced_char(ch):
+ """Latin and Hangul text separates words with spaces; CJK text does not."""
+ return (ch.isascii() and not ch.isspace()) or "\uac00" <= ch <= "\ud7a3"
+
+
def rich_transcription_postprocess(s):
def get_emo(s):
return s[-1] if s[-1] in emo_set else None
@@ -371,6 +376,10 @@ def rich_transcription_postprocess(s):
cur_ent_event = get_event(s_list[i])
if get_emo(s_list[i]) != None and get_emo(s_list[i]) == get_emo(new_s):
new_s = new_s[:-1]
- new_s += s_list[i].strip().lstrip()
+ segment = s_list[i].strip()
+ # Each VAD segment is its own <|lang|> block; keep the word boundary between them.
+ if segment and _is_spaced_char(new_s[-1]) and _is_spaced_char(segment[0]):
+ new_s += " "
+ new_s += segment
new_s = new_s.replace("The.", " ")
return new_s.strip()
diff --git a/runtime/python/onnxruntime/README.md b/runtime/python/onnxruntime/README.md
index e3d18c6d4..4982cc450 100644
--- a/runtime/python/onnxruntime/README.md
+++ b/runtime/python/onnxruntime/README.md
@@ -7,6 +7,12 @@ does not update the installed ONNX wrappers. Check their versions separately
with `python -m pip show funasr-onnx funasr`; use the source installation below
when a required wrapper fix is newer than the published PyPI package.
+Version 0.4.11 keeps timestamps independent of padded samples in a batch
+(#3871), bounds Contextual/Seaco hotwords to the exported ten-character
+embedding input and skips whitespace-only entries (#3882), and preserves
+terminal abbreviations and their timestamps (#3869). These are wrapper and
+postprocessing fixes, not model-weight updates or ASR accuracy claims.
+
Version 0.4.10 restores direct librosa decoding for non-WAV audio in offline
and streaming Paraformer, SenseVoice and offline VAD (#3865), without creating a WAV sidecar
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.
install from pip
```shell
-pip install -U "funasr-onnx>=0.4.10"
+pip install -U "funasr-onnx>=0.4.11"
# For the users in China, you could install with the command:
-# pip install -U "funasr-onnx>=0.4.10" -i https://mirror.sjtu.edu.cn/pypi/web/simple
+# pip install -U "funasr-onnx>=0.4.11" -i https://mirror.sjtu.edu.cn/pypi/web/simple
# If you want to export .onnx file, you should install modelscope and funasr
pip install -U modelscope funasr
# For the users in China, you could install with the command:
diff --git a/runtime/python/onnxruntime/funasr_onnx/paraformer_bin.py b/runtime/python/onnxruntime/funasr_onnx/paraformer_bin.py
index 517252cd8..fff3f301d 100644
--- a/runtime/python/onnxruntime/funasr_onnx/paraformer_bin.py
+++ b/runtime/python/onnxruntime/funasr_onnx/paraformer_bin.py
@@ -131,10 +131,10 @@ class Paraformer:
pred = sentence_postprocess(pred)
asr_res.append({"preds": pred})
else:
- for pred, us_peaks_ in zip(preds, us_peaks):
+ for pred, us_peaks_, feat_len in zip(preds, us_peaks, feats_len):
raw_tokens = pred
timestamp, timestamp_raw = time_stamp_lfr6_onnx(
- us_peaks_, copy.copy(raw_tokens)
+ us_peaks_[: feat_len * 3], copy.copy(raw_tokens)
)
text_proc, timestamp_proc, _ = sentence_postprocess(
raw_tokens, timestamp_raw
@@ -384,10 +384,10 @@ class ContextualParaformer(Paraformer):
pred = sentence_postprocess(pred)
asr_res.append({"preds": pred})
else:
- for pred, us_peaks_ in zip(preds, us_peaks):
+ for pred, us_peaks_, feat_len in zip(preds, us_peaks, feats_len):
raw_tokens = pred
timestamp, timestamp_raw = time_stamp_lfr6_onnx(
- us_peaks_, copy.copy(raw_tokens)
+ us_peaks_[: feat_len * 3], copy.copy(raw_tokens)
)
text_proc, timestamp_proc, _ = sentence_postprocess(
raw_tokens, timestamp_raw
@@ -407,7 +407,10 @@ class ContextualParaformer(Paraformer):
return asr_res
def proc_hotword(self, hotwords):
- hotwords = hotwords.split(" ")
+ # Like the C++ runtime, skip empty hotwords and keep the first max_hotword_len
+ # characters of longer ones: the exported embedding model takes that many per hotword.
+ max_hotword_len = 10
+ hotwords = [hotword[:max_hotword_len] for hotword in hotwords.split()]
hotwords_length = [len(i) - 1 for i in hotwords]
hotwords_length.append(0)
hotwords_length = np.array(hotwords_length)
@@ -428,7 +431,7 @@ class ContextualParaformer(Paraformer):
hotword_int = [word_map(i) for i in hotwords]
hotword_int.append(np.array([1]))
- hotwords = pad_list(hotword_int, pad_value=0, max_len=10)
+ hotwords = pad_list(hotword_int, pad_value=0, max_len=max_hotword_len)
return hotwords, hotwords_length
diff --git a/runtime/python/onnxruntime/funasr_onnx/utils/postprocess_utils.py b/runtime/python/onnxruntime/funasr_onnx/utils/postprocess_utils.py
index 3a62afee6..82c334f85 100644
--- a/runtime/python/onnxruntime/funasr_onnx/utils/postprocess_utils.py
+++ b/runtime/python/onnxruntime/funasr_onnx/utils/postprocess_utils.py
@@ -401,6 +401,11 @@ def format_str_v2(s):
return s.strip()
+def _is_spaced_char(ch):
+ """Latin and Hangul text separates words with spaces; CJK text does not."""
+ return (ch.isascii() and not ch.isspace()) or "\uac00" <= ch <= "\ud7a3"
+
+
def rich_transcription_postprocess(s):
def get_emo(s):
return s[-1] if s[-1] in emo_set else None
@@ -425,6 +430,10 @@ def rich_transcription_postprocess(s):
cur_ent_event = get_event(s_list[i])
if get_emo(s_list[i]) != None and get_emo(s_list[i]) == get_emo(new_s):
new_s = new_s[:-1]
- new_s += s_list[i].strip().lstrip()
+ segment = s_list[i].strip()
+ # Each VAD segment is its own <|lang|> block; keep the word boundary between them.
+ if segment and _is_spaced_char(new_s[-1]) and _is_spaced_char(segment[0]):
+ new_s += " "
+ new_s += segment
new_s = new_s.replace("The.", " ")
return new_s.strip()
diff --git a/runtime/python/onnxruntime/setup.py b/runtime/python/onnxruntime/setup.py
index 40290072f..22791fa14 100644
--- a/runtime/python/onnxruntime/setup.py
+++ b/runtime/python/onnxruntime/setup.py
@@ -13,7 +13,7 @@ def get_readme():
MODULE_NAME = "funasr_onnx"
-VERSION_NUM = "0.4.10"
+VERSION_NUM = "0.4.11"
setuptools.setup(
name=MODULE_NAME,
diff --git a/runtime/python/websocket/funasr_wss_server.py b/runtime/python/websocket/funasr_wss_server.py
index 738317746..8dd4ddb22 100644
--- a/runtime/python/websocket/funasr_wss_server.py
+++ b/runtime/python/websocket/funasr_wss_server.py
@@ -45,7 +45,7 @@ parser.add_argument("--port", type=int, default=10095, required=False, help="grp
parser.add_argument(
"--asr_model",
type=str,
- default="iic/speech_paraformer-large-contextual_asr_nat-zh-cn-16k-common-vocab8404",
+ default="paraformer-zh",
help="model from modelscope",
)
parser.add_argument("--asr_model_revision", type=str, default="v2.0.4", help="")
@@ -254,8 +254,8 @@ from funasr import AutoModel # noqa
# ====== 离线 ASR ======
model_asr = AutoModel(
- model="paraformer-zh",
- model_revision="v2.0.4",
+ model=args.asr_model,
+ model_revision=args.asr_model_revision,
ngpu=args.ngpu,
ncpu=args.ncpu,
device=args.device,
diff --git a/tests/test_funasr_onnx_installed.py b/tests/test_funasr_onnx_installed.py
index b6a74c78e..161870454 100644
--- a/tests/test_funasr_onnx_installed.py
+++ b/tests/test_funasr_onnx_installed.py
@@ -41,6 +41,71 @@ class InstalledOnnxPackageTest(unittest.TestCase):
LOADERS = (funasr_onnx.Paraformer, ParaformerOnline,
funasr_onnx.SenseVoiceSmall, funasr_onnx.Fsmn_vad)
+ def test_long_and_empty_hotwords_stay_within_embedding_bounds(self):
+ for cls in (funasr_onnx.ContextualParaformer, funasr_onnx.SeacoParaformer):
+ with self.subTest(wrapper=cls.__name__):
+ model = cls.__new__(cls)
+ model.vocab = {'a': 3, 'b': 4}
+ matrix, positions = model.proc_hotword(' ab abababababab ')
+ self.assertEqual(matrix.tolist(), [
+ [3, 4, 0, 0, 0, 0, 0, 0, 0, 0],
+ [3, 4, 3, 4, 3, 4, 3, 4, 3, 4],
+ [1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
+ ])
+ self.assertEqual(positions.tolist(), [1, 9, 0])
+ for value in ('', ' \t\n'):
+ matrix, positions = model.proc_hotword(value)
+ self.assertEqual(matrix.tolist(), [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0]])
+ self.assertEqual(positions.tolist(), [0])
+
+ def test_batched_timestamps_use_each_input_length(self):
+ def features(lengths):
+ return np.zeros((len(lengths), max(lengths), 4), dtype=np.float32), np.array(lengths)
+
+ def acoustic_output(feats, lengths):
+ peaks = np.zeros((len(lengths), feats.shape[1] * 3), dtype=np.float32)
+ for row, length in enumerate(lengths):
+ peaks[row, np.linspace(5, length * 3 - 6, 3).round().astype(int)] = 1
+ return None, None, np.zeros_like(peaks), peaks
+
+ # Acoustic outputs are synthetic. The installed batching, timestamp and
+ # postprocessing code must keep the shorter sample independent of padding.
+ for cls in (funasr_onnx.Paraformer, funasr_onnx.ContextualParaformer,
+ funasr_onnx.SeacoParaformer):
+ with self.subTest(wrapper=cls.__name__):
+ model = cls.__new__(cls)
+ model.batch_size = 2
+ model.plot_timestamp_to = ''
+ model.language = 'zh'
+ model.frontend = SimpleNamespace(opts=SimpleNamespace(
+ frame_opts=SimpleNamespace(samp_freq=16000)))
+ model.load_data = lambda values, fs: values
+ model.extract_feat = features
+ model.decode = lambda scores, lens: [['\u4f60', '\u597d'] for _ in range(model._rows)]
+
+ def infer(feats, lengths, *unused):
+ model._rows = len(lengths)
+ return acoustic_output(feats, lengths)
+
+ model.infer = infer
+ model.bb_infer = infer
+ model.vocab = {'a': 3}
+ model.eb_infer = lambda hotwords, lengths: [np.zeros((10, len(hotwords), 4), dtype=np.float32)]
+ args = () if cls is funasr_onnx.Paraformer else ('a',)
+ single = [model([length], *args)[0] for length in [17, 50]]
+ self.assertEqual([x['timestamp'] for x in single], [
+ [[70, 470], [470, 945]], [[70, 670], [1450, 2925]],
+ ])
+ self.assertEqual(model([17, 50], *args), single)
+
+ def test_terminal_abbreviation_preserves_text_and_timestamps(self):
+ from funasr_onnx.utils.postprocess_utils import abbr_dispose
+
+ self.assertEqual(abbr_dispose(['a', ' ', 'b']), ['AB'])
+ self.assertEqual(abbr_dispose(['a', ' ', 'b'], [[0, 100], [100, 200]]),
+ (['AB'], [[0, 200]]))
+ self.assertEqual(abbr_dispose(['a', ' ', 'b', ' ', 'c']), ['ABC'])
+
def test_lossless_non_wav_without_sidecar(self):
samples = (np.arange(4800, dtype=np.int16) - 2400).astype(np.float32) / 32768
with tempfile.TemporaryDirectory() as directory:
@@ -91,7 +156,7 @@ class InstalledOnnxPackageTest(unittest.TestCase):
def test_installed_distribution_version_and_origin(self):
distribution = importlib.metadata.distribution('funasr-onnx')
- self.assertEqual(distribution.version, '0.4.10')
+ self.assertEqual(distribution.version, '0.4.11')
self.assertEqual(
Path(funasr_onnx.__file__).resolve().parent,
Path(distribution.locate_file('funasr_onnx')).resolve(),
diff --git a/tests/test_funasr_onnx_release.py b/tests/test_funasr_onnx_release.py
index cb57f6be5..1e73caf87 100644
--- a/tests/test_funasr_onnx_release.py
+++ b/tests/test_funasr_onnx_release.py
@@ -7,7 +7,7 @@ import unittest
ROOT = Path(__file__).resolve().parents[1]
PACKAGE_ROOT = ROOT / "runtime" / "python" / "onnxruntime"
SETUP_PATH = PACKAGE_ROOT / "setup.py"
-EXPECTED_VERSION = "0.4.10"
+EXPECTED_VERSION = "0.4.11"
REQUIREMENT_NAME_PATTERN = re.compile(r"^\s*([A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?)")
@@ -44,7 +44,7 @@ def normalized_requirement_name(requirement):
class FunASROnnxReleaseContractTest(unittest.TestCase):
- def test_release_version_is_0_4_10(self):
+ def test_release_version_is_0_4_11(self):
self.assertEqual(assigned_literal(read_setup_tree(), "VERSION_NUM"), EXPECTED_VERSION)
def test_standalone_license_preserves_repository_notice(self):
@@ -83,6 +83,9 @@ class FunASROnnxReleaseContractTest(unittest.TestCase):
self.assertIn("#3847", readme)
self.assertIn("empty or sub-frame", readme)
self.assertIn("preserves the streaming cache", readme)
+ self.assertIn("#3869", readme)
+ self.assertIn("#3871", readme)
+ self.assertIn("#3882", readme)
def test_runtime_dependencies_keep_onnx_install_torch_free(self):
requirements = setup_keyword_literal(read_setup_tree(), "install_requires")
diff --git a/tests/test_release_version_contract.py b/tests/test_release_version_contract.py
index d2b076db2..b3bf95182 100644
--- a/tests/test_release_version_contract.py
+++ b/tests/test_release_version_contract.py
@@ -4,7 +4,7 @@ import pytest
ROOT = Path(__file__).resolve().parents[1]
-RELEASE_VERSION = "1.4.25"
+RELEASE_VERSION = "1.4.26"
README_FILES = ("README.md", "README_zh.md", "README_ja.md", "README_ko.md")
REPOSITORY_ROLE_FILES = ("docs/repository_roles.md", "docs/repository_roles_zh.md")
@pytest.mark.parametrize("name", README_FILES)
@@ -23,7 +23,7 @@ def test_release_summary_covers_tokenizer_normalizer_and_cif(name):
@pytest.mark.parametrize("name", README_FILES)
def test_release_summary_covers_parser_and_timestamp_fixes(name):
summaries = [line for line in (ROOT / name).read_text(encoding="utf-8").splitlines()
- if f"**FunASR {RELEASE_VERSION}**" in line]
+ if "**FunASR 1.4.25**" in line]
assert len(summaries) == 1
assert "Python 3.12" in summaries[0]
assert "distutils" in summaries[0]
@@ -31,6 +31,17 @@ def test_release_summary_covers_parser_and_timestamp_fixes(name):
assert f"https://github.com/modelscope/FunASR/pull/{number}" in summaries[0]
[email protected]("name", README_FILES)
+def test_release_summary_covers_vad_spacing_and_plain_text(name):
+ summaries = [line for line in (ROOT / name).read_text(encoding="utf-8").splitlines()
+ if f"**FunASR {RELEASE_VERSION}**" in line]
+ assert len(summaries) == 1
+ assert "VAD" in summaries[0]
+ assert "response_format=text" in summaries[0]
+ for number in (3874, 3883):
+ assert f"https://github.com/modelscope/FunASR/pull/{number}" in summaries[0]
+
+
diff --git a/tests/test_rich_transcription_event_segments.py b/tests/test_rich_transcription_event_segments.py
index ed756abfd..a565b5c3c 100644
--- a/tests/test_rich_transcription_event_segments.py
+++ b/tests/test_rich_transcription_event_segments.py
@@ -34,7 +34,9 @@ def test_repeated_event_only_segments_keep_following_text(postprocess, event, fo
result = postprocess.rich_transcription_postprocess(text)
- assert result == postprocess.event_dict[event] + "hello" + following_text
+ assert result == postprocess.event_dict[event] + " ".join(
+ filter(None, ["hello", following_text])
+ )
@pytest.mark.parametrize("event", ["<|Cough|>", "<|Sneeze|>", "<|Applause|>"])
diff --git a/tests/test_rich_transcription_postprocess.py b/tests/test_rich_transcription_postprocess.py
index 8e07de09e..2cfc708ad 100644
--- a/tests/test_rich_transcription_postprocess.py
+++ b/tests/test_rich_transcription_postprocess.py
@@ -32,3 +32,24 @@ def test_cough_and_sneeze_events_render_distinct_emojis(path, event, emoji):
text = module.rich_transcription_postprocess(f"<|en|><|NEUTRAL|>{event}<|woitn|>hello")
assert text == f"{emoji}hello"
+
+
[email protected]("path", POSTPROCESS_UTILS, ids=lambda path: path.parts[-3])
+ "first, second, expected",
+ [
+ ("Hello world.", "How are you?", "Hello world. How are you?"),
+ ("so I went to the", "store", "so I went to the store"),
+ ("안녕하세요.", "감사합니다.", "안녕하세요. 감사합니다."),
+ ("你好。", "再见。", "你好。再见。"),
+ ("你好。", "Hello.", "你好。Hello."),
+ ],
+)
+def test_vad_segments_keep_a_space_between_spaced_scripts(path, first, second, expected):
+ module = _load(path)
+ tags = "<|NEUTRAL|><|Speech|><|withitn|>"
+
+ # AutoModel joins the tagged text of each VAD segment with a single space.
+ text = module.rich_transcription_postprocess(f"<|en|>{tags}{first} <|en|>{tags}{second}")
+
+ assert text == expected
diff --git a/tests/test_runtime_eval_native.py b/tests/test_runtime_eval_native.py
index e0e615480..97133b3af 100644
--- a/tests/test_runtime_eval_native.py
+++ b/tests/test_runtime_eval_native.py
@@ -8,6 +8,7 @@ import importlib
import json
import os
from pathlib import Path
+import shutil
import subprocess
import sys
import wave
@@ -275,6 +276,99 @@ def test_hotword_wrappers_decode_every_batch(
assert model(paths, hotwords) == alone
[email protected](scope="module")
+def timestamp_fixture(hotword_fixture, tmp_path_factory):
+ np = pytest.importorskip("numpy")
+ source, _ = hotword_fixture
+ directory = tmp_path_factory.mktemp("runtime-timestamp")
+ # The graphs only have to load: the timestamp test replaces the acoustic model's session.
+ for name, target in [
+ ("tokens.json", "tokens.json"),
+ ("model_eb.onnx", "model_eb.onnx"),
+ ("model.onnx", "model.onnx"),
+ ("model_bb.torchscript", "model.torchscript"),
+ ]:
+ shutil.copy(source / name, directory / target)
+ (directory / "config.yaml").write_text(
+ json.dumps(
+ {
+ "frontend_conf": {"n_mels": 4, "lfr_m": 7, "lfr_n": 6, "dither": 0.0},
+ "model_conf": {"predictor_bias": 1},
+ }
+ )
+ )
+ (directory / "am.mvn").write_text(
+ "<AddShift> 28 28\n<LearnRateCoef> 1 [ " + "0 " * 28 + "]\n"
+ "<Rescale> 28 28\n<LearnRateCoef> 1 [ " + "1 " * 28 + "]\n"
+ )
+ paths = []
+ for seconds in (1, 3):
+ path = directory / f"tone {seconds}s.wav"
+ tone = np.sin(np.arange(16000 * seconds) * 2 * np.pi * 440 / 16000) * 3000
+ with wave.open(str(path), "wb") as output:
+ output.setnchannels(1)
+ output.setsampwidth(2)
+ output.setframerate(16000)
+ output.writeframes(tone.astype("<i2").tobytes())
+ paths.append(str(path))
+ return directory, paths
+
+
+def timestamp_outputs(feats, feats_len):
+ """BiCifParaformer-style outputs for 你 好, padded to the longest row like the exported graph.
+
+ Each row's three CIF peaks lie inside its own 3 * feats_len upsampled frames; the
+ frames after them are zero padding.
+ """
+ import numpy as np
+
+ batch = len(feats_len)
+ am_scores = np.zeros((batch, 3, 8), dtype=np.float32)
+ am_scores[:, [0, 1, 2], [3, 4, 2]] = 1.0 # 你 好 </s>
+ us_alphas = np.zeros((batch, 3 * feats.shape[1]), dtype=np.float32)
+ us_peaks = np.zeros_like(us_alphas)
+ for row, feat_len in enumerate(np.asarray(feats_len).tolist()):
+ frames = 3 * feat_len
+ us_alphas[row, :frames] = 3.0 / frames
+ us_peaks[row, np.linspace(5, frames - 6, 3).round().astype(int)] = 1.0
+ return [am_scores, np.full(batch, 3, dtype=np.int32), us_alphas, us_peaks]
+
+
+ "backend, wrapper",
+ [
+ ("onnx", "Paraformer"),
+ ("onnx", "ContextualParaformer"),
+ ("onnx", "SeacoParaformer"),
+ ("torch", "Paraformer"),
+ ],
+)
+def test_batched_timestamps_ignore_padding(timestamp_fixture, monkeypatch, backend, wrapper):
+ torch = pytest.importorskip("torch")
+ directory, paths = timestamp_fixture
+ location = "libtorch" if backend == "torch" else "onnxruntime"
+ monkeypatch.syspath_prepend(str(ROOT / "runtime/python" / location))
+ module = importlib.import_module("funasr_" + backend + ".paraformer_bin")
+ model = getattr(module, wrapper)(str(directory), batch_size=2, intra_op_num_threads=1)
+ if backend == "torch":
+ model.ort_infer = lambda feats, feats_len: tuple(
+ torch.from_numpy(output) for output in timestamp_outputs(feats, feats_len)
+ )
+ elif wrapper == "Paraformer":
+ model.ort_infer = lambda inputs: timestamp_outputs(*inputs)
+ else:
+ model.ort_infer_bb = lambda inputs: timestamp_outputs(*inputs[:2])
+ hotwords = () if wrapper == "Paraformer" else ("魔搭",)
+ alone = [model(path, *hotwords)[0] for path in paths]
+ # The 1 s tone ends at 1000 ms, the 3 s tone at 3000 ms.
+ assert [row["timestamp"] for row in alone] == [
+ [[70, 470], [470, 945]],
+ [[70, 670], [1450, 2925]],
+ ]
+ # Batched with the 3 s tone, the 1 s tone must not take on the padded frames.
+ assert model(paths, *hotwords) == alone
+
+
@pytest.mark.parametrize("extension", ["flac", "ogg", "mp3"])
def test_onnx_wrappers_read_non_wav_paths(native_fixture, tmp_path, monkeypatch, extension):
np = pytest.importorskip("numpy")
@@ -310,3 +404,32 @@ def test_onnx_wrappers_read_non_wav_paths(native_fixture, tmp_path, monkeypatch,
model = funasr_onnx.Paraformer(str(directory), device_id=DEVICE, intra_op_num_threads=1)
assert model(str(audio)) == model(expected)
assert {path.name: path.read_bytes() for path in tmp_path.iterdir()} == files
+
+
[email protected]("backend", ["torch", "onnx"])
[email protected]("wrapper", ["ContextualParaformer", "SeacoParaformer"])
+def test_hotword_wrappers_skip_empty_and_cut_long_hotwords(
+ hotword_fixture, monkeypatch, backend, wrapper
+):
+ directory, paths = hotword_fixture
+ location = "libtorch" if backend == "torch" else "onnxruntime"
+ monkeypatch.syspath_prepend(str(ROOT / "runtime/python" / location))
+ module = importlib.import_module("funasr_" + backend + ".paraformer_bin")
+ model = getattr(module, wrapper)(str(directory), intra_op_num_threads=1)
+ # Like the C++ runtime: skip empty hotwords, and keep the first 10 characters of a longer
+ # one (the exported model_eb takes 10 per hotword). Ids: <s> 1, 你 3, 好 4, 魔 5, 搭 6.
+ long_hotwords = " 魔搭 你好魔搭你好魔搭你好魔搭 "
+ matrix, positions = model.proc_hotword(long_hotwords)
+ assert matrix.tolist() == [
+ [5, 6, 0, 0, 0, 0, 0, 0, 0, 0],
+ [3, 4, 5, 6, 3, 4, 5, 6, 3, 4],
+ [1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
+ ]
+ assert positions.tolist() == [1, 9, 0]
+ matrix, positions = model.proc_hotword("")
+ assert matrix.tolist() == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
+ assert positions.tolist() == [0]
+ # Both decode every file; the 12-character hotword used to stop the call with a ValueError.
+ for hotwords in (long_hotwords, ""):
+ result = model(paths, hotwords)
+ assert [row["preds"][0] for row in result] == ["你" * 4, "你" * 11, "你" * 17]
diff --git a/tests/test_websocket_server_asr_model.py b/tests/test_websocket_server_asr_model.py
new file mode 100644
index 000000000..b1bab606f
--- /dev/null
+++ b/tests/test_websocket_server_asr_model.py
@@ -0,0 +1,64 @@
+"""Offline model options of runtime/python/websocket/funasr_wss_server.py.
+
+The README documents ``--asr_model`` for this server. The server parsed ``--asr_model`` and
+``--asr_model_revision`` but built its offline model from a fixed "paraformer-zh" v2.0.4,
+so both options had no effect.
+"""
+
+import importlib.util
+import sys
+import types
+from pathlib import Path
+
+import pytest
+
+ROOT = Path(__file__).resolve().parents[1]
+SERVER_PATH = ROOT / "runtime/python/websocket/funasr_wss_server.py"
+
+
+def load_server(monkeypatch, *options):
+ """Run the server module with these command-line options; it builds its models on import."""
+ pytest.importorskip("numpy")
+ # Each AutoModel call returns its keyword arguments.
+ funasr = types.ModuleType("funasr")
+ funasr.AutoModel = types.SimpleNamespace
+ monkeypatch.setitem(sys.modules, "funasr", funasr)
+ # Stand-ins for the modules the server uses to serve requests, not to build its models.
+ stand_ins = {
+ name: types.ModuleType(name)
+ for name in ("websockets", "torch", "scipy", "scipy.spatial", "scipy.spatial.distance")
+ }
+ stand_ins["scipy.spatial.distance"].cosine = None
+ for name, module in stand_ins.items():
+ monkeypatch.setitem(sys.modules, name, module)
+ monkeypatch.setattr(sys, "argv", [str(SERVER_PATH), *options])
+ spec = importlib.util.spec_from_file_location("funasr_wss_server_asr_model", SERVER_PATH)
+ server = importlib.util.module_from_spec(spec)
+ spec.loader.exec_module(server)
+ server.EXECUTOR.shutdown(wait=True)
+ return server
+
+
+def test_default_offline_model_is_unchanged(monkeypatch):
+ server = load_server(monkeypatch)
+ assert server.model_asr.model == "paraformer-zh"
+ assert server.model_asr.model_revision == "v2.0.4"
+
+
+ "options, model, revision",
+ [
+ (["--asr_model", "paraformer-en"], "paraformer-en", "v2.0.4"),
+ (
+ ["--asr_model", "/models/my-paraformer", "--asr_model_revision", "master"],
+ "/models/my-paraformer",
+ "master",
+ ),
+ ],
+)
+def test_asr_model_options_select_the_offline_model(monkeypatch, options, model, revision):
+ server = load_server(monkeypatch, *options)
+ assert server.model_asr.model == model
+ assert server.model_asr.model_revision == revision
+ # The streaming model keeps its own options.
+ assert server.model_asr_streaming.model == server.args.asr_model_online
diff --git a/web-pages/product-site/content/legacy-manifest.json b/web-pages/product-site/content/legacy-manifest.json
index ddfe0410d..20e7c98ac 100644
--- a/web-pages/product-site/content/legacy-manifest.json
+++ b/web-pages/product-site/content/legacy-manifest.json
@@ -37,9 +37,9 @@
"blog/lightweight-speech-recognition-cpu.html": "d6270066222ed5baef0df108e6a4155f4a87bb5482169f23f218794d371f3281",
"blog/meeting-transcript-acceptance.html": "8173b3049ca707bdac46013748bc0ca7d9576ebf6f7ff6db6c940a833b12e4a9",
"blog/punctuation-restoration-python.html": "063c5fe584bff780edc50f95214decbb3432326d4983334fcd8b38aabeb16128",
- "blog/self-hosted-deepgram-assemblyai-alternative.html": "feb17aae8e0f3fe46914c8725eacc8fcdf7fe78bf22a291347d6107c24e3992e",
+ "blog/self-hosted-deepgram-assemblyai-alternative.html": "e7021f5a7f9bc0c40d88ff46ee53cd0d08cb5cbf17ae7aa8f9e8d85a15600c5f",
"blog/self-hosted-google-aws-azure-speech-to-text.html": "8e4000fb9e2b33a48a3907d4bd0f55db57ba74121a89b5fa12b412c3c963f49a",
- "blog/self-hosted-openai-whisper-api-alternative.html": "254184cd753f30e308329c301ae47e8f5f5dfb57c01d0abf3ce341034f2990f9",
+ "blog/self-hosted-openai-whisper-api-alternative.html": "f75f4b2fad03f6d1215347fbc98c71de1a59ff3c97cecc4aaf19bbb94e8eb777",
"blog/sensevoice-deployment-guide.html": "61c34fb7626444a0f1b5c93013dd95c10c576333791eaca1ab819baf0a8cdad6",
"blog/sensevoice-emotion-language-detection.html": "2451769a28af67788456aa02dad5201d218ac53fb84764cd7fbc32f991c953f8",
"blog/speech-to-text-python-transcribe-audio.html": "87335710235dfdec9e01288f03a9a294c7bc3f730110e8d06f2b4c9d4906e284",
@@ -80,9 +80,9 @@
"en/blog/lightweight-speech-recognition-cpu.html": "0e02c0e0853b12613d32c250f593c05c2052f18231207b63ee01d6e6600a86f7",
"en/blog/meeting-transcript-acceptance.html": "ffc6eb2329267515bb367f21bb2d1c0523ff90d3f02b2e734ae41f78b02d0515",
"en/blog/punctuation-restoration-python.html": "5853658aa8e936eda988fa087cba4a297de8044f979f6a9deef49206b8967a79",
- "en/blog/self-hosted-deepgram-assemblyai-alternative.html": "4239a93246726c6f010a2fb20208211e050792a372e3ea356d1a93ac028a8a96",
+ "en/blog/self-hosted-deepgram-assemblyai-alternative.html": "49a5e6e8134c33f9951e3cc052571e8d8441acaa8522be233552f30b5f5410fa",
"en/blog/self-hosted-google-aws-azure-speech-to-text.html": "4a8453451722b3ec8735224a586744ddfbfec9458cedd433f9fc908351027e9a",
- "en/blog/self-hosted-openai-whisper-api-alternative.html": "14bdb877adfd113eeb04b215ffa015c29d8323859eeddd00d9e03d166dfa0473",
+ "en/blog/self-hosted-openai-whisper-api-alternative.html": "a95bde0e83ebea941144e5a4bd339ea866feee099f047d4b4fb01072c293cb70",
"en/blog/sensevoice-deployment-guide.html": "8882912c6a84ec0a0e025d0eff8fcfa74bf76324bd4c9cae862c43c87c6e10b3",
"en/blog/sensevoice-emotion-language-detection.html": "8f1432a4c07dab895dfda144d4fe1f64a487c72922febb6a379a15b7215e42a3",
"en/blog/speech-to-text-python-transcribe-audio.html": "4fc57aef3c6177e28afa26fa6c41f67280b986e384b32a63a2f79ca67bcfe631",
diff --git a/web-pages/product-site/legacy/blog/self-hosted-deepgram-assemblyai-alternative.html b/web-pages/product-site/legacy/blog/self-hosted-deepgram-assemblyai-alternative.html
index 631379ae9..a92b9e038 100644
--- a/web-pages/product-site/legacy/blog/self-hosted-deepgram-assemblyai-alternative.html
+++ b/web-pages/product-site/legacy/blog/self-hosted-deepgram-assemblyai-alternative.html
@@ -5,7 +5,7 @@
<link rel="canonical" href="https://www.funasr.com/blog/self-hosted-deepgram-assemblyai-alternative.html"><link rel="alternate" hreflang="en" href="https://www.funasr.com/en/blog/self-hosted-deepgram-assemblyai-alternative.html"><link rel="alternate" hreflang="zh" href="https://www.funasr.com/blog/self-hosted-deepgram-assemblyai-alternative.html"><link rel="alternate" hreflang="x-default" href="https://www.funasr.com/en/blog/self-hosted-deepgram-assemblyai-alternative.html">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
<script type="application/ld+json">
-{"@context":"https://schema.org","@type":"BlogPosting","headline":"从 Deepgram / AssemblyAI 迁移到自托管 FunASR:接入与验收 | FunASR Blog","description":"评估自托管转写迁移:映射请求和结果契约,检查鉴权、返回格式、模型质量与运维成本。提供 FunASR 本地 JSON 示例,不承诺厂商 API 或 SDK 直接替换。","datePublished":"2026-06-23","dateModified":"2026-09-09","author":{"@type":"Organization","name":"FunASR / Tongyi Lab"},"publisher":{"@type":"Organization","name":"FunASR","logo":{"@type":"ImageObject","url":"https://www.funasr.com/logo.png"}},"mainEntityOfPage":{"@type":"WebPage","@id":"https://www.funasr.com/blog/self-hosted-deepgram-assemblyai-alternative.html"},"image":"https://www.funasr.com/logo.png"}
+{"@context":"https://schema.org","@type":"BlogPosting","headline":"从 Deepgram / AssemblyAI 迁移到自托管 FunASR:接入与验收 | FunASR Blog","description":"评估自托管转写迁移:映射请求和结果契约,检查鉴权、返回格式、模型质量与运维成本。提供 FunASR 本地 JSON 示例,不承诺厂商 API 或 SDK 直接替换。","datePublished":"2026-06-23","dateModified":"2026-11-12","author":{"@type":"Organization","name":"FunASR / Tongyi Lab"},"publisher":{"@type":"Organization","name":"FunASR","logo":{"@type":"ImageObject","url":"https://www.funasr.com/logo.png"}},"mainEntityOfPage":{"@type":"WebPage","@id":"https://www.funasr.com/blog/self-hosted-deepgram-assemblyai-alternative.html"},"image":"https://www.funasr.com/logo.png"}
</script>
<style>:root{--primary:#2563eb;--primary-dark:#1d4ed8;--bg:#fff;--surface:#f8fafc;--border:#e2e8f0;--text:#0f172a;--text-soft:#475569;--text-muted:#94a3b8;--radius:12px}
*{margin:0;padding:0;box-sizing:border-box}
@@ -78,6 +78,7 @@ python -m pip check</code></pre>
-F "response_format=json"</code></pre>
<p>预期结构是包含 <code>text</code> 的 JSON 对象,具体内容取决于音频与模型。120 秒是示例客户端超时,不是可处理音频时长或吞吐承诺。使用 OpenAI Python SDK 的基本调用可参考<a href="/blog/self-hosted-openai-whisper-api-alternative.html">本地转写接入指南</a>;这不意味着原厂商 SDK 可以原样使用。</p>
<h2>明确返回格式边界</h2>
+<p data-http-contract="version-boundary"><strong>版本边界:</strong>本文固定的 1.4.15 安装示例中,<code>response_format=text</code> 返回 <code>application/json</code> 编码的字符串,下表描述该历史版本。当前 main 已通过 <a href="https://github.com/modelscope/FunASR/pull/3874">#3874</a> 改为 <code>text/plain</code> 纯文本(<a href="https://github.com/modelscope/FunASR/blob/be264e9382b4fef735536f3d278ee14514098a1a/funasr/bin/_server_app.py">已合并处理器源码</a>)。这不代表已安装服务自动升级;请核对实际安装版本和响应内容,再决定是否进行 JSON 解码。</p>
<table data-http-contract="formats"><thead><tr><th>response_format</th><th>包内处理器的行为</th></tr></thead><tbody>
<tr data-response-format="json"><td><code>json</code></td><td>返回含 <code>text</code> 的 JSON 对象。</td></tr>
<tr data-response-format="verbose_json"><td><code>verbose_json</code></td><td>返回结构化 JSON,包括 <code>segments</code>、<code>duration</code> 等字段;具体时间与说话人信息依赖模型和实际结果。</td></tr>
diff --git a/web-pages/product-site/legacy/blog/self-hosted-openai-whisper-api-alternative.html b/web-pages/product-site/legacy/blog/self-hosted-openai-whisper-api-alternative.html
index bf980d6d8..77cb82c33 100644
--- a/web-pages/product-site/legacy/blog/self-hosted-openai-whisper-api-alternative.html
+++ b/web-pages/product-site/legacy/blog/self-hosted-openai-whisper-api-alternative.html
@@ -5,7 +5,7 @@
<meta property="og:type" content="article"><meta property="og:url" content="https://www.funasr.com/blog/self-hosted-openai-whisper-api-alternative.html"><meta property="og:image" content="https://www.funasr.com/logo.png">
<link rel="canonical" href="https://www.funasr.com/blog/self-hosted-openai-whisper-api-alternative.html"><link rel="alternate" hreflang="en" href="https://www.funasr.com/en/blog/self-hosted-openai-whisper-api-alternative.html"><link rel="alternate" hreflang="zh" href="https://www.funasr.com/blog/self-hosted-openai-whisper-api-alternative.html"><link rel="alternate" hreflang="x-default" href="https://www.funasr.com/en/blog/self-hosted-openai-whisper-api-alternative.html">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
-<script type="application/ld+json">{"@context":"https://schema.org","@type":"BlogPosting","headline":"把语音转写接进自己的 API","description":"从上传一段录音、取回文本开始,走通本地应用调用,并在对外开放前检查认证、返回格式和部署边界。","datePublished":"2026-06-18","dateModified":"2026-09-09","author":{"@type":"Organization","name":"FunASR / Tongyi Lab"},"publisher":{"@type":"Organization","name":"FunASR","logo":{"@type":"ImageObject","url":"https://www.funasr.com/logo.png"}},"mainEntityOfPage":{"@type":"WebPage","@id":"https://www.funasr.com/blog/self-hosted-openai-whisper-api-alternative.html"},"image":"https://www.funasr.com/logo.png"}</script>
+<script type="application/ld+json">{"@context":"https://schema.org","@type":"BlogPosting","headline":"把语音转写接进自己的 API","description":"从上传一段录音、取回文本开始,走通本地应用调用,并在对外开放前检查认证、返回格式和部署边界。","datePublished":"2026-06-18","dateModified":"2026-11-12","author":{"@type":"Organization","name":"FunASR / Tongyi Lab"},"publisher":{"@type":"Organization","name":"FunASR","logo":{"@type":"ImageObject","url":"https://www.funasr.com/logo.png"}},"mainEntityOfPage":{"@type":"WebPage","@id":"https://www.funasr.com/blog/self-hosted-openai-whisper-api-alternative.html"},"image":"https://www.funasr.com/logo.png"}</script>
<style>:root{--primary:#2563eb;--primary-dark:#1d4ed8;--bg:#fff;--surface:#f8fafc;--border:#e2e8f0;--text:#0f172a;--text-soft:#475569;--text-muted:#94a3b8;--radius:12px}
*{margin:0;padding:0;box-sizing:border-box}
body{font-family:'Inter',-apple-system,sans-serif;color:var(--text);line-height:1.7}
@@ -98,6 +98,7 @@ print(result.text)</code></pre>
<p>根据语言、时延、硬件和说话人需求查看<a href="/docs/model-selection.html">模型选型</a>、<a href="/docs/moss-transcribe-diarize.html">MOSS 转写与说话人分离</a>和<a href="/deploy/">部署矩阵</a>。本文不提供新的准确率或性能排名;验收方法见<a href="/blog/meeting-transcript-acceptance.html">会议录音验收清单</a>。</p>
<section data-editorial="appendix"><h2>附录:核对返回契约</h2>
<h2>包内服务的兼容范围</h2>
+<p data-http-contract="version-boundary"><strong>版本边界:</strong>本文固定的 1.4.15 安装示例中,<code>response_format=text</code> 返回 <code>application/json</code> 编码的字符串,下表描述该历史版本。当前 main 已通过 <a href="https://github.com/modelscope/FunASR/pull/3874">#3874</a> 改为 <code>text/plain</code> 纯文本(<a href="https://github.com/modelscope/FunASR/blob/be264e9382b4fef735536f3d278ee14514098a1a/funasr/bin/_server_app.py">已合并处理器源码</a>)。这不代表已安装服务自动升级;请核对实际安装版本和响应内容,再决定是否进行 JSON 解码。</p>
<table id="api-contract" data-http-contract="formats"><thead><tr><th>项目</th><th>当前行为与接入要求</th></tr></thead><tbody>
<tr><td>请求</td><td>multipart 文件上传;路由声明 <code>file</code>、<code>model</code>、<code>language</code>、<code>response_format</code> 和 FunASR 扩展 <code>spk</code>。语言和说话人能力仍受所选模型限制。</td></tr>
<tr data-response-format="json"><td><code>json</code></td><td>返回带 <code>text</code> 的 JSON 对象,适合先验证基本文本转写。</td></tr>
diff --git a/web-pages/product-site/legacy/en/blog/self-hosted-deepgram-assemblyai-alternative.html b/web-pages/product-site/legacy/en/blog/self-hosted-deepgram-assemblyai-alternative.html
index dd3682ddf..4cff1795b 100644
--- a/web-pages/product-site/legacy/en/blog/self-hosted-deepgram-assemblyai-alternative.html
+++ b/web-pages/product-site/legacy/en/blog/self-hosted-deepgram-assemblyai-alternative.html
@@ -5,7 +5,7 @@
<link rel="canonical" href="https://www.funasr.com/en/blog/self-hosted-deepgram-assemblyai-alternative.html"><link rel="alternate" hreflang="en" href="https://www.funasr.com/en/blog/self-hosted-deepgram-assemblyai-alternative.html"><link rel="alternate" hreflang="zh" href="https://www.funasr.com/blog/self-hosted-deepgram-assemblyai-alternative.html"><link rel="alternate" hreflang="x-default" href="https://www.funasr.com/en/blog/self-hosted-deepgram-assemblyai-alternative.html">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
<script type="application/ld+json">
-{"@context":"https://schema.org","@type":"BlogPosting","headline":"Migrating from Deepgram / AssemblyAI to Self-Hosted FunASR | FunASR Blog","description":"Plan a self-hosted transcription migration: map request and response contracts, authentication, formats, model quality and operating costs. Includes a local FunASR JSON recipe, not a drop-in vendor SDK replacement.","datePublished":"2026-06-23","dateModified":"2026-09-09","author":{"@type":"Organization","name":"FunASR / Tongyi Lab"},"publisher":{"@type":"Organization","name":"FunASR","logo":{"@type":"ImageObject","url":"https://www.funasr.com/logo.png"}},"mainEntityOfPage":{"@type":"WebPage","@id":"https://www.funasr.com/en/blog/self-hosted-deepgram-assemblyai-alternative.html"},"image":"https://www.funasr.com/logo.png"}
+{"@context":"https://schema.org","@type":"BlogPosting","headline":"Migrating from Deepgram / AssemblyAI to Self-Hosted FunASR | FunASR Blog","description":"Plan a self-hosted transcription migration: map request and response contracts, authentication, formats, model quality and operating costs. Includes a local FunASR JSON recipe, not a drop-in vendor SDK replacement.","datePublished":"2026-06-23","dateModified":"2026-11-12","author":{"@type":"Organization","name":"FunASR / Tongyi Lab"},"publisher":{"@type":"Organization","name":"FunASR","logo":{"@type":"ImageObject","url":"https://www.funasr.com/logo.png"}},"mainEntityOfPage":{"@type":"WebPage","@id":"https://www.funasr.com/en/blog/self-hosted-deepgram-assemblyai-alternative.html"},"image":"https://www.funasr.com/logo.png"}
</script>
<style>:root{--primary:#2563eb;--primary-dark:#1d4ed8;--bg:#fff;--surface:#f8fafc;--border:#e2e8f0;--text:#0f172a;--text-soft:#475569;--text-muted:#94a3b8;--radius:12px}
*{margin:0;padding:0;box-sizing:border-box}
@@ -78,6 +78,7 @@ python -m pip check</code></pre>
-F "response_format=json"</code></pre>
<p>The expected structure is a JSON object containing <code>text</code>; its content depends on the audio and model. The 120-second client timeout is an example, not an audio-duration or throughput guarantee. For a basic OpenAI Python SDK call, see the <a href="/en/blog/self-hosted-openai-whisper-api-alternative.html">local transcription integration guide</a>. This does not make the original vendor SDK reusable unchanged.</p>
<h2>Make response-format limits explicit</h2>
+<p data-http-contract="version-boundary"><strong>Version boundary:</strong> The pinned 1.4.15 recipe returns an <code>application/json</code> encoded string for <code>response_format=text</code>; the table below describes that historical version. Current main returns a bare <code>text/plain</code> transcript after <a href="https://github.com/modelscope/FunASR/pull/3874">#3874</a> (<a href="https://github.com/modelscope/FunASR/blob/be264e9382b4fef735536f3d278ee14514098a1a/funasr/bin/_server_app.py">merged handler source</a>). This does not automatically upgrade an installed service: check its installed version and response bytes before choosing JSON decoding.</p>
<table data-http-contract="formats"><thead><tr><th>response_format</th><th>Packaged handler behavior</th></tr></thead><tbody>
<tr data-response-format="json"><td><code>json</code></td><td>Returns a JSON object containing <code>text</code>.</td></tr>
<tr data-response-format="verbose_json"><td><code>verbose_json</code></td><td>Returns structured JSON with fields including <code>segments</code> and <code>duration</code>. Actual timing and speaker information depend on the model and result.</td></tr>
diff --git a/web-pages/product-site/legacy/en/blog/self-hosted-openai-whisper-api-alternative.html b/web-pages/product-site/legacy/en/blog/self-hosted-openai-whisper-api-alternative.html
index 03a230117..8209261ec 100644
--- a/web-pages/product-site/legacy/en/blog/self-hosted-openai-whisper-api-alternative.html
+++ b/web-pages/product-site/legacy/en/blog/self-hosted-openai-whisper-api-alternative.html
@@ -5,7 +5,7 @@
<meta property="og:type" content="article"><meta property="og:url" content="https://www.funasr.com/en/blog/self-hosted-openai-whisper-api-alternative.html"><meta property="og:image" content="https://www.funasr.com/logo.png">
<link rel="canonical" href="https://www.funasr.com/en/blog/self-hosted-openai-whisper-api-alternative.html"><link rel="alternate" hreflang="en" href="https://www.funasr.com/en/blog/self-hosted-openai-whisper-api-alternative.html"><link rel="alternate" hreflang="zh" href="https://www.funasr.com/blog/self-hosted-openai-whisper-api-alternative.html"><link rel="alternate" hreflang="x-default" href="https://www.funasr.com/en/blog/self-hosted-openai-whisper-api-alternative.html">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
-<script type="application/ld+json">{"@context":"https://schema.org","@type":"BlogPosting","headline":"Add transcription to your own API","description":"Start with one recording and a text response. Connect a local application, then check authentication, response formats and deployment boundaries.","datePublished":"2026-06-18","dateModified":"2026-09-09","author":{"@type":"Organization","name":"FunASR / Tongyi Lab"},"publisher":{"@type":"Organization","name":"FunASR","logo":{"@type":"ImageObject","url":"https://www.funasr.com/logo.png"}},"mainEntityOfPage":{"@type":"WebPage","@id":"https://www.funasr.com/en/blog/self-hosted-openai-whisper-api-alternative.html"},"image":"https://www.funasr.com/logo.png"}</script>
+<script type="application/ld+json">{"@context":"https://schema.org","@type":"BlogPosting","headline":"Add transcription to your own API","description":"Start with one recording and a text response. Connect a local application, then check authentication, response formats and deployment boundaries.","datePublished":"2026-06-18","dateModified":"2026-11-12","author":{"@type":"Organization","name":"FunASR / Tongyi Lab"},"publisher":{"@type":"Organization","name":"FunASR","logo":{"@type":"ImageObject","url":"https://www.funasr.com/logo.png"}},"mainEntityOfPage":{"@type":"WebPage","@id":"https://www.funasr.com/en/blog/self-hosted-openai-whisper-api-alternative.html"},"image":"https://www.funasr.com/logo.png"}</script>
<style>:root{--primary:#2563eb;--primary-dark:#1d4ed8;--bg:#fff;--surface:#f8fafc;--border:#e2e8f0;--text:#0f172a;--text-soft:#475569;--text-muted:#94a3b8;--radius:12px}
*{margin:0;padding:0;box-sizing:border-box}
body{font-family:'Inter',-apple-system,sans-serif;color:var(--text);line-height:1.7}
@@ -98,6 +98,7 @@ print(result.text)</code></pre>
<p>Choose by language, latency, hardware and speaker requirements using <a href="/en/docs/model-selection.html">model selection</a>, <a href="/en/docs/moss-transcribe-diarize.html">MOSS transcription and diarization</a> and the <a href="/en/deploy/">deployment matrix</a>. This article supplies no new accuracy or performance ranking. For acceptance criteria, see the <a href="/en/blog/meeting-transcript-acceptance.html">meeting-audio checklist</a>.</p>
<section data-editorial="appendix"><h2>Appendix: verify the response contract</h2>
<h2>Compatibility of the packaged handler</h2>
+<p data-http-contract="version-boundary"><strong>Version boundary:</strong> The pinned 1.4.15 recipe returns an <code>application/json</code> encoded string for <code>response_format=text</code>; the table below describes that historical version. Current main returns a bare <code>text/plain</code> transcript after <a href="https://github.com/modelscope/FunASR/pull/3874">#3874</a> (<a href="https://github.com/modelscope/FunASR/blob/be264e9382b4fef735536f3d278ee14514098a1a/funasr/bin/_server_app.py">merged handler source</a>). This does not automatically upgrade an installed service: check its installed version and response bytes before choosing JSON decoding.</p>
<table id="api-contract" data-http-contract="formats"><thead><tr><th>Item</th><th>Current behavior and integration requirement</th></tr></thead><tbody>
<tr><td>Request</td><td>Multipart upload. The route declares <code>file</code>, <code>model</code>, <code>language</code>, <code>response_format</code> and the FunASR extension <code>spk</code>. Language and speaker capabilities depend on the selected model.</td></tr>
<tr data-response-format="json"><td><code>json</code></td><td>A JSON object with <code>text</code>, suitable for a first basic transcription check.</td></tr>
diff --git a/web-pages/product-site/tests/test_blog_editorial_articles.py b/web-pages/product-site/tests/test_blog_editorial_articles.py
index 69d47a703..025170bd4 100644
--- a/web-pages/product-site/tests/test_blog_editorial_articles.py
+++ b/web-pages/product-site/tests/test_blog_editorial_articles.py
@@ -32,6 +32,7 @@ ARTICLES = {
"self-hosted-openai-whisper-api-alternative": {
"titles": ("把语音转写接进自己的 API", "Add transcription to your own API"),
"published": "2026-06-18",
+ "modified": "2026-11-12",
"codes": ["ffaeacf00f8f84adbc0e2d5c3291412987427592ff9f5518e82cd6e3955062e4", "f87d523ad71de6c2d5f39bb7a549031c98be8feed3663e27f3419cd97179e747", "006d3d5b258d15e2c1be5822b7268b94923d584a730f0fcdd647b9beb4372d05", "4d4613a7fa2355b3134f7d4e932bb69dfac48a1fbac2485da79815e9064cef02"],
},
"meeting-transcript-acceptance": {
@@ -79,7 +80,7 @@ def test_title_metadata_and_existing_routes_stay_in_sync(article):
metadata = json.loads(soup.select_one('script[type="application/ld+json"]').get_text())
assert metadata["headline"] == expected
assert metadata["datePublished"] == ARTICLES[slug]["published"]
- assert metadata["dateModified"] == "2026-09-09"
+ assert metadata["dateModified"] == ARTICLES[slug].get("modified", "2026-09-09")
assert soup.select_one('link[rel="canonical"]')["href"] == f"https://www.funasr.com/{prefix}blog/{slug}.html"
peer = "" if prefix else "en/"
assert soup.select_one(f'link[rel="alternate"][href="https://www.funasr.com/{peer}blog/{slug}.html"]')
diff --git a/web-pages/product-site/tests/test_http_blog_contracts.py b/web-pages/product-site/tests/test_http_blog_contracts.py
index 8167766a4..4876fb3fe 100644
--- a/web-pages/product-site/tests/test_http_blog_contracts.py
+++ b/web-pages/product-site/tests/test_http_blog_contracts.py
@@ -325,7 +325,20 @@ def test_example_links_do_not_own_packaged_installation_or_schema(site_tree, pre
visible_text(link)
-def test_packaged_format_implementation_still_matches_documented_boundary():
[email protected]("prefix,slug", PAGES)
+def test_visible_version_boundary_separates_pinned_recipe_from_current_main(site_tree, prefix, slug):
+ soup = read_page(site_tree, prefix, slug)
+ notice = soup.select_one('article [data-http-contract="version-boundary"]')
+ text = visible_text(notice)
+ for value in ("1.4.15", "response_format=text", "application/json", "text/plain", "main"):
+ assert value in text, (value, text)
+ assert notice.select_one('a[href="https://github.com/modelscope/FunASR/pull/3874"]')
+ source = "https://github.com/modelscope/FunASR/blob/be264e9382b4fef735536f3d278ee14514098a1a/funasr/bin/_server_app.py"
+ assert notice.select_one(f'a[href="{source}"]')
+ assert notice.find_next("table") == soup.select_one('[data-http-contract="formats"]')
+
+
+def test_current_packaged_text_format_returns_plain_text():
tree = ast.parse((REPO / "funasr/bin/_server_app.py").read_text())
handler = next(node for node in ast.walk(tree)
if isinstance(node, ast.AsyncFunctionDef) and node.name == "transcribe")
@@ -338,7 +351,7 @@ def test_packaged_format_implementation_still_matches_documented_boundary():
and node.test.left.id == "response_format"
and node.test.comparators[0].value == "text")
returned = text_branch.body[0].value
- assert isinstance(returned, ast.Call) and returned.func.id == "JSONResponse"
+ assert isinstance(returned, ast.Call) and returned.func.id == "PlainTextResponse"
assert ast.dump(returned.args[0]) == ast.dump(ast.parse('result["text"]', mode="eval").body)