Skip to content

Fix Windows path escaping and make long-audio transcription resumable - #2

Open
yingzhouquan3-art wants to merge 2 commits into
cimu233:mainfrom
yingzhouquan3-art:fix/long-audio-and-windows-paths
Open

Fix Windows path escaping and make long-audio transcription resumable#2
yingzhouquan3-art wants to merge 2 commits into
cimu233:mainfrom
yingzhouquan3-art:fix/long-audio-and-windows-paths

Conversation

@yingzhouquan3-art

Copy link
Copy Markdown

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_component mapped / and : to their fullwidth twins, but
Windows also rejects \ * ? " < > |. A lesson titled
新时代视角下的"执行力"新解 failed at directory creation:

OSError: [WinError 123] The filename, directory name, or volume label
syntax is incorrect

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_error is now halved and
retried, 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 tests reports 63 failures before and after these commits — no
new 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.

yingzhouquan3-art and others added 2 commits August 29, 2026 01:50
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant