fix(asr): 修复 Windows 本地长语音只识别前段#769
Open
Duyi-Wang wants to merge 2 commits into
Open
Conversation
Contributor
PR Reviewer Guide 🔍(Review updated until commit 3f2c6a4)Here are some key observations to aid the review process:
|
Contributor
|
Persistent review updated to latest commit 3f2c6a4 |
H-Chris233
approved these changes
Jul 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
摘要
修复 Windows 本地 ASR 在长语音场景下可能只识别前一段的问题。
主要原因是
foundry-local-whisper使用 Whisper 系模型,单次解码窗口约 30 秒;当录音超过这个窗口时,单次把整段 WAV 交给 Foundry SDK 可能只返回前段结果。这个 PR 将 Foundry Local Whisper 的 PCM 输入按 30 秒分片转写,再合并分片文本;同时把 Windows 本地 ASR 的转写超时从固定 30 秒改为按音频时长动态增长。未关联 issue。
修复 / 新增 / 改进
foundry-local-whisper录音结束后按 30 秒 PCM chunk 分片,逐段生成临时 WAV 并调用 Foundry SDK。buffer_duration_ms(),coordinator 可按实际录音长度计算 timeout。max(30s, ceil(audio_s) + 20s),避免长音频撞固定 30 秒超时。兼容
不包含:
对现有用户 / 本地环境 / 构建流程的影响:
foundry-local-whisper下会拆成多段本地识别,整体耗时会随音频长度增加,但可以覆盖完整录音。sherpa-onnx-local仅调整 timeout 预算,不改变识别输入和模型调用方式。测试计划
命令:
cargo test结果:本地 Rust 单测通过,
546 passed; 0 failed证据路径:本地终端运行结果
命令:fork 上的 GitHub Actions CI
结果:通过
证据路径:https://github.com/Duyi-Wang/openless/actions/runs/28922670487
命令:fork 上的桌面安装包构建
Release Tauri (cross-platform)结果:通过
证据路径:https://github.com/Duyi-Wang/openless/actions/runs/28922670561
命令:fork 上的 Android APK 构建
结果:通过
证据路径:https://github.com/Duyi-Wang/openless/actions/runs/28922670488
PR Type
Bug fix
Description
Split Foundry Local Whisper PCM into 30s chunks to prevent truncation of long recordings
Added dynamic transcribe timeout (max(30s, ceil(audio_s)+20s)) for Windows local ASR
Exposed buffer_duration_ms() from Foundry and Sherpa providers
Applied dynamic timeout to dictation, QA, overlay QA, and re-transcription paths
Diagram Walkthrough
File Walkthrough
foundry_provider.rs
Chunk Foundry Whisper PCM into 30s segmentsopenless-all/app/src-tauri/src/asr/local/foundry_provider.rs
buffer_duration_ms() method
with remaining deadline timeout
timeout calculation, and buffer reporting
sherpa_provider.rs
Add buffer_duration_ms to Sherpa ONNX provideropenless-all/app/src-tauri/src/asr/local/sherpa_provider.rs
(worker audio bytes) modes
whisper.rs
Export PCM split and transcript join functionsopenless-all/app/src-tauri/src/asr/whisper.rs
for reuse by Foundry provider
coordinator.rs
Replace fixed timeouts with dynamic per-audio timeoutopenless-all/app/src-tauri/src/coordinator.rs
windows_local_asr_transcribe_timeout(audio_secs)
re_transcribe_current_session to use audio-relative timeout
→ 85s)
dictation.rs
Use dynamic timeout in dictation end sessionopenless-all/app/src-tauri/src/coordinator/dictation.rs
compute timeout from buffer_duration_ms()
qa_session.rs
Use dynamic timeout in QA transcription pathsopenless-all/app/src-tauri/src/coordinator/qa_session.rs
Foundry and Sherpa to compute dynamic timeout