2026-04-14 10:08:41 +08:00

21 lines
778 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# Conda 里 PyAudio 自带的 libportaudio 会加载同目录 libasound从而去 conda/.../lib/alsa-lib/
# 找插件(多数环境不完整,终端刷屏且麦克风电平异常)。
# 在启动 Python **之前** 预加载系统的 libasound.so.2 可恢复正常 ALSA 行为。
#
# 用法(项目根目录):
# bash with_system_alsa.sh python src/mic_level_check.py
# bash with_system_alsa.sh python src/rocket_drone_audio.py
set -euo pipefail
ARCH="$(uname -m)"
case "${ARCH}" in
aarch64) ASO="/usr/lib/aarch64-linux-gnu/libasound.so.2" ;;
x86_64) ASO="/usr/lib/x86_64-linux-gnu/libasound.so.2" ;;
*) ASO="" ;;
esac
if [[ -n "${ASO}" && -f "${ASO}" ]]; then
export LD_PRELOAD="${ASO}${LD_PRELOAD:+:${LD_PRELOAD}}"
fi
exec "$@"