From 081f9368bcf341dced07bc515ce26a3b25f2eaa2 Mon Sep 17 00:00:00 2001 From: RhombusMaximus <31224721+RhombusMaximus@users.noreply.github.com> Date: Tue, 12 May 2026 18:43:44 -0700 Subject: [PATCH] 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. --- tools/voice_mode.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/voice_mode.py b/tools/voice_mode.py index 238fed4b289..cc691afad7d 100644 --- a/tools/voice_mode.py +++ b/tools/voice_mode.py @@ -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")