From 88b3c4d21748379d208d8db3470a4a4940ebd545 Mon Sep 17 00:00:00 2001 From: Pierre Ruyssen Date: Mon, 7 Oct 2024 06:33:42 -0700 Subject: [PATCH] avoid ValueError when checking whether a value exists. PiperOrigin-RevId: 683160443 --- tensorflow_datasets/core/utils/conversion_utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tensorflow_datasets/core/utils/conversion_utils.py b/tensorflow_datasets/core/utils/conversion_utils.py index 5fbceaa8d69..a7e382febe0 100644 --- a/tensorflow_datasets/core/utils/conversion_utils.py +++ b/tensorflow_datasets/core/utils/conversion_utils.py @@ -152,7 +152,8 @@ def to_tfds_value(value: Any, feature: feature_lib.FeatureConnector) -> Any: case _: return [value] case feature_lib.Audio(): - if array := value.get('array'): + array = value.get('array') + if array is not None: # Hugging Face uses floats, TFDS uses integers. return [int(sample * feature.sample_rate) for sample in array] elif (path := value.get('path')) and (path := epath.Path(path)).exists():