Skip to content

Conversation

@CloseChoice
Copy link
Contributor

Fixes #7837

We currently have the mono attribute for Audio documented but not used anywhere resulting in confusion for users. Since torchcodec does not know this attribute I suggest using num_channels (currently supported None (leave unchanged), mono: 1, stereo: 2).

I could also add a mono attribute but found that to be more confusing for developers and would restrict us if at any point in the future more than 2 channels are supported.

samples = audio.get_all_samples()
buffer = BytesIO()
AudioEncoder(samples.data.cpu(), sample_rate=samples.sample_rate).to_file_like(buffer, format="wav")
num_channels = samples.data.shape[0]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This isn't strictly necessary but added it to be explicit

@CloseChoice CloseChoice marked this pull request as ready for review November 2, 2025 12:14
Copy link
Member

@lhoestq lhoestq left a comment

Choose a reason for hiding this comment

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

lgtm !

@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.

@lhoestq lhoestq merged commit 0e7c6ca into huggingface:main Nov 3, 2025
7 of 14 checks passed
@CloseChoice CloseChoice deleted the add-num-channels-to-audio branch November 3, 2025 17:37
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.

mono parameter to the Audio feature is missing

3 participants