Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decode audio from remote #3271

Merged
merged 1 commit into from
Nov 16, 2021
Merged
Changes from all 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
4 changes: 3 additions & 1 deletion src/datasets/features/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import pyarrow as pa

from ..utils.streaming_download_manager import xopen


@dataclass(unsafe_hash=True)
class Audio:
Expand Down Expand Up @@ -48,7 +50,7 @@ def _decode_example_with_librosa(self, value):
except ImportError as err:
raise ImportError("To support decoding audio files, please install 'librosa'.") from err

with open(value, "rb") as f:
with xopen(value, "rb") as f:
array, sampling_rate = librosa.load(f, sr=self.sampling_rate, mono=self.mono)
return array, sampling_rate

Expand Down