Page 1 of 1

Playing .wav using aplay

Posted: Sat Mar 22, 2014 8:01 pm
by stujol
Using LXTerminal I can play a wav file using the below and it outputs to my speaker

pi@raspberrypi ~ $ aplay alarmclock.wav

I also have a cron job which outputs some espeak text to my speakers and I want to integrate the two (espeak and wav file) together.

I have tried a few different formats but cant get the aplay to work from a script file, any help would be great. Also my echo doesn't work.

#!/bin/sh
# /etc/init.d/start-sound
echo "playing alarmclock sound"
aplay /home/pi/alarmclock.wav
espeak "some text"

Re: Playing .wav using aplay

Posted: Sat Mar 22, 2014 8:06 pm
by redhawk
stujol wrote:Also my echo doesn't work.
That's probably because your script isn't getting called or crontab contains errors.
First make sure your script has execute flag (chmod +x) and secondly in your crontab entry make sure it contains the full path to the script file.

Richard S.

Re: Playing .wav using aplay

Posted: Sat Mar 22, 2014 8:29 pm
by stujol
cron is working ok as the espeak function works

Re: Playing .wav using aplay

Posted: Sun Mar 23, 2014 3:47 am
by sdjf
You have to make the script executable. Do "ls -l" and post that output, if it does not have x in it, that is your problem.

Also, how are you trying it, are you entering the script name on the command line? There should be some output if it is not an executable, telling you something.

chmod +x does not work for my scripts, I usually do the following with them, that way it does not matter who the user is who calls the script.

chmod a+x myscript.sh

Make sure the script works when you type it's name on the command line, before you put it into a crontab.

Re: Playing .wav using aplay

Posted: Sun Mar 23, 2014 10:17 am
by stujol
sorry all my fault, I was editing the wrong file. I need to keep an eye on what directory I'm working in.