#3012 Fix attribute check for torchaudio backend availability in CodecAugme… #3020
+8
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes #3012
Before submitting
PR review
Reviewer checklist
Add
hasattr()checks before callingtorchaudio.list_audio_backends()to maintain compatibility with torchaudio 2.9+, where this function was removed.Changes
hasattr()check in the docstring example before callingtorchaudio.list_audio_backends()hasattr()check in the test code before callingtorchaudio.list_audio_backends()Context
The
torchaudio.list_audio_backends()function was deprecated and removed in torchaudio 2.9. While the main backend checking code inspeechbrain/utils/torch_audio_backend.pywas already fixed in PRs #2988 and #2989, these two additional locations still had unprotected calls that would causeAttributeErrorwith newer torchaudio versions.Testing
torchaudio.list_audio_backends()in the codebase are now protected withhasattr()checks