I have a Sense Hat and want to run this oython script at boot:
from sense_hat import SenseHat
from pydub import AudioSegment
from pydub.playback import play
song = AudioSegment.from_wav("/home/pi/redalert.wav")
sense = SenseHat()
x = 0.1
y = 204,0,0
z = 0,0,153
y1 = 25,0,0
z1 = 255,255,0
while True:
play(song)
play(song)
sense.show_message("!!! Intuder Alert ", x, y, z)
Now if I boot the Pi and then run the script it runs fine and the sound plays.
However if I use
@reboot python3 /home/pi/intruder.py via a cron job, the message is
displayed but no sound.
The Natural Philosopher wrote:
On 22/12/2023 08:41, Dr Stephen Strange wrote:
I have a Sense Hat and want to run this oython script at boot:
from sense_hat import SenseHat
from pydub import AudioSegment
from pydub.playback import play
song = AudioSegment.from_wav("/home/pi/redalert.wav")
sense = SenseHat()
x = 0.1
y = 204,0,0
z = 0,0,153
y1 = 25,0,0
z1 = 255,255,0
while True:
play(song)
play(song)
sense.show_message("!!! Intuder Alert ", x, y, z)
Now if I boot the Pi and then run the script it runs fine and the
sound plays.
However if I use
@reboot python3 /home/pi/intruder.py via a cron job, the message is
displayed but no sound.
I think I had this issue. The permissions on sound channels are
weird. I wanted the web server (user www-data) to play sounds - it
wouldn't until I did something to it...
OK I just logged in to that machine
in /etc/group is this line:
audio:x:29:me,www-data,pulse,root
I suggest you add at least root and probably pulse to the audio group
Hi - thanks for your help - tired that but still no sound
On 22/12/2023 08:41, Dr Stephen Strange wrote:
I have a Sense Hat and want to run this oython script at boot:
from sense_hat import SenseHat
from pydub import AudioSegment
from pydub.playback import play
song = AudioSegment.from_wav("/home/pi/redalert.wav")
sense = SenseHat()
x = 0.1
y = 204,0,0
z = 0,0,153
y1 = 25,0,0
z1 = 255,255,0
while True:
play(song)
play(song)
sense.show_message("!!! Intuder Alert ", x, y, z)
Now if I boot the Pi and then run the script it runs fine and the
sound plays.
However if I use
@reboot python3 /home/pi/intruder.py via a cron job, the message is
displayed but no sound.
I think I had this issue. The permissions on sound channels are weird.
I wanted the web server (user www-data) to play sounds - it wouldn't
until I did something to it...
OK I just logged in to that machine
in /etc/group is this line:
audio:x:29:me,www-data,pulse,root
I suggest you add at least root and probably pulse to the audio group
Dr Stephen Strange wrote:
The Natural Philosopher wrote:
On 22/12/2023 08:41, Dr Stephen Strange wrote:
I have a Sense Hat and want to run this oython script at boot:
from sense_hat import SenseHat
from pydub import AudioSegment
from pydub.playback import play
song = AudioSegment.from_wav("/home/pi/redalert.wav")
sense = SenseHat()
x = 0.1
y = 204,0,0
z = 0,0,153
y1 = 25,0,0
z1 = 255,255,0
while True:
play(song)
play(song)
sense.show_message("!!! Intuder Alert ", x, y, z)
Now if I boot the Pi and then run the script it runs fine and the
sound plays.
However if I use
@reboot python3 /home/pi/intruder.py via a cron job, the message is
displayed but no sound.
I think I had this issue. The permissions on sound channels are
weird. I wanted the web server (user www-data) to play sounds - it
wouldn't until I did something to it...
OK I just logged in to that machine
in /etc/group is this line:
audio:x:29:me,www-data,pulse,root
I suggest you add at least root and probably pulse to the audio group
Hi - thanks for your help - tired that but still no sound
That is *TRIED* but still no sound!!!
Sysop: | deepend |
---|---|
Location: | Calgary, Alberta |
Users: | 264 |
Nodes: | 10 (0 / 10) |
Uptime: | 30:56:37 |
Calls: | 2,002 |
Files: | 4,428 |
D/L today: |
18 files (8,990K bytes) |
Messages: | 410,046 |