Support longer audio files reducing memory usage with chunking #2256
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.
Description
The current implementation of Whisper loads the entire audio file into memory during transcription. This approach demands a substantial amount of memory, making it highly likely to run out of memory, especially for very long audio files (many hours).
This proposed change modifies the processing mechanism so that the audio file, when processed by ffmpeg, is loaded in chunks with a maximum duration of two hours. These chunks are processed sequentially, significantly reducing memory usage.
Test Plan
Unit Tests: Verified with existing unit tests to ensure no regression.
Long Audio Files: Tested with audio files up to 16 hours in duration to confirm stability and efficiency.