mirror of
https://github.com/huggingface/lerobot.git
synced 2026-07-23 09:46:00 +00:00
[skip-ci] fix(online audio chunks): adding missing observation copy when adding audio buffer
This commit is contained in:
@@ -64,6 +64,7 @@ lerobot-record \
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
from copy import copy
|
||||||
from dataclasses import asdict, dataclass, field
|
from dataclasses import asdict, dataclass, field
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from pprint import pformat
|
from pprint import pformat
|
||||||
@@ -361,16 +362,17 @@ def record_loop(
|
|||||||
# Get action from either policy or teleop
|
# Get action from either policy or teleop
|
||||||
if policy is not None and preprocessor is not None and postprocessor is not None:
|
if policy is not None and preprocessor is not None and postprocessor is not None:
|
||||||
# Transform instantaneous audio samples into a buffer of fixed size
|
# Transform instantaneous audio samples into a buffer of fixed size
|
||||||
|
buffered_observation_frame = copy(observation_frame)
|
||||||
for name in audio_buffer:
|
for name in audio_buffer:
|
||||||
# Remove as many old audio samples as needed
|
# Remove as many old audio samples as needed
|
||||||
audio_buffer[name] = audio_buffer[name][len(observation_frame[name]) :]
|
audio_buffer[name] = audio_buffer[name][len(buffered_observation_frame[name]) :]
|
||||||
# Add new audio samples
|
# Add new audio samples
|
||||||
audio_buffer[name] = np.vstack((audio_buffer[name], observation_frame[name]))
|
audio_buffer[name] = np.vstack((audio_buffer[name], buffered_observation_frame[name]))
|
||||||
# Add the audio buffer to the observation
|
# Add the audio buffer to the observation
|
||||||
observation_frame[name] = audio_buffer[name]
|
buffered_observation_frame[name] = audio_buffer[name]
|
||||||
|
|
||||||
action_values = predict_action(
|
action_values = predict_action(
|
||||||
observation=observation_frame,
|
observation=buffered_observation_frame,
|
||||||
policy=policy,
|
policy=policy,
|
||||||
device=get_safe_torch_device(policy.config.device),
|
device=get_safe_torch_device(policy.config.device),
|
||||||
preprocessor=preprocessor,
|
preprocessor=preprocessor,
|
||||||
|
|||||||
Reference in New Issue
Block a user