-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AttributeError: 'Wav2Vec2Processor' object has no attribute 'sampling_rate' #722
Comments
I have the same issue, does anyone get around this? It might be caused by some breaking changes in transformers, I'll try downgrading transformers. |
Finally I solved this error rewriting - inputs = processor(waveform_segment.squeeze(), sampling_rate=processor.sampling_rate, return_tensors="pt").to(device)
+ inputs = processor(waveform_segment.squeeze(), sampling_rate=processor.feature_extractor.sampling_rate, return_tensors="pt").to(device) |
Thanks, i've made small patch file that make it backwards compatible --- .venv/lib/python3.11/site-packages/whisperx/alignment.py 2024-03-03 17:22:05.042130573 +0300
+++ .venv/lib/python3.11/site-packages/whisperx/alignment.py 2024-03-03 17:25:20.760972944 +0300
@@ -229,7 +229,13 @@
emissions, _ = model(waveform_segment.to(device), lengths=lengths)
elif model_type == "huggingface":
if preprocess:
- inputs = processor(waveform_segment.squeeze(), sampling_rate=processor.sampling_rate, return_tensors="pt").to(device)
+ sample_rate = None
+ if 'sampling_rate' in processor.__dict__:
+ sample_rate = processor.sampling_rate
+ if 'feature_extractor' in processor.__dict__ and 'sampling_rate' in processor.feature_extractor.__dict__:
+ sample_rate = processor.feature_extractor.sampling_rate
+
+ inputs = processor(waveform_segment.squeeze(), sampling_rate=sample_rate, return_tensors="pt").to(device)
emissions = model(**inputs).logits
else:
emissions = model(waveform_segment.to(device)).logits |
How did you solve it, I tried to find the code you mentioned its not exist. |
I also don't see the code referenced above. |
@alfahadgm @melanie-rosenberg, i am unsure why but this fix intended for v3.1.2, which it seems has been removed from the repo for some reason. Maybe @m-bain can shed some light on why |
Thank you @arabcoders -- applying the patch worked while using v3.1.2. |
FYI @alfahadgm running this also worked: |
Here's some info about the PyPI release vs this repo in case anyone else is confused like I was: It seems like the PyPI releases are created by someone other than the maintainer of this repo according to #700 (comment). The above patch works on top of this PR #625. |
That version on PyPi was from a fork and not this repo. Note as of January 1st 2025, the whisperX project on PyPi will be maintained by the author of this project. Previous, unofficial, versions have been removed to prevent potential issues. |
@HHousen You're very welcome to create a PR for your fix, if it also applies to this repo. |
Hello, I have simple project testing out whisperx, the test script
leads to
I am unable to get it working at all. testing just faster-whisper works ok it seems there is problem with the Wav2Vec model.
The text was updated successfully, but these errors were encountered: