Skip to content

[Bug]: no audio device error in hermes chat #21203

@myzhongguo

Description

@myzhongguo

Bug Description

I am encountering a persistent no audio device error when running Hermes v0.12.0 in a Docker container on a Linux host.

The environment is correctly configured to pass through the host's audio system (PipeWire/PulseAudio). I have verified that the audio subsystem is fully functional inside the container using standard tools and Python scripts. However, Hermes chat /voice on to initialize audio.

Steps to Reproduce

1.Run a Docker container with the following audio configuration:

•Mount PulseAudio socket: -v /run/user/1000/pulse/native:/run/user/1000/pulse/native

•Mount XDG runtime dir: -v /run/user/1000:/run/user/1000

•Set env vars: PULSE_SERVER=unix:/run/user/1000/pulse/native and XDG_RUNTIME_DIR=/run/user/1000
2.Inside the container, verify audio functionality:

•Run pactl info: Success (Connects to server).

•Run python3 -c "import sounddevice; print(sounddevice.query_devices())": Success (Lists devices).

•Run a test script to play sound: Success (Confirmed output device index is 19).
3.Set environment variables for Hermes:

•SOUNDDEVICE_DEVICE=19

•SOUNDDEVICE_API=PulseAudio
4.Start Hermes Chat/Agent.

Expected Behavior

Hermes should detect the PulseAudio backend and use the specified default device (index 19) or the system default without error.

Actual Behavior

Hermes chat voice on with the error: no audio device.

Affected Component

CLI (interactive chat)

Messaging Platform (if gateway-related)

No response

Debug Report

/voice

Voice mode unavailable in this environment:
  Running inside Docker container -- no audio devices
 ⚕ claude-opus-4.6 │ ctx -- │ [░░░░░░░░░░] -- │ 4m │ ⏲ 0s

Operating System

ubantu24.04

Python Version

No response

Hermes Version

v0.12.0

Additional Logs / Traceback (optional)

Root Cause Analysis (optional)

I have performed extensive debugging which suggests this is a bug in how Hermes (or the underlying sounddevice/PortAudio library) initializes the audio backend in a containerized environment.

1.Environment Variables Ignored: Even though SOUNDDEVICE_DEVICE=19 is set and visible in the container environment, Hermes still fails. This suggests the library might be initializing before the environment variable is read, or Hermes is overriding it.
2.Hardcoded Device Index: It appears the application or library might be defaulting to device index 0 (typically a physical ALSA card which doesn't exist in the container) instead of respecting the PulseAudio virtual device.
3.Verification: My Python diagnostic script proves that sounddevice can work on device 19, so the issue is specific to Hermes' initialization sequence.

Proposed Fix (optional)

The initialization logic for sounddevice needs to be more robust in handling non-zero default devices or environments where physical cards are absent.

1.Ensure Environment Variable Compliance: Ensure sounddevice reads SOUNDDEVICE_DEVICE at the very start of execution.
2.Auto-Detection: If device 0 is unavailable, the code should automatically fall back to querying available devices (like pactl does) rather than failing immediately.
3.Explicit Configuration: Allow users to pass the device index via CLI arguments (e.g., hermes --audio-device 19)

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existsarea/dockerDocker image, Compose, packagingcomp/cliCLI entry point, hermes_cli/, setup wizardtool/ttsText-to-speech and transcriptiontype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions