reachy_mini_danceml / tests /verify_fix.py
Boopster's picture
feat: Implement voice-controlled movement generation for Reachy Mini with real-time audio processing, new tests, and documentation.
c8edd3d
import sys
import os
import time
import numpy as np
# Ensure we can import the module
sys.path.append(os.getcwd())
from reachy_mini_danceml.audio_capture import LocalAudioCapture
def verify_fix():
print("Testing Audio Capture with 'Reachy Mini Audio'...")
# Initialize with the specific device name
capture = LocalAudioCapture(device_name="Reachy Mini Audio")
# Check if the device index resulted in a valid index (not None)
# The class prints "Selected audio device..." or "Warning..."
# We can inspect the internal property
if capture._device_index is None:
print("❌ Verification Failed: Device 'Reachy Mini Audio' not found.")
return
print(f"βœ… Device found! Index: {capture._device_index}")
capture.start()
time.sleep(1) # Let it warm up
print("Capturing 2 seconds of audio...")
chunks = []
start_time = time.time()
while time.time() - start_time < 2:
chunk = capture.get_chunk()
if chunk:
chunks.append(chunk)
capture.stop()
total_chunks = len(chunks)
print(f"Total chunks captured: {total_chunks}")
if total_chunks == 0:
print("❌ Verification Failed: No audio chunks captured.")
return
# Concatenate all chunks
all_audio = b"".join(chunks)
audio_array = np.frombuffer(all_audio, dtype=np.int16)
max_amp = np.max(np.abs(audio_array))
print(f"Max Amplitude: {max_amp}")
if max_amp < 100:
print("⚠️ Warning: Amplitude is very low (Silence?). Check mic mute.")
else:
print("βœ… Signal Detected! Amplitude looks good.")
# Check sample rate consistency
# 2 seconds * 24000 samples/sec = 48000 samples
expected_samples = 48000
actual_samples = len(audio_array)
print(f"Samples Captured: {actual_samples} (Expected ~{expected_samples})")
if abs(actual_samples - expected_samples) > 10000:
print("⚠️ Warning: Sample count deviation is high. Check specific timing/buffer issues.")
else:
print("βœ… Sample rate looks consistent.")
if __name__ == "__main__":
verify_fix()