Skip to content

[Proposed with solutions] Fix torchaudio path compatibility issue #92

Description

@larry-ziyue-yin

Hi Encodec Team,

I am here to propose an issue with my solution.

Bug Description

The encodec command-line tool fails when trying to load audio files due to a type compatibility issue between pathlib.Path objects and torchaudio.load().

Error Message:

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

Steps to Reproduce

  1. Install encodec: pip install encodec
  2. Run: encodec -b 6.0 input.wav output.wav
  3. Error occurs at line 109 in encodec/__main__.py

Expected Behavior

The command should successfully compress/decompress audio files.

Actual Behavior

The command fails with a type casting error.

Environment

  • Python 3.8
  • torchaudio (latest)
  • encodec (latest)

Proposed Solution

Convert Path object to string before passing to torchaudio.load():

Change from:

wav, sr = torchaudio.load(args.input)

To:

wav, sr = torchaudio.load(str(args.input))

I hope this helps, and please feel free to discuss further! :)

Best,
Ziyue

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions