Claude/fix large file transcription q ob73 - #52
Open
End2EndAI wants to merge 2 commits into
Open
Conversation
The old chunking logic split raw file bytes at arbitrary boundaries, producing invalid audio files that Whisper rejects. Web used blob.slice() on WebM containers; native split base64-encoded M4A at random offsets. Fix: Web now decodes via AudioContext to PCM then encodes valid WAV chunks. Native parses the M4A (MP4) container to find sample boundaries and builds valid M4A files for each chunk with proper atoms. https://claude.ai/code/session_01AALsZMcA3oGi5w3xEcR71C
The previous buildM4AFile used a byte-search to find 'stco' in the moov and patch its offset. This search could find false matches in atom type fields, causing the stco to point into moov instead of mdat — producing files Whisper rejects as "format not supported". Fix: pre-calculate all atom sizes, compute the correct stco offset upfront, then write the entire file sequentially into a single buffer. No search-and-patch needed. Also: - Parse ALL stco entries + stsc for proper multi-chunk M4A support (common in Android MediaRecorder files) - Compute per-sample file offsets instead of assuming contiguous layout - Add roundtrip tests (build → parse → verify audio data at offsets) https://claude.ai/code/session_01AALsZMcA3oGi5w3xEcR71C
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Summary
Bug: Large file (>25MB) transcription produced invalid audio chunks that Whisper rejected with "The audio file could not be decoded or its format is not supported"
Root cause (web): blob.slice() split raw WebM bytes at arbitrary offsets — chunks lacked valid container headers
Root cause (native): Base64 M4A was split at random byte boundaries, and the M4A muxer used a byte-search to find stco in the moov for patching, which could match at wrong positions causing the offset to point inside moov instead of mdat
Fix: New audio-splitter.ts module with proper platform-specific splitting:
Web: AudioContext.decodeAudioData() → PCM → time-based WAV chunks
Native: Parse M4A container (stco/stsc/stsz/stts), split at AAC sample boundaries, build valid M4A files with pre-calculated atom sizes (no byte-search patching)
Test plan
[x] All 22 unit tests pass (8 orchestration + 14 M4A roundtrip)
[x] Roundtrip test: buildM4AFile → parseM4A → verify audio data at correct offsets
[x] Double roundtrip: build → parse → rebuild → re-parse gives identical results
[x] sttsForRange correctly handles partial/spanning/full entry ranges
[ ] Manual test: transcribe a >25MB recording on Android