diff --git a/src/transformers/pipelines/__init__.py b/src/transformers/pipelines/__init__.py index 34d6222d7165..3167c91fd720 100755 --- a/src/transformers/pipelines/__init__.py +++ b/src/transformers/pipelines/__init__.py @@ -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") and isinstance(model_name, str) ): try: diff --git a/src/transformers/pipelines/automatic_speech_recognition.py b/src/transformers/pipelines/automatic_speech_recognition.py index 8e6f8b5cafcd..98fb8255d3bf 100644 --- a/src/transformers/pipelines/automatic_speech_recognition.py +++ b/src/transformers/pipelines/automatic_speech_recognition.py @@ -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: