Why i cant launch python script with systemd?

  Kiến thức lập trình

I tried to launch my voice assistant with the start of the rassbery pi 4 using systemd but its faliur


Apr 12 19:44:24 raspberrypi python3[38693]: Traceback (most recent call last):
Apr 12 19:44:24 raspberrypi python3[38693]:   File "/home/vovo/Desktop/project-2/mediaplayer/bublik/media_4.py", line 157, in <module>
Apr 12 19:44:24 raspberrypi python3[38693]:     listen()
Apr 12 19:44:24 raspberrypi python3[38693]:   File "/home/vovo/Desktop/project-2/mediaplayer/bublik/media_4.py", line 120, in listen
Apr 12 19:44:24 raspberrypi python3[38693]:     stream = mic.open(format=pyaudio.paInt16, channels=1, rate=16000, input=True, frames_per_buffer=8192)
Apr 12 19:44:24 raspberrypi python3[38693]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 12 19:44:24 raspberrypi python3[38693]:   File "/home/vovo/Desktop/project-2/mediaplayer/bublik/lib/python3.11/site-packages/pyaudio/__init__.py", line 639, in open
Apr 12 19:44:24 raspberrypi python3[38693]:     stream = PyAudio.Stream(self, *args, **kwargs)
Apr 12 19:44:24 raspberrypi python3[38693]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 12 19:44:24 raspberrypi python3[38693]:   File "/home/vovo/Desktop/project-2/mediaplayer/bublik/lib/python3.11/site-packages/pyaudio/__init__.py", line 441, in __init__
Apr 12 19:44:24 raspberrypi python3[38693]:     self._stream = pa.open(**arguments)
Apr 12 19:44:24 raspberrypi python3[38693]:                    ^^^^^^^^^^^^^^^^^^^^
Apr 12 19:44:24 raspberrypi python3[38693]:     OSError: [Erron -9997] Invalid sample rate

I dont understand why there is an Invalid sample rate because if i launch it mannually it will work
Here is my unit


#rpi.service
[Unit]
Description= RPi-Service
After = multi-user.target

[Service]
Type = simple
Environment="DISPLAY=:0"
Environment="XAUTHORITY=/home/vovo/.Xauthority"
ExecStart = /home/vovo/Desktop/project-2/mediaplayer/bublik/bin/python3 /home/vovo/Desktop/project-2/mediaplayer/bublik/media_4.py
Restart = always
RestartSec = 5
KillMode = process
SendSIGHUP = no

[Install]
WantedBy= graphical.target

New contributor

Marokass Marokas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT