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: | Weed Hopper |
---|---|
Location: | Clearwater, FL |
Users: | 14 |
Nodes: | 6 (0 / 6) |
Uptime: | 231:16:43 |
Calls: | 55 |
Calls today: | 1 |
Files: | 50,127 |
D/L today: |
29 files (3,538K bytes) |
Messages: | 275,358 |