Conversation
Fix issue #944 where progress bar would jump backwards during transcription. Root cause: When audio is split into chunks for parallel processing, progress callbacks from different chunks were interleaved, causing the overall progress to regress (e.g., 80% -> 20%). Changes: - ChunkedASR: Track each chunk's progress separately, calculate weighted average, and only emit progress when it increases - FasterWhisperASR: Add monotonic progress protection Co-Authored-By: Claude Opus 4.5 <[email protected]>
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
There was a problem hiding this comment.
Pull request overview
This pull request fixes issue #944 where the transcription progress bar would regress (e.g., jump from 80% back to 20%) when processing long audio files that are split into chunks and processed in parallel.
Changes:
- Added monotonic progress increase protection in
FasterWhisperASRto prevent progress regression - Implemented weighted average progress calculation in
ChunkedASRwith thread-safe progress tracking - Changed progress message formatting to remove space before '%' sign for consistency
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| app/core/asr/faster_whisper.py | Added last_progress tracking variable and monotonic increase check to prevent progress callback from reporting lower values |
| app/core/asr/chunked_asr.py | Introduced thread-safe progress tracking with per-chunk progress array, progress lock, and monotonic increase enforcement using weighted average calculation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| idx: int, chunk_bytes: bytes, offset_ms: int | ||
| ) -> Tuple[int, ASRData]: | ||
| """转录单个音频块 - 为每个块创建独立的 ASR 实例""" | ||
| nonlocal last_overall |
There was a problem hiding this comment.
The nonlocal declaration for last_overall on line 180 is redundant because it's already declared as nonlocal on line 184 within the nested chunk_callback function. The outer transcribe_single_chunk function doesn't need to declare it as nonlocal since it's not modifying it directly - only the inner callback does.
| nonlocal last_overall |
| with progress_lock: | ||
| chunk_progress[idx] = progress | ||
| overall = sum(chunk_progress) // total_chunks | ||
| # 只允许进度单调递增 | ||
| if overall > last_overall: | ||
| last_overall = overall | ||
| callback(overall, f"{idx+1}/{total_chunks}: {message}") |
There was a problem hiding this comment.
The new monotonic progress increase behavior is not covered by tests. Consider adding a test that verifies progress values are monotonically increasing when multiple chunks are processed concurrently. The test could track all callback invocations and verify that each progress value is greater than or equal to the previous one.
Summary
修复 #944 转录时进度条回退的问题。
问题原因:当音频较长被分块并行处理时,不同块的进度回调是交错的,导致整体进度出现回退(比如已经到 80%,突然跳回 20%)。
修复方案:
ChunkedASR:记录每个块的进度,计算加权平均值,只在进度增加时才更新FasterWhisperASR:补充单调递增保护Test plan
🤖 Generated with Claude Code
Note
Fixes progress rollback during transcription by enforcing monotonic progress updates.
last_progressand only forward increasing mapped progress values; minor formatting change to progress message (e.g.,85%).Written by Cursor Bugbot for commit e9a8bab. This will update automatically on new commits. Configure here.