I have a python script that plays a .wav
file on the speakers.
from playsound import playsound
playsound('a.wav')
This works correctly if I execute the script on my local machine.
However, if I push the script on my remote Raspberry PI (along with the .wav
file) and execute it through an SSH session, the sound doesn't come out of the speaker plugged on the Raspberry PI.
I already had some question related, when I needed to open the web browser on the remote Raspberry PI device, but it doesn't seem to fix it.
I tried
python3 my_script.py
and
DISPLAY=:0 python3 my_script.py
None of them do play the file on the raspberry PI's speakers.
For info, omxplayer a.wav
does play the file on the remote speakers properly. But I do not want to call a 'shell' command for that, I'd like this to be done through a python script.
1 Answer 1
Ok, it seems the playsound
doesn't work properly on Raspbian (tried on a fresh install, with no luck).
However PyDub worked perfectly fine.
-
Congratulations, Arthur! +1 Please mark your answer as the "accepted" answer - it's more likely to help others, and you are the ONLY one who can do so.Seamus– Seamus2020年10月04日 15:25:40 +00:00Commented Oct 4, 2020 at 15:25
-
I'm aware of how Stack Exchange works, however I have to wait until tomorrow to accept my own answer ;-)Arthur Attout– Arthur Attout2020年10月04日 17:35:15 +00:00Commented Oct 4, 2020 at 17:35
DISPLAY=:0
to your command will never have an effect on it.