I'm working on a Raspberry Pi project and I have a python script that accepts some serial input and plays sounds depending on the input. I have the script set up and it works just fine when I run it from within the GUI (i.e. startx). If I log out of the GUI and try to run the script from the command line the script executes just fine but my sounds don't play. I just get a momentary static click. I can tell the script is running because I have it printing debug code and the print's work just fine. Is there a way to get the sounds to work from the command line?
I want this script to execute when the Raspberry Pi is turned on without user input which I believe means it will be running from the command line. If there is some reason the sounds simply won't play until the GUI starts up how would I set it up to load the GUI and then execute the script on startup without any user input?
This will be embedded in a prop and will play sounds when some buttons (connected through arduino i.e. serial input) are pressed. So I need a solution that will have it from power on automatically run the script and be able to play the sounds with no keyboard, mouse, or monitor attached.
Turns out it was file path naming. If I have the command line test to the root directory it doesn't work but if I "cd Desktop/containingFolder" then the sounds play. I'll play with how I have the files set up in the python script so it will work.
Updating the path names fixed the issue. I just needed them to be full paths instead of relative ones.
pygame.mixer sound not playing when script run from command line