fix(voice_mode): detect audio in WSL when sd.query_devices() returns empty list but PULSE_SERVER is set

In WSL2, sounddevice.query_devices() returns [] even when the
PulseAudio bridge is functional. The existing code already handled
the case where the query itself raises an exception, but it missed
the empty-list case.

This change treats an empty device list as non-fatal in WSL when
PULSE_SERVER is configured, matching the existing exception-handler
behavior.

Fixes: WSL users seeing 'No audio input/output devices detected'
even though paplay/arecord work fine.
This commit is contained in:
RhombusMaximus 2026-05-12 18:43:44 -07:00 committed by Teknium
parent e71393237e
commit 081f9368bc

View file

@ -130,7 +130,9 @@ def detect_audio_environment() -> dict:
try:
devices = sd.query_devices()
if not devices:
if termux_capture:
if os.environ.get('PULSE_SERVER'):
notices.append("No PortAudio devices detected but PULSE_SERVER is set -- continuing")
elif termux_capture:
notices.append("No PortAudio devices detected, but Termux:API microphone capture is available")
else:
warnings.append("No audio input/output devices detected")