Fix Windows path escaping and make long-audio transcription resumable - #2
Open
yingzhouquan3-art wants to merge 2 commits into
Open
Fix Windows path escaping and make long-audio transcription resumable#2yingzhouquan3-art wants to merge 2 commits into
yingzhouquan3-art wants to merge 2 commits into
Conversation
Only "/" and ":" were mapped to their fullwidth twins. Windows also
rejects \ * ? " < > | in a path component, so a lesson whose title
contains one of them failed at directory creation:
OSError: [WinError 123] The filename, directory name, or volume
label syntax is incorrect
A title like 新时代视角下的"执行力"新解 was enough to lose the lesson.
macOS only rejects the separator, so this never showed up there.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Two problems surfaced transcribing a 4h20m lesson split into 66 chunks. Chunk results were accumulated in memory and only written once every chunk had succeeded, so a failure on chunk 50 discarded the 49 already transcribed - and the retry re-sent, and re-paid for, all of them. Cache each result next to its chunk (including the raw payload, which carries the usage accounting) and reuse it on the next run. Separately, one chunk stalled until the request timed out, every time, while its neighbours took two seconds. It held four minutes of unbroken intro music; the same audio transcribed fine once split. Halve a chunk that returns provider_network_error and retry the halves, to a depth of two, so a lesson is no longer lost to a single unlucky segment. Offsets are recomputed per depth so merged timings stay correct. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Two independent fixes found while transcribing a 50-lesson course on
Windows 11. Neither depends on #1.
1. Path components kept characters Windows rejects
_safe_human_componentmapped/and:to their fullwidth twins, butWindows also rejects
\ * ? " < > |. A lesson titled新时代视角下的"执行力"新解failed at directory creation:macOS only rejects the separator, so this is invisible there. Now all
nine are mapped, which keeps titles readable rather than stripping them.
2. A long lesson could not be retried, and one chunk could sink it
Transcribing a 4h20m lesson (66 chunks) surfaced two problems.
Chunk results were only persisted after every chunk succeeded. A
failure on chunk 50 discarded the 49 already transcribed, and the retry
re-sent all of them — paying for the same audio again. On a metered ASR
provider that is a silent cost you only notice on the invoice. Each
chunk result is now cached beside its audio, including the raw payload so
usage accounting survives, and reused on the next run.
One chunk stalled until timeout, reproducibly, while its neighbours
returned in ~2s. Same size, same duration. It held four minutes of
unbroken intro music — the host playing a track while waiting for an
audience — and the identical audio transcribed fine once split in half.
A chunk that fails with
provider_network_erroris now halved andretried, to a depth of two (4min → 2min → 1min), so a lesson is not lost
to a single unlucky segment. Offsets are recomputed per depth so merged
segment timings stay correct.
Testing
pytest testsreports 63 failures before and after these commits — nonew failures. The pre-existing ones look environment-related (the suite
assumes macOS paths and can bind ports); a few are flaky between runs.
Verified end to end on the affected course: the quoted title now creates
its directory, and the 4h20m lesson completes, halving exactly one chunk
and reusing the other 65 from cache.