Skip to content

Instantly share code, notes, and snippets.

@i-sync
Created October 6, 2019 08:40
Show Gist options
  • Select an option

  • Save i-sync/d1c59f29e4f018e5ab9f565cfdf4eb8f to your computer and use it in GitHub Desktop.

Select an option

Save i-sync/d1c59f29e4f018e5ab9f565cfdf4eb8f to your computer and use it in GitHub Desktop.
voice check for telegram
[program:voice-producor]
command=/home/pi/voice/voice-producor.sh
user=pi
stderr_logfile=/home/pi/voice/voicep.log
stdout_logfile=/home/pi/voice/voicep.log
stopasgroup=true
stopsignal=QUIT
[program:voice-consumer]
command=/home/pi/voice/voice-consumer.sh
user=pi
stderr_logfile=/home/pi/voice/voicec.log
stdout_logfile=/home/pi/voice/voicec.log
stopasgroup=true
stopsignal=QUIT
#! /bin/bash
#variable
player=/usr/bin/omxplayer
reminder=/home/pi/tmp/remind/reminder.mp3
backup=/home/pi/tmp/backup/
FIFO=/home/pi/voice/fifo1
#create a named pipe
if [[ ! -e $FIFO ]]; then
mkfifo $FIFO
fi
#read
while read file < $FIFO
do
echo $file
#check mpc is running, pause
playing=`mpc | grep playing | wc -l`
if [ $playing -ge 1 ]
then
mpc pause
fi
#playing message
$player $reminder
$player $file
$player $file
mv $file $backup
#if mpc is paused , resume
paused=`mpc | grep paused | wc -l`
if [ $paused -ge 1 ]
then
mpc play
fi
done
#!/bin/bash
FIFO=/home/pi/voice/fifo1
if [[ ! -e $FIFO ]]; then
mkfifo $FIFO
fi
inotifywait -m /home/pi/tmp -e close_write |
while read path action file; do
#echo "########$path$file#########"
echo "$path$file" >> $FIFO
#echo "$path$file" >> ~/inotify.txt
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment