Skip to content

Fix audio pipeline with torchcodec input#39309

Open
lhoestq wants to merge 1 commit into
mainfrom
fix-audio-pipeline-with-torchcodec-input
Open

Fix audio pipeline with torchcodec input#39309
lhoestq wants to merge 1 commit into
mainfrom
fix-audio-pipeline-with-torchcodec-input

Conversation

@lhoestq

@lhoestq lhoestq commented Jul 9, 2025

Copy link
Copy Markdown
Member

fix tests/pipelines/test_pipelines_automatic_speech_recognition.py::AutomaticSpeechRecognitionPipelineTests::test_speculative_decoding_whisper_distil

which has

ValueError: When passing a dictionary to AutomaticSpeechRecognitionPipeline, the dict needs to contain a "raw" key containing the numpy array or torch tensor representing the audio and a "sampling_rate" key, containing the sampling_rate associated with that array

@lhoestq lhoestq requested review from eustlb and ydshieh July 9, 2025 13:56
if not isinstance(inputs, np.ndarray):
raise TypeError(f"We expect a numpy ndarray or torch tensor as input, got `{type(inputs)}`")
if len(inputs.shape) != 1:
raise ValueError("We expect a single channel audio input for AutomaticSpeechRecognitionPipeline")

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.

cc @eustlb fyi, I simply forgot to remove this check in #39156 that you suggested

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ohoho, ok

@ydshieh ydshieh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Great, thanks!

Comment on lines -229 to -230
if len(inputs.shape) != 1:
raise ValueError("We expect a single channel audio input for AudioClassificationPipeline")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

do you know why we remove this in this PR?

@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

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.

@ydshieh

ydshieh commented Aug 1, 2025

Copy link
Copy Markdown
Collaborator

cc @eustlb when you get the bandwidth to check this one

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