stujol
Posts: 25
Joined: Sat Mar 08, 2014 10:56 pm

Playing .wav using aplay

Sat Mar 22, 2014 8:01 pm

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"

User avatar
redhawk
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1

Re: Playing .wav using aplay

Sat Mar 22, 2014 8:06 pm

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.

stujol
Posts: 25
Joined: Sat Mar 08, 2014 10:56 pm

Re: Playing .wav using aplay

Sat Mar 22, 2014 8:29 pm

cron is working ok as the espeak function works

sdjf
Posts: 1395
Joined: Fri Mar 16, 2012 5:20 am
Location: California
Contact: Website

Re: Playing .wav using aplay

Sun Mar 23, 2014 3:47 am

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.
FORUM TIP: To view someone's posting history, sign in, click on their user name, then on "Search User's Posts." || Running ArchLinuxArm on Model 2B and 512MB Model B

stujol
Posts: 25
Joined: Sat Mar 08, 2014 10:56 pm

Re: Playing .wav using aplay

Sun Mar 23, 2014 10:17 am

sorry all my fault, I was editing the wrong file. I need to keep an eye on what directory I'm working in.

Return to “Beginners”