mirror of
https://github.com/huggingface/lerobot.git
synced 2026-05-22 20:19:43 +00:00
[skip-ci] style(clean): cleaning up audio benchmark
This commit is contained in:
@@ -15,7 +15,6 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import time
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
@@ -25,11 +24,13 @@ from soundfile import read
|
|||||||
from lerobot.microphones.configs import MicrophoneConfig
|
from lerobot.microphones.configs import MicrophoneConfig
|
||||||
from lerobot.microphones.portaudio import PortAudioMicrophone, PortAudioMicrophoneConfig
|
from lerobot.microphones.portaudio import PortAudioMicrophone, PortAudioMicrophoneConfig
|
||||||
from lerobot.microphones.utils import (
|
from lerobot.microphones.utils import (
|
||||||
async_microphones_read,
|
|
||||||
async_microphones_start_recording,
|
async_microphones_start_recording,
|
||||||
async_microphones_stop_recording,
|
async_microphones_stop_recording,
|
||||||
make_microphones_from_configs,
|
make_microphones_from_configs,
|
||||||
)
|
)
|
||||||
|
from lerobot.utils.robot_utils import (
|
||||||
|
busy_wait,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def main(
|
def main(
|
||||||
@@ -51,6 +52,8 @@ def main(
|
|||||||
|
|
||||||
all_audio_chunks = []
|
all_audio_chunks = []
|
||||||
for i in range(repetitions):
|
for i in range(repetitions):
|
||||||
|
print(f"Repetition {i + 1}/{repetitions}...")
|
||||||
|
|
||||||
# Create audio chunks
|
# Create audio chunks
|
||||||
audio_chunks = {}
|
audio_chunks = {}
|
||||||
for microphone_key in microphones:
|
for microphone_key in microphones:
|
||||||
@@ -62,17 +65,17 @@ def main(
|
|||||||
output_files=[
|
output_files=[
|
||||||
recording_dir / f"{microphone_key}_recording_{i}.wav" for microphone_key in microphones
|
recording_dir / f"{microphone_key}_recording_{i}.wav" for microphone_key in microphones
|
||||||
],
|
],
|
||||||
multiprocessing=True,
|
multiprocessing=multiprocessing,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Record audio chunks
|
# Record audio chunks
|
||||||
for j in range(audio_chunks_number):
|
for j in range(audio_chunks_number):
|
||||||
time.sleep(audio_chunks_duration)
|
busy_wait(audio_chunks_duration)
|
||||||
|
|
||||||
audio_readings = async_microphones_read(microphones)
|
for microphone_key, microphone in microphones.items():
|
||||||
for microphone_index, reading in audio_readings.items():
|
audio_chunk = microphone.read()
|
||||||
print(f"{microphone_index} - repetition {i} - chunk {j} - samples {reading.shape[0]}")
|
print(f"{microphone_key} - repetition {i} - chunk {j} - samples {audio_chunk.shape[0]}")
|
||||||
audio_chunks[microphone_index].append(reading)
|
audio_chunks[microphone_key].append(audio_chunk)
|
||||||
|
|
||||||
# Stop recording
|
# Stop recording
|
||||||
async_microphones_stop_recording(microphones)
|
async_microphones_stop_recording(microphones)
|
||||||
|
|||||||
Reference in New Issue
Block a user