Skip to content

Conversation

gante
Copy link
Member

@gante gante commented Aug 22, 2025

What does this PR do?

Related to #25084

Makes the ASR pipeline behave as other text-generating pipelines: kwargs at call time are forwared to generate, as opposed to needing a special keyword.


from transformers import pipeline
from datasets import load_dataset

model = "openai/whisper-tiny"
asr = pipeline("automatic-speech-recognition", model=model)
dataset = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation[:1]")

# BC: with `generate_kwargs` as a dictionary
res = asr(
    dataset[0]["audio"],
    generate_kwargs={"task": "transcribe", "max_new_tokens": 256},
    chunk_length_s=30,
    batch_size=8,
)
print(res)

# New: kwargs forwarded to `generate`
res = asr(
    dataset[0]["audio"],
    max_new_tokens=256,
    task="transcribe",
    chunk_length_s=30,
    batch_size=8,
)
print(res)

@gante gante requested a review from ArthurZucker August 22, 2025 14:18
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@gante gante requested review from Cyrilvallez and removed request for ArthurZucker September 3, 2025 10:30
Copy link
Member

@Cyrilvallez Cyrilvallez left a comment

Choose a reason for hiding this comment

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

Woww, fixing 2023 bugs 😆🤗! Thanks a lot!

Copy link
Contributor

github-actions bot commented Sep 9, 2025

[For maintainers] Suggested jobs to run (before merge)

run-slow: whisper

@gante
Copy link
Member Author

gante commented Sep 9, 2025

Woww, fixing 2023 bugs

@Cyrilvallez perks of operating in a LIFO notification queue :D (was pinged recently)

@gante gante enabled auto-merge (squash) September 9, 2025 17:24
@gante gante merged commit 37c1443 into huggingface:main Sep 9, 2025
24 checks passed
vijayabhaskar-ev pushed a commit to vijayabhaskar-ev/transformers that referenced this pull request Oct 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants