Fix for crash in alignment when called with no tokens#1081
Open
balooii wants to merge 1 commit intom-bain:mainfrom
Open
Fix for crash in alignment when called with no tokens#1081balooii wants to merge 1 commit intom-bain:mainfrom
balooii wants to merge 1 commit intom-bain:mainfrom
Conversation
|
Worked for me, thanks EDIT: I was using version 3.3.1 |
|
I haven't had this issue since upgrading to v3.3.2. Is it still necessary to address it? |
|
I was using version 3.3.1, I did not try with 3.3.2. However in alignment.py, get_wildcard_emission() is the same in both versions so it might be worth it to add this fix (unless the bug has been fixed in another part of the code) Thank you for your work anyway :) |
bjollans
added a commit
to bjollans/whisperX
that referenced
this pull request
Jun 7, 2025
|
I patched that issue for upper boundary also. Test code below # Run (in virtualenv): python test_alignment_out_of_bounds.py
import torch
from whisperx import alignment as A
def run_case(V, tokens, blank_id=0, label=""):
fe = torch.randn(V, dtype=torch.float32)
t = torch.tensor(tokens, dtype=torch.long)
try:
out = A.get_wildcard_emission(fe, t, blank_id)
ok = bool(torch.isfinite(out).all())
print(f"[OK ] {label:40s} -> out.shape={tuple(out.shape)} finite={ok}")
except Exception as e:
print(f"[ERR] {label:40s} -> {type(e).__name__}: {e}")
print("Testing whisperx.alignment.get_wildcard_emission")
print("Function:", A.get_wildcard_emission.__code__.co_filename)
# OFF-BY-ONE repro: token == vocab size (V)
run_case(34, [34], 0, "off-by-one (V=34, token=V)")
# Mixed case: wildcard + valid + token==V
run_case(34, [-1, 0, 5, 34], 0, "wildcard + in-range + token=V")
# Edge case: empty emissions (should assert / error, but not IndexError from indexing)
run_case(0, [0], 0, "empty emissions (V=0)") |
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.
Fixes #1048
There are probably better ways to do this but this change restores previous behavior which worked before changes from 65b2332
-> when called with empty list of tokens return empty tensor