Skip to content

fix(whisper): ignore empty non-speech token encodings - #934

Open
saichowdary007 wants to merge 2 commits into
Blaizzy:mainfrom
saichowdary007:fix/whisper-empty-non-speech-tokens
Open

fix(whisper): ignore empty non-speech token encodings#934
saichowdary007 wants to merge 2 commits into
Blaizzy:mainfrom
saichowdary007:fix/whisper-empty-non-speech-tokens

Conversation

@saichowdary007

Copy link
Copy Markdown

Summary

Fixes #917.

HFTokenizerWrapper.non_speech_tokens indexed the result of several tokenizer
encodes without checking whether the tokenizer returned any tokens. English
only Whisper tokenizers can return an empty list for the seed strings, which
made every transcription fail with IndexError. Empty encodings are now
ignored for both the seed tokens and miscellaneous symbols; existing tokens
and suppression behavior are unchanged.

Testing

  • .venv/bin/python -m pytest tests/test_whisper_decode_options.py -q (8 passed)
  • .venv/bin/pre-commit run --files mlx_audio/stt/models/whisper/whisper.py tests/test_whisper_decode_options.py

The regression tests cover empty seed encodings and empty miscellaneous-symbol
encodings with lightweight fake tokenizers.

Implementation and test preparation used AI assistance; the submitting
contributor reviewed the changed lines and owns the behavior validation.

Fixes Blaizzy#917

Signed-off-by: sai <saikumar@sais-MacBook-Pro.local>
@github-actions

Copy link
Copy Markdown

⚠️ GitHub does not mark 1 commit in this PR as Verified.

Please sign every commit, then update the PR. You can review the commits on the commits tab and follow GitHub's commit-signing guide if needed.

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.

Whisper non_speech_tokens crashes with IndexError: encode(" -")[0] on empty result (0.4.4 STT)

1 participant