Repository navigation
whisper: add progress_callback to transcribe() - #1459
Open
KAJI-JAPAN wants to merge 1 commit into
Open
KAJI-JAPAN wants to merge 1 commit into
KAJI-JAPAN wants to merge 1 commit into
Conversation
Call an optional progress_callback(frames_done, total_frames) after each 30-second window is decoded or skipped as silence, so that programs embedding mlx-whisper can show progress without patching tqdm. The default None keeps the current behaviour.
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.
What
Adds an optional
progress_callbackargument tomlx_whisper.transcribe(). It is called with(frames_done, total_frames)after each 30-second window is decoded or skipped as silence (a frame is 10 ms of audio). The defaultNonekeeps the current behaviour.Why
transcribe()reports progress only through the tqdm bar (verbose=False) or by printing segments (verbose=True), so a program that embeds mlx-whisper (a web UI, a GUI, a job queue) cannot receive progress as a value. In my own small web app for transcribing lesson recordings, I currently monkey-patchmlx_whisper.transcribe.tqdmto read the frame count. That breaks silently on any refactor and leaks across concurrent calls.The callback is also called when a window is skipped as no-speech. Without that, a recording that ends in silence stops reporting at the last voiced window (3000 of 6666 frames for the test audio plus 60 s of silence) even though transcription has finished. The tqdm bar has the same gap; I left it unchanged to keep this PR small.
Related: #1373 asks for a way to cancel or time out
transcribe(). This PR does not solve that, because the callback runs between windows and not insidedecode().Tests
test_transcribe_progress_callback: the test audio plus 60 s of trailing silence. It checks that the callback is called more than once,frames_donenever decreases, and the last call is(total, total). It fails without the call in the no-speech branch.python -m unittest testinwhisper/: 12 tests pass.pre-commit run(black, isort) passes.verbose=None,FalseandTrue.