Python 脚本作为服务无法访问 asoundrc 配置文件

标签 python raspbian audio-recording alsa

我有一个 Python 脚本,用于记录连接到 Raspberry PI 3 的 I2S MEMS 麦克风的音频。 从终端访问时,该脚本按预期运行。当我在后台将其作为服务运行时,就会出现问题。

据我所知,问题在于脚本作为服务无法访问我在 asoundrc 中配置的 software_volume。奇怪的是,我可以使用 get_device_info_by_index() 函数在设备列表中看到这个“设备”。

对于音频捕获,我使用pyaudio库,为了使脚本成为服务,我使用supervisor实用程序。 有什么想法可能是什么问题以及如何使我的脚本在作为服务运行时能够访问 asoundrc 吗?

最佳答案

~/.asoundrc 文件中查找当前用户的主目录(这就是 ~ 的含义)。

将其放入服务运行用户的主目录中,或将定义放入全局 ALSA 配置文件 /etc/asound.conf 中。

关于Python 脚本作为服务无法访问 asoundrc 配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50812469/

相关文章:

python - 将参数传递给通用 View Django 查询集

python - Pandas 分析 - KeyError : 'Requested level (var1) does not match index name (None)'

Raspbian 上 Raspberry Pi 的 Bash 文件修改警报

c# - 如何使用 Windows MediaCapture API 捕获 "Audio Only"?

安卓 : Audio Recorder With TImer

android - 带耳机的通话录音

python - 从 HTML 页面动态提取数据

python - Pandas 提取和替换值

c - raspbian libc 函数名称上的 Gdb

linux - 在 Raspberry Pi 上重新启动崩溃的驱动程序