Skip to content

fix(asr): Whisper/OpenRouter 动态超时 + 全局兜底 15→30s#723

Merged
H-Chris233 merged 2 commits into
Open-Less:betafrom
H-Chris233:fix/whisper-dynamic-timeout-721
Jun 21, 2026
Merged

fix(asr): Whisper/OpenRouter 动态超时 + 全局兜底 15→30s#723
H-Chris233 merged 2 commits into
Open-Less:betafrom
H-Chris233:fix/whisper-dynamic-timeout-721

Conversation

@H-Chris233

@H-Chris233 H-Chris233 commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

User description

问题

Closes #721

OpenRouter Whisper 长语音被 15s 全局超时硬截断。

方案

双重保险:

  1. 全局常量 15→30s:`COORDINATOR_GLOBAL_TIMEOUT_SECS` 提升为云端 ASR 留网络预算
  2. Whisper 动态超时:`whisper_transcribe_timeout(audio_secs)` = `max(30, ceil(audio×0.5)+20)`,参考本地 Qwen 的 `local_qwen_transcribe_timeout`
音频 旧超时 新超时
10s 15s 30s
30s 15s ❌ 35s ✅
60s 15s ❌ 50s ✅
90s 15s ❌ 65s ✅

改动

3 文件,+32 / −7 行,`cargo check` 通过。


PR Type

Bug fix, Enhancement


Description

  • Increase global ASR timeout from 15s to 30s

  • Add dynamic timeout for Whisper/OpenRouter based on audio duration

  • Log audio duration and timeout for debugging

  • Add unit tests covering new timeout logic


Diagram Walkthrough

flowchart LR
  endSession["End Session (Whisper)"] -- audio_secs from buffer_duration_ms() --> calc["whisper_transcribe_timeout(audio_secs)"]
  calc -- "timeout_duration = max(30, ceil(audio*0.5)+20)" --> call["tokio::time::timeout(timeout_duration, w.transcribe())"]
  call -- "Ok(r)" --> transcript["Return transcript"]
  call -- "Err(_)" --> log["Log timeout with audio_secs"]
Loading

File Walkthrough

Relevant files
Enhancement
whisper.rs
Expose buffer duration for timeout calculation                     

openless-all/app/src-tauri/src/asr/whisper.rs

  • Add buffer_duration_ms() method to WhisperBatchASR to expose audio
    duration
  • Allows coordinator to compute dynamic timeout before transcribing
+6/-0     
coordinator.rs
Implement Whisper timeout function and update tests           

openless-all/app/src-tauri/src/coordinator.rs

  • Raise COORDINATOR_GLOBAL_TIMEOUT_SECS from 15 to 30
  • Add whisper_transcribe_timeout() function with formula max(30,
    ceil(audio*0.5)+20)
  • Update local_qwen_timeout tests to align with new global timeout
  • Add 3 new unit tests for Whisper timeout (short audio, scaling, ceil)
+46/-7   
Bug fix
dictation.rs
Apply dynamic timeout to Whisper/OpenRouter session           

openless-all/app/src-tauri/src/coordinator/dictation.rs

  • Use buffer_duration_ms() and whisper_transcribe_timeout() for dynamic
    timeout
  • Log audio duration and computed timeout duration
  • Update error log message to include actual timeout seconds
+12/-4   

@github-actions

github-actions Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

(Review updated until commit e1f24b6)

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

721 - Partially compliant

Compliant requirements:

  • Whisper-compatible ASR, especially OpenRouter Whisper path, no longer use fixed 15s global timeout. (Dynamic timeout introduced, global fallback increased to 30s.)
  • OpenRouter Whisper uses dynamic timeout based on audio length.
  • Do not revert feat(asr): 支持 OpenRouter 作为 ASR 提供商 (#582) #591's OpenRouter JSON+base64 request format.

Non-compliant requirements:

  • Log audio duration, chunk count, provider, timeout seconds. (Only audio duration and timeout are logged; chunk count and provider are missing.)
  • OpenRouter chunk requests can tolerate brief network jitter; errors distinguish provider HTTP error, network error, client timeout. (No error type differentiation added.)
  • Provide retry path on transcribe failure: preserve audio/PCM for retry or at least allow re-transcribe in debug/settings. (No retry path implemented; existing PCM retention is unchanged but no retry UI/logic.)

Requires further human verification:

(empty)

⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

@H-Chris233 H-Chris233 force-pushed the fix/whisper-dynamic-timeout-721 branch from 4d7ea2e to e1f24b6 Compare June 21, 2026 04:50
@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit e1f24b6

@H-Chris233 H-Chris233 merged commit b07f78b into Open-Less:beta Jun 21, 2026
5 checks passed
- COORDINATOR_GLOBAL_TIMEOUT_SECS 从 15 改为 30,为云端 batch ASR 留网络预算
- 新增 whisper_transcribe_timeout(audio_secs):max(30, ceil(audio×0.5)+20)
- WhisperBatchASR 新增 buffer_duration_ms() 供 coordinator 计算动态超时
- dictation.rs Whisper 路径从固定 15s 切到动态超时,超时日志包含音频时长

Closes Open-Less#721
- local_qwen_timeout_ceils_partial_seconds: 10.1s 音频原期望 17s,全局常量
  提升到 30s 后改为期望 COORDINATOR_GLOBAL_TIMEOUT_SECS
- 更新相关注释中的 15→30
- 新增 3 个 whisper_transcribe_timeout 测试:短音频兜底、长音频缩放、ceil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[asr] OpenRouter Whisper 长语音触发 15 秒全局超时

1 participant