Skip to content
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

Whisper: fix asr pipeline with seq2seq assistant model #30726

Closed
wants to merge 4 commits into from
Closed
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
7 changes: 1 addition & 6 deletions src/transformers/pipelines/automatic_speech_recognition.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,6 @@ def _forward(self, model_inputs, return_timestamps=False, **generate_kwargs):
raise ValueError("segment_size must be used only when stride is None")

if self.type in {"seq2seq", "seq2seq_whisper"}:
encoder = self.model.get_encoder()
# Consume values so we can let extra information flow freely through
# the pipeline (important for `partial` in microphone)
if "input_features" in model_inputs:
Expand Down Expand Up @@ -500,12 +499,8 @@ def _forward(self, model_inputs, return_timestamps=False, **generate_kwargs):
else:
generate_kwargs["num_frames"] = segment_size[0] // self.feature_extractor.hop_length

if self.type == "seq2seq_whisper" and inputs.shape[-1] > self.feature_extractor.nb_max_frames:
generate_kwargs["input_features"] = inputs
else:
generate_kwargs["encoder_outputs"] = encoder(inputs, attention_mask=attention_mask)

tokens = self.model.generate(
inputs,
attention_mask=attention_mask,
**generate_kwargs,
)
Expand Down
Loading