feat(history): 转录失败保留录音 + 历史「重新转录」(#613)#637
Merged
Merged
Conversation
ASR 转录失败时若本次录音已归档,写一条 transcribeFailed 历史记录,让用户能在 历史页回放原始录音并对其重新转录,不再丢失可恢复的语音内容。 后端: - dictation_end: 新增 write_transcribe_failed_history 辅助函数,在 14 处真实 转录失败分支(各 provider 的 Ok(Err)/超时;不含 cancel/empty 分支)写历史。 history id 用 coordinator session_id,与归档 wav 文件名对齐,回放/重转才能命中。 仅在录音确已归档时写(沿用 empty-transcript「以实际归档状态为准」语义)。 - coordinator: retranscribe_pcm —— 复用 build_qa_asr_start,用当前 provider 对一段 PCM 重新转录,统一覆盖流式/批处理全部 provider,整段超时兜底。 - persistence: HistoryStore::update_entry,原地按 id 替换历史条目(保持位置)。 - commands/history: retranscribe_recording 命令 —— 读归档 wav→取 PCM→重转→回写 rawTranscript/finalText 并清 error_code,返回更新后的整条记录。已注册到 lib.rs。 前端: - ipc: retranscribeRecording。 - History.tsx: 失败条目(有 errorCode)且录音仍在时显示「重新转录」按钮, loading 态防重复点击,成功后局部刷新该条。 - i18n: history.retranscribe / retranscribing / retranscribeFailed(5 语言)。 仅做 ASR 重转,不自动二次润色(依赖 LLM 凭据且 issue 标为待定,留作后续)。 验证:cargo check + cargo test(481 通过)+ npm run build 均通过。 Closes #613 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
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
背景
Closes #613。ASR 转录失败(网络错误 / 超时 / 引擎异常)时,当前各失败分支只
emit_capsule(Error)后return Err,不写历史 —— 即使用户开了「保留原始录音」,也无法在历史页找到这次会话、回放录音或重试。本 PR 让失败也能恢复。改动清单
后端
coordinator/dictation_end.rs:新增write_transcribe_failed_history辅助函数;在 14 处真实转录失败分支(各 provider 的Ok(Err)/ 超时;不含 cancel / empty-transcript 分支)调用它写一条transcribeFailed历史。session_id(而非新 UUID),与 recorder 旁路写盘的recordings/<id>.wav同名 —— 否则回放 / 重转会 404。audio_archive_active,沿用 empty-transcript「以实际归档状态为准」语义),未归档不写空壳记录。coordinator.rs:retranscribe_pcm(pcm)—— 复用build_qa_asr_start,用当前 ASR provider 对一段 PCM 重新转录,统一覆盖流式(Volcengine/Bailian)+ 批处理(Whisper/Mimo/local-qwen/Foundry/sherpa)全部 provider,整段超时兜底。persistence.rs:HistoryStore::update_entry—— 原地按 id 替换历史条目(保持原位置),找不到返回Ok(false)。commands/history.rs:retranscribe_recording命令 —— 校验 id → 读归档 wav → 取 PCM(跳过 44 字节 WAV 头)→ 重转 → 回写rawTranscript/finalText并清error_code→ 返回更新后的整条记录。已注册到lib.rs。前端
lib/ipc.ts:retranscribeRecording。pages/History.tsx:失败条目(有errorCode)且录音仍在时显示「重新转录」按钮,loading 态防重复点击,成功后局部刷新该条。history.retranscribe/retranscribing/retranscribeFailed(zh-CN / en / ja / ko / zh-TW 全部同步)。验收标准对照(issue #613)
errorCode = transcribeFailed)read_audio_recording,id 与 wav 对齐)rawTranscript/finalText并清除错误状态取舍 / 待定(issue 里标为「不确定项」)
测试情况
cargo check(macOS)✅cargo test --lib:481 通过 ✅npm run build(tsc + vite)✅🤖 Generated with Claude Code
PR Type
Bug fix, Enhancement
Description
转录失败时保留录音并写入历史
新增「重新转录」功能,对归档录音重新ASR
前端支持重新转录按钮及局部刷新
Diagram Walkthrough
File Walkthrough
11 files
add retranscribe_recording command for failed entriesadd retranscribe_pcm method for re-transcriptionregister retranscribe_recording commandadd update_entry to replace history entry in-placeadd i18n keys for retranscribeadd i18n keys for retranscribeadd i18n keys for retranscribeadd i18n keys for retranscribeadd i18n keys for retranscribeadd retranscribeRecording IPC functionadd retranscribe button for failed entries1 files
write failed transcription history on ASR error branches