mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-11-18 04:32:23 -05:00
49 lines
2.5 KiB
YAML
49 lines
2.5 KiB
YAML
- id: alsa
|
|
name: ALSA microphone
|
|
description: Uses the configured audio input device through roverd's ALSA conversion route.
|
|
setup: |
|
|
if ! command -v ffmpeg >/dev/null || ! command -v arecord >/dev/null; then
|
|
apt-get update && apt-get install -y ffmpeg alsa-utils
|
|
fi
|
|
run: |
|
|
exec ffmpeg -nostdin -f alsa -ar "$ROVER_AUDIO_SAMPLE_RATE" -ac "$ROVER_AUDIO_CHANNELS" -i "$ROVER_AUDIO_INPUT_DEVICE" -c:a libopus -b:a "$ROVER_AUDIO_BITRATE" -f rtsp -rtsp_transport tcp "$ROVER_AUDIO_PUBLISH_URL"
|
|
- id: aiy
|
|
name: Google AIY Voice HAT microphone
|
|
description: HAT capture with S32_LE input, 20 dB microphone boost, and low-latency Opus settings. Reboot once after first enabling its hardware.
|
|
setup: |
|
|
set -euo pipefail
|
|
# Capture/playback setup may run concurrently; serialize edits to boot config.
|
|
exec 9>/var/lock/roverd-aiy.lock
|
|
flock 9
|
|
boot=/boot/firmware/config.txt
|
|
[[ -f "$boot" ]] || boot=/boot/config.txt
|
|
[[ -f "$boot" ]] || { echo 'AIY setup needs a Raspberry Pi boot config.txt' >&2; exit 1; }
|
|
changed=0
|
|
for setting in dtparam=i2s=on dtoverlay=googlevoicehat-soundcard; do
|
|
if ! grep -Fxq "$setting" "$boot"; then
|
|
# Leave any model-specific section before adding shared HAT settings.
|
|
if [[ "$changed" == 0 ]]; then printf '\n[all]\n' >> "$boot"; fi
|
|
printf '%s\n' "$setting" >> "$boot"
|
|
changed=1
|
|
fi
|
|
done
|
|
if [[ "$changed" == 1 ]]; then
|
|
echo 'AIY hardware enabled. Reboot the host once before using this sound card.'
|
|
fi
|
|
if ! command -v ffmpeg >/dev/null || ! command -v arecord >/dev/null; then
|
|
apt-get update && apt-get install -y ffmpeg alsa-utils
|
|
fi
|
|
run: |
|
|
# Preserve the HAT capture format, gain, and low-cost Opus settings.
|
|
arecord -D "$ROVER_AUDIO_INPUT_DEVICE" -f S32_LE \
|
|
-c "$ROVER_AUDIO_CHANNELS" -r "$ROVER_AUDIO_SAMPLE_RATE" \
|
|
-B "${AUDIO_ALSA_BUFFER_BYTES:-16384}" -F "${AUDIO_ALSA_PERIOD_BYTES:-1024}" -q -t raw |
|
|
ffmpeg -nostdin -hide_banner -loglevel warning -fflags nobuffer \
|
|
-rtbufsize 0 -thread_queue_size 4096 -f s32le \
|
|
-ar "$ROVER_AUDIO_SAMPLE_RATE" -ac "$ROVER_AUDIO_CHANNELS" -i pipe:0 \
|
|
-af "volume=20dB" -c:a libopus -b:a "$ROVER_AUDIO_BITRATE" \
|
|
-ar:a "$ROVER_AUDIO_SAMPLE_RATE" -ac:a "$ROVER_AUDIO_CHANNELS" \
|
|
-application audio -frame_duration 20 -compression_level 0 \
|
|
-flush_packets 1 -muxdelay 0 -muxpreload 0 \
|
|
-f rtsp -rtsp_transport tcp "$ROVER_AUDIO_PUBLISH_URL"
|