From e743f846a79c0789c3acfa33eb745dbbd542154c Mon Sep 17 00:00:00 2001 From: CarolinePascal Date: Mon, 7 Apr 2025 19:08:53 +0200 Subject: [PATCH] Adding dtype="audio" by default in microphone features --- lerobot/common/datasets/utils.py | 8 +------- lerobot/common/robot_devices/robots/manipulator.py | 5 +++-- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/lerobot/common/datasets/utils.py b/lerobot/common/datasets/utils.py index a7bda7f2..80143939 100644 --- a/lerobot/common/datasets/utils.py +++ b/lerobot/common/datasets/utils.py @@ -403,13 +403,7 @@ def get_features_from_robot(robot: Robot, use_videos: bool = True) -> dict: key: {"dtype": "video" if use_videos else "image", **ft} for key, ft in robot.camera_features.items() } - microphones_ft = {} - if robot.microphones: - microphones_ft = { - key: {"dtype": "audio", **ft} - for key, ft in robot.microphones_features.items() - } - return {**robot.motor_features, **camera_ft, **microphones_ft, **DEFAULT_FEATURES} + return {**robot.motor_features, **camera_ft, **robot.microphone_features, **DEFAULT_FEATURES} def dataset_to_policy_features(features: dict[str, dict]) -> dict[str, PolicyFeature]: diff --git a/lerobot/common/robot_devices/robots/manipulator.py b/lerobot/common/robot_devices/robots/manipulator.py index 7e849914..16edc4fb 100644 --- a/lerobot/common/robot_devices/robots/manipulator.py +++ b/lerobot/common/robot_devices/robots/manipulator.py @@ -203,11 +203,12 @@ class ManipulatorRobot: } @property - def microphones_features(self) -> dict: + def microphone_features(self) -> dict: mic_ft = {} for mic_key, mic in self.microphones.items(): key = f"observation.audio.{mic_key}" mic_ft[key] = { + "dtype": "audio", "shape": (len(mic.channels),), "names": "channels", "info" : None, @@ -216,7 +217,7 @@ class ManipulatorRobot: @property def features(self): - return {**self.motor_features, **self.camera_features, **self.microphones_features} + return {**self.motor_features, **self.camera_features, **self.microphone_features} @property def has_camera(self):