Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5365

Python • Re: Running PyAudio Script On Startup Issue

$
0
0


No. By headless I mean without monitor (and keyboard, and mouse).
No, my pi isn't headless. I have a TV with a keyboard and mouse connected.
BTW, that user's systemd solution didn't work. I doubt that's the best method anyway.
1) What was the issue?
My pi is headless. It works very well there.
Recently I have been facing issues after switching to a compute module...but I guess that's another issue.

Try looking at the journal

Code:

journalctl -u your_service_name.service
and see what went wrong.
Did the service not start on boot? Did the python code not execute?

2) One more thing, pyaudio has gotten old.
I switched to python-sounddevice after facing several problems with it. It does the same thing as pyaudio, and it's also a wrapper around PortAudio. But it has better documentation and is easier to use. You can see if that works for you.
https://pypi.org/project/sounddevice/

3) Most of the error message you are getting from pyaudio is unnecessary warnings. Try suppressing them, then you will be able to see the actual error more clearly. Take a look at this answer.
https://stackoverflow.com/questions/677 ... isy-output

4) It could be that pyaudio ends up using the wrong audio card, since you have HDMI etc. Try setting the audio card explicitly. In Sounddevice it's done by:

Code:

sounddevice.default.device = audio_device
. You can find the available audio device by running

Code:

arecord -l
in your command line.
So you're saying that I should switch to python-soundevice?
Also, when I run the .service file just from terminal, it works, but when I run it on startup I get an error. (my script has an error function) But what is weird is when I first ran the .service file the first few times, it worked, but after like 5 or 6 it stopped working. Any idea why?

Statistics: Posted by Henrik Gill — Wed Aug 21, 2024 8:24 pm



Viewing all articles
Browse latest Browse all 5365

Trending Articles