chore(busy_wait): renaming busy_wait into precise_sleep

This commit is contained in:
CarolinePascal
2025-12-25 18:36:39 +01:00
parent 3399513e5e
commit 5cd3572713
7 changed files with 17 additions and 17 deletions
+2 -2
View File
@@ -29,7 +29,7 @@ from lerobot.microphones.utils import (
make_microphones_from_configs,
)
from lerobot.utils.robot_utils import (
busy_wait,
precise_sleep,
)
@@ -70,7 +70,7 @@ def main(
# Record audio chunks
for j in range(audio_chunks_number):
busy_wait(audio_chunks_duration)
precise_sleep(audio_chunks_duration)
for microphone_key, microphone in microphones.items():
audio_chunk = microphone.read()
+2 -2
View File
@@ -28,7 +28,7 @@ from lerobot.microphones.utils import (
make_microphones_from_configs,
)
from lerobot.utils.robot_utils import (
busy_wait,
precise_sleep,
)
@@ -59,7 +59,7 @@ def main(
)
# Record audio chunks
busy_wait(10.0)
precise_sleep(10.0)
for sensor_key, sensor in sensors.items():
data_chunk = sensor.read()
@@ -21,7 +21,7 @@ from typing import Any
import numpy as np
from sounddevice import PortAudioError
from lerobot.utils.robot_utils import busy_wait
from lerobot.utils.robot_utils import precise_sleep
# --- Interface definitions for InputStream ---
@@ -335,7 +335,7 @@ class FakeSounddeviceSDKAdapter(ISounddeviceSDK):
def _streaming_loop(self):
if self.callback is not None:
while not self._streaming_thread_stop_event.is_set():
busy_wait(self.latency)
precise_sleep(self.latency)
tmp_data = self._simulated_audio_data()
self.callback(
tmp_data,
@@ -268,7 +268,7 @@ class PortAudioMicrophone(Microphone):
self.audio_callback_start_event.clear()
# Create and start an audio input stream with a recording callback
# Remark: this is done in a separate process so that audio recording is not impacted by the main thread CPU usage, especially the busy_wait function.
# Remark: this is done in a separate process so that audio recording is not impacted by the main thread CPU usage, especially the precise_sleep function.
process_init_event = process_Event()
self.record_process = Process(
target=self._record_process,
@@ -171,7 +171,7 @@ class TouchLabSensor(Microphone):
self.audio_callback_start_event.clear()
# Create and start an audio input stream with a recording callback
# Remark: this is done in a separate process so that audio recording is not impacted by the main thread CPU usage, especially the busy_wait function.
# Remark: this is done in a separate process so that audio recording is not impacted by the main thread CPU usage, especially the precise_sleep function.
process_init_event = process_Event()
self.record_process = Process(
target=self._record_process,
+1 -1
View File
@@ -363,7 +363,7 @@ def record_loop(
# 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)
precise_sleep(DEFAULT_INITIAL_AUDIO_BUFFER_DURATION)
for microphone_name, microphone in robot.microphones.items():
audio_chunk = microphone.read()
audio_buffer[microphone_name] = rolling_vstack(audio_buffer[microphone_name], audio_chunk)
+8 -8
View File
@@ -33,7 +33,7 @@ from lerobot.utils.errors import (
DeviceNotConnectedError,
DeviceNotRecordingError,
)
from lerobot.utils.robot_utils import busy_wait
from lerobot.utils.robot_utils import precise_sleep
MODULE_PATH = "lerobot.microphones.portaudio.microphone_portaudio"
RECORDING_DURATION = 1.0
@@ -302,7 +302,7 @@ def test_stop_recording_success(default_config, test_sdk, multiprocessing):
microphone = PortAudioMicrophone(default_config, sounddevice_sdk=test_sdk)
microphone.connect()
microphone.start_recording(multiprocessing=multiprocessing)
busy_wait(RECORDING_DURATION)
precise_sleep(RECORDING_DURATION)
microphone.stop_recording()
assert not microphone.is_recording
@@ -316,7 +316,7 @@ def test_stop_writing_success(tmp_path, default_config, test_sdk, multiprocessin
microphone = PortAudioMicrophone(default_config, sounddevice_sdk=test_sdk)
microphone.connect()
microphone.start_recording(output_file=tmp_path / "test.wav", multiprocessing=multiprocessing)
busy_wait(RECORDING_DURATION)
precise_sleep(RECORDING_DURATION)
microphone.stop_recording()
assert not microphone.is_recording
@@ -348,7 +348,7 @@ def test_disconnect_while_recording(default_config, test_sdk, multiprocessing):
microphone = PortAudioMicrophone(default_config, sounddevice_sdk=test_sdk)
microphone.connect()
microphone.start_recording(multiprocessing=multiprocessing)
busy_wait(RECORDING_DURATION)
precise_sleep(RECORDING_DURATION)
microphone.disconnect()
assert not microphone.is_connected
@@ -362,7 +362,7 @@ def test_disconnect_while_writing(tmp_path, default_config, test_sdk, multiproce
microphone = PortAudioMicrophone(default_config, sounddevice_sdk=test_sdk)
microphone.connect()
microphone.start_recording(output_file=tmp_path / "test.wav", multiprocessing=multiprocessing)
busy_wait(RECORDING_DURATION)
precise_sleep(RECORDING_DURATION)
microphone.disconnect()
assert not microphone.is_connected
@@ -378,7 +378,7 @@ def test_read_success(default_config, test_sdk, multiprocessing):
microphone.connect()
microphone.start_recording(multiprocessing=multiprocessing)
busy_wait(RECORDING_DURATION)
precise_sleep(RECORDING_DURATION)
data = microphone.read()
@@ -398,7 +398,7 @@ def test_writing_success(tmp_path, default_config, test_sdk, multiprocessing):
microphone.connect()
microphone.start_recording(output_file=tmp_path / "test.wav", multiprocessing=multiprocessing)
busy_wait(RECORDING_DURATION)
precise_sleep(RECORDING_DURATION)
microphone.stop_recording()
@@ -420,7 +420,7 @@ def test_read_while_writing(tmp_path, default_config, test_sdk, multiprocessing)
microphone.connect()
microphone.start_recording(output_file=tmp_path / "test.wav", multiprocessing=multiprocessing)
busy_wait(RECORDING_DURATION)
precise_sleep(RECORDING_DURATION)
read_data = microphone.read()
microphone.stop_recording()