transformers - 💡(How to fix) Fix Issue with _torch_extract_fbank_features() [2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
huggingface/transformers#44220Fetched 2026-04-08 00:29:45
View on GitHub
Comments
2
Participants
3
Timeline
6
Reactions
0
Timeline (top)
commented ×2closed ×1labeled ×1mentioned ×1

Error Message

File "/usr/local/lib/python3.11/dist-packages/transformers/pipelines/pt_utils.py", line 271, in next processed = self.infer(next(self.iterator), **self.params) ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/torch/utils/data/dataloader.py", line 741, in next data = self._next_data() ^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/torch/utils/data/dataloader.py", line 801, in _next_data data = self._dataset_fetcher.fetch(index) # may raise StopIteration ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/torch/utils/data/_utils/fetch.py", line 35, in fetch data.append(next(self.dataset_iter)) ^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/transformers/pipelines/pt_utils.py", line 188, in next processed = next(self.subiterator) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/transformers/pipelines/automatic_speech_recognition.py", line 486, in preprocess processed = self.feature_extractor( ^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/transformers/models/lasr/feature_extraction_lasr.py", line 266, in call input_features = self._torch_extract_fbank_features(input_features, device, center) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: LasrFeatureExtractor._torch_extract_fbank_features() takes from 2 to 3 positional arguments but 4 were given

Code Example

pipe = pipeline("automatic-speech-recognition", model=model_id)
result = pipe(audio,chunk_length_s=20,stride_length_s=2)

---

File "/usr/local/lib/python3.11/dist-packages/transformers/pipelines/pt_utils.py", line 271, in __next__
    processed = self.infer(next(self.iterator), **self.params)
                           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/torch/utils/data/dataloader.py", line 741, in __next__
    data = self._next_data()
           ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/torch/utils/data/dataloader.py", line 801, in _next_data
    data = self._dataset_fetcher.fetch(index)  # may raise StopIteration
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/torch/utils/data/_utils/fetch.py", line 35, in fetch
    data.append(next(self.dataset_iter))
                ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/transformers/pipelines/pt_utils.py", line 188, in __next__
    processed = next(self.subiterator)
                ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/transformers/pipelines/automatic_speech_recognition.py", line 486, in preprocess
    processed = self.feature_extractor(
                ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/transformers/models/lasr/feature_extraction_lasr.py", line 266, in __call__
    input_features = self._torch_extract_fbank_features(input_features, device, center)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: LasrFeatureExtractor._torch_extract_fbank_features() takes from 2 to 3 positional arguments but 4 were given

---

pipe = pipeline("automatic-speech-recognition", model=model_id)
result = pipe(audio,chunk_length_s=20,stride_length_s=2)
RAW_BUFFERClick to expand / collapse

System Info

transformers version 5.2.0 (this is where the bug was introducted).

Get the error below when calling ASR pipeline code like this:

pipe = pipeline("automatic-speech-recognition", model=model_id)
result = pipe(audio,chunk_length_s=20,stride_length_s=2)

Error:

File "/usr/local/lib/python3.11/dist-packages/transformers/pipelines/pt_utils.py", line 271, in __next__
  processed = self.infer(next(self.iterator), **self.params)
                         ^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/torch/utils/data/dataloader.py", line 741, in __next__
  data = self._next_data()
         ^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/torch/utils/data/dataloader.py", line 801, in _next_data
  data = self._dataset_fetcher.fetch(index)  # may raise StopIteration
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/torch/utils/data/_utils/fetch.py", line 35, in fetch
  data.append(next(self.dataset_iter))
              ^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/transformers/pipelines/pt_utils.py", line 188, in __next__
  processed = next(self.subiterator)
              ^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/transformers/pipelines/automatic_speech_recognition.py", line 486, in preprocess
  processed = self.feature_extractor(
              ^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/transformers/models/lasr/feature_extraction_lasr.py", line 266, in __call__
  input_features = self._torch_extract_fbank_features(input_features, device, center)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: LasrFeatureExtractor._torch_extract_fbank_features() takes from 2 to 3 positional arguments but 4 were given

The issue is introduced as a result of this commit: https://github.com/huggingface/transformers/commit/b768d8b157e227c7c84e57014f5183d461556579

Who can help?

No response

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

pipe = pipeline("automatic-speech-recognition", model=model_id)
result = pipe(audio,chunk_length_s=20,stride_length_s=2)

Expected behavior

I would expect to be able to be able to pass in the arguments above into the pipe function signature without error

extent analysis

Fix Plan

Update transformers version

The issue is introduced in transformers version 5.2.0. We can try downgrading to a previous version that does not have this issue.

Update code to match new transformers version

If downgrading is not an option, we need to update the code to match the new version of transformers. The error message indicates that the LasrFeatureExtractor._torch_extract_fbank_features() method now takes 2 to 3 positional arguments, but 4 were given.

Here's an example of how to update the code:

import torch
from transformers import pipeline

# Create a pipeline for ASR
pipe = pipeline("automatic-speech-recognition", model=model_id)

# Update the audio processing code to match the new transformers version
def process_audio(audio):
    # Assuming audio is a tensor
    if len(audio.shape) == 1:  # mono audio
        audio = torch.unsqueeze(audio, 0)  # add batch dimension
    elif len(audio.shape) == 2:  # stereo audio
        pass  # no need to add batch dimension
    else:
        raise ValueError("Invalid audio shape")

    # Process audio using the pipeline
    result = pipe(audio, chunk_length_s=20, stride_length_s=2)
    return result

Verify the fix

To verify that the fix worked, you can run the updated code and check if the error is resolved. You can also add some print statements to verify that the audio is being processed correctly.

print("Audio shape:", audio.shape)
result = process_audio(audio)
print("Result:", result)

Extra Tips

  • Make sure to check the transformers documentation for any changes in the API that may affect your code.
  • If you're using a custom dataset or task, make sure to update your code to match the new transformers version.
  • Consider using a virtual environment to

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

I would expect to be able to be able to pass in the arguments above into the pipe function signature without error

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

transformers - 💡(How to fix) Fix Issue with _torch_extract_fbank_features() [2 comments, 3 participants]