Error trying to play an audio file in jetson nano connected to a bluetooth speaker

hi, i am trying to fix the audio issue in jetson nano from past one week and i am unable to find suitable solution for it anywhere.

i have connected a bluetooth speaker to jetson nano but this is seen as “headset” in the audio icon. so, my issue is that i am running an audio file(.wav file) in a python script if certain function is executed like enclosed below. THE AUDIO PLAYS ABSOULTELY FINE WHEN RUN MANUALLY ON TERMINAL USING “PYTHON3 abcd.py”. but this exact file is made into a executable file using pyinstaller and ran in systemd services. the executable file ./abcd file also plays the audio and the event also executes but only the audio does not play in systemd services.

from pygame import mixer
mixer.init()
mixer.music.load( "/home/sid/song/song.wav" )
if (some_event):
mixer.music.play()

audio is 5sec long and .wav format.
my service file looks like this

[Unit]
Description = SIDD
After=local-fs.target
ConditionPathExists=/opt/SIDD/bin

[Service]
ExecStart=/opt/SIDD/bin/SIDD.sh
Restart=no
Type=simple
StandardOutput=journal+console

[Install]
WantedBy=multi-user.target

i did follow the below link to enable audio on my speaker but no luck with respect to service. https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide%2Fasoc_driver.18.2.html%23wwpID0E0AV0HA
Should i be adding a audio path anywhere or change audio/bluetooth config file?

Hi,

I don’t think this issue has anything to do with bluetooth. Issue seems related to systemd.
Is your python script able to work as root?

hi,
yeah my python script works absolutely fine in sudo. i am unable to figure out any errors in systemd.
How can i fix this?

Have you tried other startup tool from ubuntu like rc.local?

Hi,
Here is a reference post of setting rc.local:


FYR.