Skip to content

fix: read wav via soundfile to avoid torchcodec dependency#1887

Open
jasagiri wants to merge 1 commit into
FunAudioLLM:mainfrom
jasagiri:fix/torchaudio-load-compat
Open

fix: read wav via soundfile to avoid torchcodec dependency#1887
jasagiri wants to merge 1 commit into
FunAudioLLM:mainfrom
jasagiri:fix/torchaudio-load-compat

Conversation

@jasagiri
Copy link
Copy Markdown

Summary

load_wav calls torchaudio.load, which since torchaudio 2.8 routes through torchcodec — an optional dependency frequently not installed. On such setups load_wav fails with an ImportError before any inference runs.

This reads the file directly with soundfile and falls back to torchaudio only if that fails.

Test plan

  • load_wav('asset/zero_shot_prompt.wav', 24000) returns a tensor on a torchaudio build without torchcodec

Since torchaudio 2.8, torchaudio.load routes through torchcodec, an
optional dependency that is often not installed. This makes load_wav
fail with an ImportError on otherwise working setups.

Read the file directly with soundfile and fall back to torchaudio
only if that fails.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.

1 participant