From 0caba222eff7b00bb8df67fb3b4f7373036828a5 Mon Sep 17 00:00:00 2001 From: CarolinePascal Date: Sat, 9 Aug 2025 01:13:30 +0200 Subject: [PATCH] fix(typos): fixing typos and missing imports --- src/lerobot/async_inference/robot_client.py | 1 + src/lerobot/datasets/utils.py | 10 ++++++---- src/lerobot/scripts/lerobot_calibrate.py | 1 + src/lerobot/scripts/lerobot_record.py | 11 ++++++++--- src/lerobot/scripts/lerobot_teleoperate.py | 1 + 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/lerobot/async_inference/robot_client.py b/src/lerobot/async_inference/robot_client.py index f26639dc1..46bd64b25 100644 --- a/src/lerobot/async_inference/robot_client.py +++ b/src/lerobot/async_inference/robot_client.py @@ -47,6 +47,7 @@ import torch from lerobot.cameras.opencv.configuration_opencv import OpenCVCameraConfig # noqa: F401 from lerobot.cameras.realsense.configuration_realsense import RealSenseCameraConfig # noqa: F401 +from lerobot.microphones.portaudio.configuration_portaudio import PortAudioMicrophoneConfig # noqa: F401 from lerobot.processor import RobotAction from lerobot.robots import ( # noqa: F401 Robot, diff --git a/src/lerobot/datasets/utils.py b/src/lerobot/datasets/utils.py index 953a544b7..514f04977 100644 --- a/src/lerobot/datasets/utils.py +++ b/src/lerobot/datasets/utils.py @@ -685,12 +685,12 @@ def hw_to_dataset_features( "names": ["height", "width", "channels"], } - for key, features in mic_fts.items(): + for key, parameters in mic_fts.items(): features[f"{prefix}.audio.{key}"] = { "dtype": "audio", - "shape": (features[1],), + "shape": (len(parameters[1]),), "names": ["channels"], - "info": {"sample_rate": features[0]}, + "info": {"sample_rate": parameters[0]}, } _validate_feature_names(features) @@ -1168,7 +1168,9 @@ def validate_feature_audio(name: str, expected_shape: list[str], value: np.ndarr if isinstance(value, np.ndarray): actual_shape = value.shape c = expected_shape - if len(actual_shape) != 2 or actual_shape[-1] != c[-1]: # The number of frames might be different + if (len(actual_shape) != 2 and len(actual_shape) != 1) or actual_shape[-1] != c[ + -1 + ]: # The number of frames might be different error_message += ( f"The feature '{name}' of shape '{actual_shape}' does not have the expected shape '{c}'.\n" ) diff --git a/src/lerobot/scripts/lerobot_calibrate.py b/src/lerobot/scripts/lerobot_calibrate.py index cbc7684d3..c66fcf3c2 100644 --- a/src/lerobot/scripts/lerobot_calibrate.py +++ b/src/lerobot/scripts/lerobot_calibrate.py @@ -33,6 +33,7 @@ import draccus from lerobot.cameras.opencv.configuration_opencv import OpenCVCameraConfig # noqa: F401 from lerobot.cameras.realsense.configuration_realsense import RealSenseCameraConfig # noqa: F401 +from lerobot.microphones.portaudio.configuration_portaudio import PortAudioMicrophoneConfig # noqa: F401 from lerobot.robots import ( # noqa: F401 Robot, RobotConfig, diff --git a/src/lerobot/scripts/lerobot_record.py b/src/lerobot/scripts/lerobot_record.py index 3e0ea1155..2027e8fcf 100644 --- a/src/lerobot/scripts/lerobot_record.py +++ b/src/lerobot/scripts/lerobot_record.py @@ -91,6 +91,10 @@ from lerobot.datasets.utils import ( combine_feature_dicts, ) from lerobot.datasets.video_utils import VideoEncodingManager +from lerobot.microphones import ( + MicrophoneConfig, # noqa: F401 +) +from lerobot.microphones.portaudio.configuration_portaudio import PortAudioMicrophoneConfig # noqa: F401 from lerobot.microphones.utils import ( async_microphones_start_recording, async_microphones_stop_recording, @@ -344,14 +348,15 @@ def record_loop( if ( dataset is not None and robot.name != "lekiwi" ): # For now, LeKiwi only supports frame audio recording (which may lead to audio chunks loss, extended post-processing, increased memory usage) - for microphone_key, microphone in robot.microphones.items(): - dataset.add_microphone_recording(microphone, microphone_key) + dataset.add_microphones_recordings(robot.microphones) else: async_microphones_start_recording(robot.microphones) # Fill audio buffers if needed if robot.microphones and (policy is not None or dataset is not None): - # This initial wait might be longer than the audio chunk duration to (1) ensure that the audio buffers are filled with enough data and (2) add additional initial samples to the dataset in case of variable audio chubk duration during training. + # This initial wait might be longer than the audio chunk duration to + # (1) ensure that the audio buffers are filled with enough data + # (2) add additional initial samples to the dataset in case of variable audio chunk duration during training busy_wait(DEFAULT_INITIAL_AUDIO_BUFFER_DURATION) for microphone_name, microphone in robot.microphones.items(): diff --git a/src/lerobot/scripts/lerobot_teleoperate.py b/src/lerobot/scripts/lerobot_teleoperate.py index 2115a5fc2..80bebacf3 100644 --- a/src/lerobot/scripts/lerobot_teleoperate.py +++ b/src/lerobot/scripts/lerobot_teleoperate.py @@ -61,6 +61,7 @@ import rerun as rr from lerobot.cameras.opencv.configuration_opencv import OpenCVCameraConfig # noqa: F401 from lerobot.cameras.realsense.configuration_realsense import RealSenseCameraConfig # noqa: F401 from lerobot.configs import parser +from lerobot.microphones.portaudio.configuration_portaudio import PortAudioMicrophoneConfig # noqa: F401 from lerobot.processor import ( RobotAction, RobotObservation,