mirror of
https://github.com/huggingface/lerobot.git
synced 2026-05-21 19:49:49 +00:00
fix(audio feature shape): fixing audio feature shape ordering (frames first, channels second)
This commit is contained in:
@@ -1143,11 +1143,9 @@ def validate_feature_audio(name: str, expected_shape: list[str], value: np.ndarr
|
|||||||
if isinstance(value, np.ndarray):
|
if isinstance(value, np.ndarray):
|
||||||
actual_shape = value.shape
|
actual_shape = value.shape
|
||||||
c = expected_shape
|
c = expected_shape
|
||||||
if len(actual_shape) != 2 or (
|
if len(actual_shape) != 2 or actual_shape[-1] != c[-1]: # The number of frames might be different
|
||||||
actual_shape[-1] != c[-1] and actual_shape[0] != c[0]
|
|
||||||
): # The number of frames might be different
|
|
||||||
error_message += (
|
error_message += (
|
||||||
f"The feature '{name}' of shape '{actual_shape}' does not have the expected shape '{(c,)}'.\n"
|
f"The feature '{name}' of shape '{actual_shape}' does not have the expected shape '{c}'.\n"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
error_message += f"The feature '{name}' is expected to be of type 'np.ndarray', but type '{type(value)}' provided instead.\n"
|
error_message += f"The feature '{name}' is expected to be of type 'np.ndarray', but type '{type(value)}' provided instead.\n"
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ def audio_dataset(tmp_path, empty_lerobot_dataset_factory):
|
|||||||
features = {
|
features = {
|
||||||
"audio": {
|
"audio": {
|
||||||
"dtype": "audio",
|
"dtype": "audio",
|
||||||
"shape": (DUMMY_AUDIO_CHANNELS,),
|
"shape": (1, DUMMY_AUDIO_CHANNELS),
|
||||||
"names": [
|
"names": [
|
||||||
"channels",
|
"channels",
|
||||||
],
|
],
|
||||||
|
|||||||
Vendored
+2
-2
@@ -41,8 +41,8 @@ DUMMY_VIDEO_INFO = {
|
|||||||
"has_audio": False,
|
"has_audio": False,
|
||||||
}
|
}
|
||||||
DUMMY_MICROPHONE_FEATURES = {
|
DUMMY_MICROPHONE_FEATURES = {
|
||||||
"laptop": {"dtype": "audio", "shape": (1,), "names": ["channels"], "info": None},
|
"laptop": {"dtype": "audio", "shape": (1, 2), "names": ["channels"], "info": None},
|
||||||
"phone": {"dtype": "audio", "shape": (1,), "names": ["channels"], "info": None},
|
"phone": {"dtype": "audio", "shape": (1, 2), "names": ["channels"], "info": None},
|
||||||
}
|
}
|
||||||
DEFAULT_SAMPLE_RATE = 48000
|
DEFAULT_SAMPLE_RATE = 48000
|
||||||
DUMMY_AUDIO_CHANNELS = 2
|
DUMMY_AUDIO_CHANNELS = 2
|
||||||
|
|||||||
Reference in New Issue
Block a user