-
Notifications
You must be signed in to change notification settings - Fork 2
Workaround: SpeechBrain torchaudio.info() removed in torchaudio 2.9.x #39
Copy link
Copy link
Open
Description
Summary
SpeechBrain's dataio.py uses torchaudio.info() and torchaudio.backend.common.AudioMetaData which were removed in torchaudio 2.9.x. This causes import errors and runtime failures when processing audio files.
Error
AttributeError: module 'torchaudio' has no attribute 'info'Or:
ModuleNotFoundError: No module named 'torchaudio.backend.common'Root Cause
- torchaudio 2.9.x removed
torchaudio.info()function - torchaudio 2.9.x removed
torchaudio.backend.common.AudioMetaDataclass - SpeechBrain uses these to get audio file metadata in
read_audio_info()
Affected Versions
- torchaudio >= 2.9.0
- SpeechBrain (current versions as of Jan 2026)
Workaround
The install script (Step 10b) patches speechbrain/dataio/dataio.py:
- Adds
AudioMetaDataCompatclass to replace the removedAudioMetaData - Replaces
read_audio_info()to usetorchaudio.load()for metadata extraction:
class AudioMetaDataCompat:
"""Compatibility class replacing torchaudio.backend.common.AudioMetaData."""
def __init__(self, sample_rate, num_frames, num_channels, bits_per_sample=16, encoding="PCM_S"):
self.sample_rate = sample_rate
self.num_frames = num_frames
self.num_channels = num_channels
self.bits_per_sample = bits_per_sample
self.encoding = encoding
def read_audio_info(path, backend=None) -> AudioMetaDataCompat:
if hasattr(torchaudio, 'info'):
# Old torchaudio version - use original approach
...
else:
# torchaudio 2.9.x: info() removed, use load() to get metadata
channels_data, sample_rate = torchaudio.load(path, normalize=False)
return AudioMetaDataCompat(
sample_rate=sample_rate,
num_frames=channels_data.size(1),
num_channels=channels_data.size(0),
)Resolution
This workaround can be removed once SpeechBrain releases a version compatible with torchaudio 2.9.x.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels