Hi all!
I’m working on a small project with a text-to-speech microservice.
We use an upboard cht01, with a usb sound card plugged in.
this is lsusb output on balena os host
Bus 001 Device 004: ID 0424:2530 Standard Microsystems Corp.
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 0d8c:000c C-Media Electronics, Inc. Audio Adapter
Bus 001 Device 003: ID 0424:4603 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
I also listed /dev content with and without plugged usb, and I notice that the only difference is hidraw0.
After that I create a docker compose in order to get a docker container with audio support, with a small node script to playout a local file by audio-play, audio-buffer-from and audio-loader npm packages
This is the docker compose
version: "2"
services:
test:
container_name: test
build:
context: .
dockerfile: Dockerfile
environment:
- UDEV=1
privileged: true
devices:
- "/dev/snd:/dev/snd"
- "/dev/hidraw0:/dev/hidraw0"
network_mode: host
and this is the dockerfile
FROM node:16.6-alpine
RUN adduser -S appuser
WORKDIR /usr/src/app
RUN apk update && \
apk upgrade && \
apk add \
espeak \
vorbis-tools \
sox \
alsa-utils \
alsa-lib \
pulseaudio \
pulseaudio-alsa \
pulseaudio-utils \
curl \
rm -rf /var/cache/apk/*
COPY package*.json ./
RUN npm i
COPY . .
RUN addgroup appuser audio
RUN addgroup appuser pulse
RUN addgroup appuser pulse-access
USER appuser
RUN pulseaudio --start
CMD tail -f /dev/null
in the docker container I can get available sound cards by aplay --list-devices command, but unluckily, it seems there is no sound card available.
aplay --list-devices
aplay: device_list:274: no soundcards found...
I think it’s just a docker compose device mount issue, but I have no idea about how to make it working… any helps?
Thanks!