From 62223ca41c46264e8a710087ef7a067f13541aee Mon Sep 17 00:00:00 2001 From: Harshal Janjani Date: Wed, 1 Jul 2026 05:55:11 +0000 Subject: [PATCH] feat: Rename audio_processor to feature_extractor with BC alias --- .../granite_speech/processing_granite_speech.py | 13 ++++++++++--- .../phi4_multimodal/processing_phi4_multimodal.py | 13 ++++++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/transformers/models/granite_speech/processing_granite_speech.py b/src/transformers/models/granite_speech/processing_granite_speech.py index 969ebc1c3596..a82d5d3e4b37 100644 --- a/src/transformers/models/granite_speech/processing_granite_speech.py +++ b/src/transformers/models/granite_speech/processing_granite_speech.py @@ -19,6 +19,7 @@ from ...processing_utils import ProcessorMixin from ...tokenization_python import PreTokenizedInput, TextInput from ...utils import auto_docstring, is_torch_available, logging +from ...utils.deprecation import deprecate_kwarg from ...utils.import_utils import requires_backends @@ -30,9 +31,10 @@ @auto_docstring class GraniteSpeechProcessor(ProcessorMixin): + @deprecate_kwarg("audio_processor", new_name="feature_extractor", version="v5.20") def __init__( self, - audio_processor, + feature_extractor, tokenizer, audio_token="<|audio|>", chat_template=None, @@ -44,7 +46,12 @@ def __init__( audio tokens inserted depends on the audio feature dimensions extracted by the audio processor. """ self.audio_token = tokenizer.audio_token if hasattr(tokenizer, "audio_token") else audio_token - super().__init__(audio_processor, tokenizer, chat_template=chat_template) + super().__init__(feature_extractor, tokenizer, chat_template=chat_template) + + @property + def audio_processor(self): + logger.warning_once("`audio_processor` is deprecated! Use `feature_extractor` instead!") + return self.feature_extractor @auto_docstring def __call__( @@ -64,7 +71,7 @@ def __call__( # text / audio inputs here because some inference engines will # trigger the conditions due to the way they call multimodal # processors, e.g., vLLM. - audio_inputs = self.audio_processor(audio, device=device) + audio_inputs = self.feature_extractor(audio, device=device) # TODO (@alex-jw-brooks); we should add a util to get_num_audio_tokens # from feature lengths and call it here, rather than returning it diff --git a/src/transformers/models/phi4_multimodal/processing_phi4_multimodal.py b/src/transformers/models/phi4_multimodal/processing_phi4_multimodal.py index 325b27ed361c..3db3a3578b3b 100644 --- a/src/transformers/models/phi4_multimodal/processing_phi4_multimodal.py +++ b/src/transformers/models/phi4_multimodal/processing_phi4_multimodal.py @@ -24,6 +24,7 @@ from ...processing_utils import ProcessingKwargs, ProcessorMixin, Unpack from ...tokenization_utils_base import TextInput from ...utils import auto_docstring, logging +from ...utils.deprecation import deprecate_kwarg logger = logging.get_logger(__name__) @@ -39,10 +40,11 @@ class Phi4MultimodalProcessorKwargs(ProcessingKwargs, total=False): @auto_docstring class Phi4MultimodalProcessor(ProcessorMixin): + @deprecate_kwarg("audio_processor", new_name="feature_extractor", version="v5.20") def __init__( self, image_processor, - audio_processor, + feature_extractor, tokenizer, **kwargs, ): @@ -50,7 +52,12 @@ def __init__( self.image_token_id = tokenizer.image_token_id self.audio_token = tokenizer.audio_token self.audio_token_id = tokenizer.audio_token_id - super().__init__(image_processor, audio_processor, tokenizer, **kwargs) + super().__init__(image_processor, feature_extractor, tokenizer, **kwargs) + + @property + def audio_processor(self): + logger.warning_once("`audio_processor` is deprecated! Use `feature_extractor` instead!") + return self.feature_extractor @auto_docstring def __call__( @@ -78,7 +85,7 @@ def __call__( audio_kwargs = output_kwargs["audio_kwargs"] image_inputs = self.image_processor(images, **image_kwargs) if images is not None else {} - audio_inputs = self.audio_processor(audio, **audio_kwargs) if audio is not None else {} + audio_inputs = self.feature_extractor(audio, **audio_kwargs) if audio is not None else {} # We pop here for images as we don't need it later num_img_tokens = image_inputs.pop("num_img_tokens", [])