clio/clio-ai/real_time/test_corsair_mic.sh

72 lines
2.1 KiB
Bash
Raw Normal View History

2026-05-19 19:48:13 -04:00
#!/usr/bin/env bash
# Test script for Corsair VOID ELITE Wireless microphone
# Uses PipeWire for audio capture
OUTPUT_FILE="test_recording.wav"
DURATION=5
echo "=== Corsair VOID ELITE Microphone Test ==="
echo ""
# Get the Corsair source ID
CORSAIR_SOURCE=$(wpctl status | grep -i "corsair" | grep -i "mono" | grep -oE '[0-9]+\.' | head -1 | tr -d '.')
if [ -z "$CORSAIR_SOURCE" ]; then
echo "ERROR: Corsair microphone not found in PipeWire sources"
wpctl status | grep -A5 "Sources:"
exit 1
fi
echo "Found Corsair mic: Source ID $CORSAIR_SOURCE"
echo "Duration: ${DURATION} seconds"
echo ""
echo "Speak into your Corsair headset microphone..."
echo ""
# Record using pw-record
pw-record --target "$CORSAIR_SOURCE" --rate 48000 --channels 1 --format s16 "$OUTPUT_FILE" &
PW_PID=$!
sleep "$DURATION"
kill "$PW_PID" 2>/dev/null
wait "$PW_PID" 2>/dev/null
if [ -f "$OUTPUT_FILE" ]; then
echo ""
echo "=== Recording complete ==="
echo "Saved to: $OUTPUT_FILE"
echo ""
# Show file info
echo "File info:"
ffprobe -hide_banner "$OUTPUT_FILE" 2>&1 | grep -E "Duration|Stream"
# Check if there's actual audio (not silence)
echo ""
echo "Audio levels:"
ffmpeg -i "$OUTPUT_FILE" -af "volumedetect" -f null /dev/null 2>&1 | grep -E "max_volume|mean_volume"
MAX_VOL=$(ffmpeg -i "$OUTPUT_FILE" -af "volumedetect" -f null /dev/null 2>&1 | grep "max_volume" | sed 's/.*max_volume: \([-0-9.]*\).*/\1/')
echo ""
# Check if max volume is greater than -50 dB (audible)
if [ "$(echo "$MAX_VOL" | cut -d. -f1)" -gt -50 ] 2>/dev/null; then
echo "SUCCESS: Audio detected! Max volume: ${MAX_VOL} dB"
else
echo "WARNING: Very quiet or silent recording (${MAX_VOL} dB)"
echo ""
echo "Possible causes:"
echo " - Mic mute button on headset is ON (flip the switch!)"
echo " - Headset is not being worn / mic boom is retracted"
echo " - Volume too low in system settings"
fi
echo ""
echo "To play back: ffplay -nodisp -autoexit $OUTPUT_FILE"
else
echo ""
echo "=== Recording FAILED ==="
exit 1
fi