{"record":{"id":"dff124627bfb5486","repo":"Aider-AI/aider","slug":"no-audio-input-device-detected-please-check-your","errorCode":null,"errorMessage":"No audio input device detected. Please check your audio settings and try again.","messagePattern":"No audio input device detected\\. Please check your audio settings and try again\\.","errorType":"exception","errorClass":"SoundDeviceError","httpStatus":null,"severity":"error","filePath":"aider/voice.py","lineNumber":126,"sourceCode":"            return self.raw_record_and_transcribe(history, language)\n        except KeyboardInterrupt:\n            return\n        except SoundDeviceError as e:\n            print(f\"Error: {e}\")\n            print(\"Please ensure you have a working audio input device connected and try again.\")\n            return\n\n    def raw_record_and_transcribe(self, history, language):\n        self.q = queue.Queue()\n\n        temp_wav = tempfile.mktemp(suffix=\".wav\")\n\n        try:\n            sample_rate = int(self.sd.query_devices(self.device_id, \"input\")[\"default_samplerate\"])\n        except (TypeError, ValueError):\n            sample_rate = 16000  # fallback to 16kHz if unable to query device\n        except self.sd.PortAudioError:\n            raise SoundDeviceError(\n                \"No audio input device detected. Please check your audio settings and try again.\"\n            )\n\n        self.start_time = time.time()\n\n        try:\n            with self.sd.InputStream(\n                samplerate=sample_rate, channels=1, callback=self.callback, device=self.device_id\n            ):\n                prompt(self.get_prompt, refresh_interval=0.1)\n        except self.sd.PortAudioError as err:\n            raise SoundDeviceError(f\"Error accessing audio input device: {err}\")\n\n        with sf.SoundFile(temp_wav, mode=\"x\", samplerate=sample_rate, channels=1) as file:\n            while not self.q.empty():\n                file.write(self.q.get())\n\n        use_audio_format = self.audio_format","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/Aider-AI/aider/blob/5dc9490bb35f9729ef2c95d00a19ccd30c26339c/aider/voice.py#L108-L144","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before (headless box)\nfrom aider.voice import Voice\nVoice().record_and_transcribe()  # SoundDeviceError: No audio input device detected\n\n# after (guard before recording)\nimport sounddevice as sd\ntry:\n    inputs = [d[\"name\"] for d in sd.query_devices() if d[\"max_input_channels\"] > 0]\nexcept Exception:\n    inputs = []\nif not inputs:\n    raise SystemExit(\"No microphone available; use text input instead.\")\nVoice().record_and_transcribe()","handlingStrategy":"validation","validationCode":"import sounddevice as sd\n\ndef has_input_device() -> bool:\n    try:\n        return any(d[\"max_input_channels\"] > 0 for d in sd.query_devices())\n    except (OSError, ModuleNotFoundError, sd.PortAudioError):\n        return False","typeGuard":null,"tryCatchPattern":"from aider.voice import SoundDeviceError, Voice\ntry:\n    text = Voice().record_and_transcribe()\nexcept SoundDeviceError as e:\n    if \"No audio input device\" in str(e):\n        text = input(\"No mic available — type instead: \")\n    else:\n        raise","preventionTips":["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."],"tags":["audio","voice","portaudio","no-device","environment","aider"],"backgroundTag":null,"analyzedSha":"5dc9490bb35f9729ef2c95d00a19ccd30c26339c","analyzedAt":"2026-08-15T05:40:10.498Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}