diff --git a/src/datasets/features/audio.py b/src/datasets/features/audio.py index b53dd2d2663..69ab8625596 100644 --- a/src/datasets/features/audio.py +++ b/src/datasets/features/audio.py @@ -295,16 +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. On Google Colab you can run:\n\n" + "\t!add-apt-repository -y ppa:jonathonf/ffmpeg-4 && apt update && apt install -y ffmpeg\n\n" + "and restart your runtime. Alternatively, you can downgrade `torchaudio`:\n\n" + "\tpip install \"torchaudio<0.12\"`.\n\nOtherwise '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`: " - "`pip install librosa`. Note that decoding will be extremely slow in that case." + "To support 'mp3' decoding with `torchaudio>=0.12.0`, please install `ffmpeg4` system package. On Google Colab you can run:\n\n" + "\t!add-apt-repository -y ppa:jonathonf/ffmpeg-4 && apt update && apt install -y ffmpeg\n\n" + "and restart your runtime. Alternatively, you can downgrade `torchaudio`:\n\n" + "\tpip install \"torchaudio<0.12\"`.\n\nOtherwise 'mp3' files will be decoded with `librosa`:\n\n" + "\tpip install librosa\n\nNote that decoding will be extremely slow in that case." ) from err # try to decode with librosa for torchaudio>=0.12.0 as a workaround warnings.warn("Decoding mp3 with `librosa` instead of `torchaudio`, decoding is slow.")