Skip to content

Commit 9dfa288

Browse files
authored
fix audio cast storage from array + sampling_rate (#7684)
1 parent 8a4384d commit 9dfa288

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/datasets/features/audio.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,9 @@ def cast_storage(self, storage: Union[pa.StringArray, pa.StructArray]) -> pa.Str
236236
path_array = pa.array([None] * len(storage), type=pa.string())
237237
storage = pa.StructArray.from_arrays([storage, path_array], ["bytes", "path"], mask=storage.is_null())
238238
elif pa.types.is_struct(storage.type) and storage.type.get_all_field_indices("array"):
239-
storage = pa.array([Audio().encode_example(x) if x is not None else None for x in storage.to_pylist()])
239+
storage = pa.array(
240+
[Audio().encode_example(x) if x is not None else None for x in storage.to_numpy(zero_copy_only=False)]
241+
)
240242
elif pa.types.is_struct(storage.type):
241243
if storage.type.get_field_index("bytes") >= 0:
242244
bytes_array = storage.field("bytes")

0 commit comments

Comments
 (0)