Skip to content

Claude/fix large file transcription q ob73 - #52

Open
End2EndAI wants to merge 2 commits into
mainfrom
claude/fix-large-file-transcription-qOB73
Open

Claude/fix large file transcription q ob73#52
End2EndAI wants to merge 2 commits into
mainfrom
claude/fix-large-file-transcription-qOB73

Conversation

@End2EndAI

Copy link
Copy Markdown
Owner

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

claude added 2 commits April 5, 2026 19:53
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
@vercel

vercel Bot commented Apr 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
voicekeeper Ready Ready Preview, Comment Apr 7, 2026 2:51pm

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.

2 participants