Skip to content
Merged
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/datasets/features/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,15 +295,22 @@ def _decode_mp3(self, path_or_file):
try: # try torchaudio anyway because sometimes it works (depending on the os and os packages installed)
array, sampling_rate = self._decode_mp3_torchaudio(path_or_file)
except RuntimeError:
warnings.warn(
"\nTo support 'mp3' decoding with `torchaudio>=0.12.0`, please install `ffmpeg4` system package: "
"`add-apt-repository -y ppa:jonathonf/ffmpeg-4 && apt update && apt install -y ffmpeg` "
"and restart your runtime. Alternatively, you can downgrade `torchaudio`: "
"`pip install \"torchaudio<0.12\"`. Otherwise 'mp3' files will be decoded with `librosa`."
)
try:
# flake8: noqa
import librosa
except ImportError as err:
raise ImportError(
"Your version of `torchaudio` (>=0.12.0) doesn't support decoding 'mp3' files on your machine. "
"To support 'mp3' decoding with `torchaudio>=0.12.0`, please install `ffmpeg>=4` system package "
'or downgrade `torchaudio` to <0.12: `pip install "torchaudio<0.12"`. '
"To support decoding 'mp3' audio files without `torchaudio`, please install `librosa`: "
"To support 'mp3' decoding with `torchaudio>=0.12.0`, please install `ffmpeg4` system package: "
"`add-apt-repository -y ppa:jonathonf/ffmpeg-4 && apt update && apt install -y ffmpeg`, "
"and restart your runtime. Alternatively, you can downgrade `torchaudio`: "
'`pip install "torchaudio<0.12"`. '
"To support decoding of 'mp3' audio files without `torchaudio`, please install `librosa`: "
"`pip install librosa`. Note that decoding will be extremely slow in that case."
) from err
# try to decode with librosa for torchaudio>=0.12.0 as a workaround
Expand Down