Search code examples
pythonraspbianaudio-recordingalsa

Python script as service has not access to asoundrc configuration file


I have a python script that records audio from an I2S MEMS microphone, connected to a Raspberry PI 3. This script runs as supposed to, when accessed from the terminal. The problem appears when i run it as a service in the background.

From what i have seen, the problem is that the script as service, has no access to a software_volume i have configured in asoundrc. The strange thing is that i can see this "device" in the list of devices using the get_device_info_by_index() function.

For audio capturing i use the pyaudio library and for making the script a service i have utilized the supervisor utility. Any ideas what the problem might be and how i can make my script to have access to asoundrc when it runs as a service?


Solution

  • The ~/.asoundrc file is looked for the home directory of the current user (this is what ~ means).

    Put it into the home directory of the user as which the service runs, or put the definitions into the global ALSA configuration file /etc/asound.conf.