Aider-AI/aider · error · SoundDeviceError
No audio input device detected. Please check your audio sett
Error message
No audio input device detected. Please check your audio settings and try again.
What it means
In Voice.raw_record_and_transcribe, before opening an input stream the code queries the chosen device's default input sample rate via sd.query_devices(self.device_id, "input"). A sounddevice.PortAudioError from that query is converted to SoundDeviceError('No audio input device detected...') — PortAudio itself reports no usable input device. This is an environment/backend problem (no mic, disabled device, or a broken audio server), distinct from the later stream-open failure at voice.py:138.
Source
Thrown at aider/voice.py:126
return self.raw_record_and_transcribe(history, language)
except KeyboardInterrupt:
return
except SoundDeviceError as e:
print(f"Error: {e}")
print("Please ensure you have a working audio input device connected and try again.")
return
def raw_record_and_transcribe(self, history, language):
self.q = queue.Queue()
temp_wav = tempfile.mktemp(suffix=".wav")
try:
sample_rate = int(self.sd.query_devices(self.device_id, "input")["default_samplerate"])
except (TypeError, ValueError):
sample_rate = 16000 # fallback to 16kHz if unable to query device
except self.sd.PortAudioError:
raise SoundDeviceError(
"No audio input device detected. Please check your audio settings and try again."
)
self.start_time = time.time()
try:
with self.sd.InputStream(
samplerate=sample_rate, channels=1, callback=self.callback, device=self.device_id
):
prompt(self.get_prompt, refresh_interval=0.1)
except self.sd.PortAudioError as err:
raise SoundDeviceError(f"Error accessing audio input device: {err}")
with sf.SoundFile(temp_wav, mode="x", samplerate=sample_rate, channels=1) as file:
while not self.q.empty():
file.write(self.q.get())
use_audio_format = self.audio_formatView on GitHub (pinned to 5dc9490bb3)
Solutions
- Verify an input device exists and is enabled: python -c "import sounddevice as sd; print([d['name'] for d in sd.query_devices() if d['max_input_channels']>0])" — empty list confirms the OS sees no mic.
- On headless/SSH/container environments, attach an audio device (docker --device /dev/snd, PulseAudio socket forward) or use text input instead of voice.
- On Linux, restart/verify the sound server (pulseaudio -k && pulseaudio -D or check pipewire) so devices enumerate.
- Enable/unmute the microphone in OS privacy settings and re-run.
Example fix
# before (headless box)
from aider.voice import Voice
Voice().record_and_transcribe() # SoundDeviceError: No audio input device detected
# after (guard before recording)
import sounddevice as sd
try:
inputs = [d["name"] for d in sd.query_devices() if d["max_input_channels"] > 0]
except Exception:
inputs = []
if not inputs:
raise SystemExit("No microphone available; use text input instead.")
Voice().record_and_transcribe() Defensive patterns
Strategy: validation
Validate before calling
import sounddevice as sd
def has_input_device() -> bool:
try:
return any(d["max_input_channels"] > 0 for d in sd.query_devices())
except (OSError, ModuleNotFoundError, sd.PortAudioError):
return False Try / catch
from aider.voice import SoundDeviceError, Voice
try:
text = Voice().record_and_transcribe()
except SoundDeviceError as e:
if "No audio input device" in str(e):
text = input("No mic available — type instead: ")
else:
raise Prevention
- Guard with a device-enumeration check before offering the voice feature (headless boxes, SSH, containers).
- In Docker, pass --device /dev/snd or forward PulseAudio; plain containers have no audio.
- Verify the OS sound server (pipewire/pulseaudio) is running on Linux before recording.
When it happens
Trigger: Calling record_and_transcribe()/raw_record_and_transcribe on a machine where PortAudio finds no default input device: headless server/VM/container with no audio hardware, microphone disabled at OS level, or Linux sound server (PulseAudio/PipeWire) down so query_devices cannot resolve an input.
Common situations: Running aider's voice feature over SSH or in Docker where /dev/snd is absent; CI machines; laptops with mic privacy-switch off or mic disabled in BIOS/OS; Linux after the audio daemon crashes.
Related errors
- Error accessing audio input device: {err}
- Device '{device_name}' not found. Available input devices: {
- Unsupported audio format: {audio_format}
- Please set the OPENAI_API_KEY environment variable.
- Unknown edit format {edit_format}. Valid formats are: {', '.
AI-assisted analysis of Aider-AI/aider@5dc9490bb3 (2026-08-15).
Data as JSON: /api/errors/dff124627bfb5486.
Report an issue: GitHub.