Skip to content

Conversation

@seohyunjun
Copy link
Contributor

@seohyunjun seohyunjun commented Jan 10, 2026

What does this PR do?

Fixes #3012

Before submitting
  • Did you read the contributor guideline?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you list all the breaking changes introduced by this pull request?
  • Does your code adhere to project-specific code style and conventions?

PR review

Reviewer checklist
  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified
  • Confirm that the changes adhere to compatibility requirements (e.g., Python version, platform)
  • Review the self-review checklist to ensure the code is ready for review

Add hasattr() checks before calling torchaudio.list_audio_backends() to maintain compatibility with torchaudio 2.9+, where this function was removed.

Changes

  • speechbrain/augment/codec.py: Added hasattr() check in the docstring example before calling torchaudio.list_audio_backends()
  • tests/unittests/test_augment.py: Added hasattr() check in the test code before calling torchaudio.list_audio_backends()

Context

The torchaudio.list_audio_backends() function was deprecated and removed in torchaudio 2.9. While the main backend checking code in speechbrain/utils/torch_audio_backend.py was already fixed in PRs #2988 and #2989, these two additional locations still had unprotected calls that would cause AttributeError with newer torchaudio versions.

Testing

  • Verified that all calls to torchaudio.list_audio_backends() in the codebase are now protected with hasattr() checks
  • No linting or syntax errors in modified files
  • Changes maintain backward compatibility with older torchaudio versions (< 2.9)

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.

AttributeError: module 'torchaudio' has no attribute 'list_audio_backends'

1 participant