Skip to content

Fix torchaudio.load() Path compatibility issue#97

Open
Mr-Neutr0n wants to merge 1 commit intofacebookresearch:mainfrom
Mr-Neutr0n:fix-torchaudio-path-compat
Open

Fix torchaudio.load() Path compatibility issue#97
Mr-Neutr0n wants to merge 1 commit intofacebookresearch:mainfrom
Mr-Neutr0n:fix-torchaudio-path-compat

Conversation

@Mr-Neutr0n
Copy link

Summary

  • Convert Path object to string before passing to torchaudio.load() for backend compatibility

Problem

When running the encodec CLI:

encodec -b 6.0 input.wav output.wav

The command fails with:

RuntimeError: torchaudio_sox::load_audio_file() Expected a value of type 'str' 
for argument '0' but instead found type 'PosixPath'.

This occurs because args.input is a pathlib.Path object, but some torchaudio backends (like sox) require a string path.

Solution

Convert the Path to string using str(args.input) before passing to torchaudio.load().

This is consistent with how save_audio() in utils.py already handles path conversion.

Test plan

  • Run encodec -b 6.0 input.wav output.ecdc on a test audio file
  • Verify encoding completes without path type errors

Fixes #92

Convert Path object to string before passing to torchaudio.load()
to fix compatibility with torchaudio backends that expect string paths.

Fixes RuntimeError: "Expected a value of type 'str' for argument '0'
but instead found type 'PosixPath'"

Fixes facebookresearch#92
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 6, 2026
@Mr-Neutr0n
Copy link
Author

hey, just checking in on this one. it fixes a Path compatibility issue with torchaudio.load(). pretty small change, happy to adjust anything

@Mr-Neutr0n
Copy link
Author

Friendly bump! Let me know if there's anything I should update or improve to help move this forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Proposed with solutions] Fix torchaudio path compatibility issue

1 participant