Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/transformers/pipelines/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -989,9 +989,10 @@ def pipeline(
feature_extractor, _from_pipeline=task, **hub_kwargs, **model_kwargs
)

feature_extractor_type = feature_extractor.to_dict().get("feature_extractor_type", None)
if (
feature_extractor._processor_class
and feature_extractor._processor_class.endswith("WithLM")
feature_extractor_type
and feature_extractor_type.endswith("WithLM")
Comment on lines +992 to +995
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the feature extractor is a simple Wav2Vec2FeatureExtractor so this might not work. I found only one processor with LM in hte codebase tbh

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that was my question too, I wasn't sure how many cases would be impacted. Closing this in favor of yours then.

and isinstance(model_name, str)
):
try:
Expand Down
8 changes: 3 additions & 5 deletions src/transformers/pipelines/automatic_speech_recognition.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,16 +193,14 @@ def __init__(
device: Union[int, "torch.device"] | None = None,
**kwargs,
):
feature_extractor_type = feature_extractor.to_dict().get("feature_extractor_type", None)

# set the model type so we can check we have the right pre- and post-processing parameters
if model.config.model_type == "whisper":
self.type = "seq2seq_whisper"
elif model.__class__.__name__ in MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES.values():
self.type = "seq2seq"
elif (
feature_extractor._processor_class
and feature_extractor._processor_class.endswith("WithLM")
and decoder is not None
):
elif feature_extractor_type and feature_extractor_type.endswith("WithLM") and decoder is not None:
self.decoder = decoder
self.type = "ctc_with_lm"
else:
Expand Down