Sponsored Content
Full Discussion: Play sound
Top Forums Shell Programming and Scripting Play sound Post 302787121 by tukuyomi on Thursday 28th of March 2013 04:53:59 PM
Old 03-28-2013
Quite the same solution as Corona688; uses aplay to play wav files:
Code:
#!/bin/sh

while read line; do
	set -- $line
	while [ "$1" ]; do
		echo aplay "$1.wav" # remove echo to actually let aplay play the wav file
		shift
	done
done

exit 0

Example usage: ~/unix.com$ echo input_file | sh the_above_script.sh

Code:
~/unix.com$ cat input_file
one four five
two
three

~/unix.com$ cat input_file | sh the_above_script.sh 
aplay one.wav
aplay four.wav
aplay five.wav
aplay two.wav
aplay three.wav

Of course, remove the echo that prevent the aplay to do its job Smilie
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

play cd? how?

hi all, How do I set up my cdrom to play some regular audio cd (not cd-r or cd-rw). I know that my cdrom has been mounted as it does pop up the file manager if I put in, e.g., the office52 cd. Thanks in advance. Andre (3 Replies)
Discussion started by: andrec
3 Replies

2. UNIX for Advanced & Expert Users

Need something new to play with

I posted this question in the dummies forums, but I would like to get a more expert opinion... I am looking for a new OS to play with. I have a celron 450 running slackware linux, a powermac G4 450 running Mac OS X (Which by the way has 81 days of uptime as of this moment), a PowerBook G3 running... (5 Replies)
Discussion started by: dewhite04
5 Replies

3. UNIX for Dummies Questions & Answers

How Can I Play A Cd On Unix

HI I AM A FRESH NEW USER ...I MEAN I JUST GOT A COMPUTER ALMOST FOR FREE AND IT RUNS UNIX WHICH I DIDN'T EXPECT AND DONT KNOW HOW TO WORK ON IT I THOUGHT IT'LL BE WITH WINDOWS ..YOU KNOW SO HOW DO I PLAY A CD IN IT. REMEMBER I KNOW NOTHING ABOUT UNIX , BUT I THINK I'LL GET OVER IT... (1 Reply)
Discussion started by: IMOTEB
1 Replies

4. UNIX for Advanced & Expert Users

play

dear friends, i have linux system . can i play songs in linux system. like winamp player in windows. let me know. (2 Replies)
Discussion started by: rajan_ka1
2 Replies

5. Linux

how can i play the gam

can some1 tell me how to start playing? (2 Replies)
Discussion started by: 123456
2 Replies

6. Linux

Can not play sound in Linux RHEL5.

Hi All, Recently I installed Linux RHEL5 on my machine. It seems that I can not play sound on RHEL5. I have real player installed along with RHEL5 but, when I try to play any song, the error message comes up saying "Can not open the audio device.Another application may be using it." Does any... (2 Replies)
Discussion started by: gydave
2 Replies

7. Slackware

Can't play sound files with aplay or cat to /dev/dsp

I am having problems using soundes. Until a few moments ago the following commands produced errors and no sound: cat /usr/share/apps/kolf/sounds/blackhole.wav/ > /dev/dsp yielded: /dev/dsp: Invalid argument cat /usr/share/apps/kolf/sounds/blackhole.wav > /dev/audio yelded: /dev/audio:... (3 Replies)
Discussion started by: slak0
3 Replies

8. Shell Programming and Scripting

Making a play-list

approximately the same question as the last time, but unfortunately I didn't get a working answer. I made a script with bash and gtkdialog that create a play-list. The output is for example : gtk-media-pause | CB60471-05 - Gilbert, Brantley - Country Must Be Country Wide.zip | 28897 |... (3 Replies)
Discussion started by: jkfloris
3 Replies
MAILSOUND(1)						      General Commands Manual						      MAILSOUND(1)

NAME
mailsound - play sounds when mail is received SYNOPSIS
mailsound [-hszZvrd] soundname ... DESCRIPTION
mailsound allows a user to play sounds when new mail arrives. It reads a mail message from stdin and uses Mark Boyns' rplay library to play sounds. The sound that is played is determined by a configuration file in the user's home directory called .mailsounds. Each line in this file has two parts. The first part is a regular expression which will be used to match the from address from a mail message. The second part describes what to do when a match is found. The options in the second part are identical to the options on the command line. The command line options will set defaults which will be used if they are not specified in the configuration file. If not specified, the mailsound program will use the following defaults: default sound: youvegotmail.au default volume: 127 (50%) If the mail address does not match any of the regular expressions in the .mailsounds file, no sound will be played. OPTIONS
-h hostname:[hostname...] Play sounds on all of these hosts. -z <minsize>:<minvolume>,<maxsize>:<maxvolume> The volume the sound will be played at will be determined by the size of the mail message. The sound for a message with a size smaller than <minsize> will be played at volume <minvolume>. The sound for a message with a size larger than <maxsize> will be played at volume <maxvolume>. The sound for a message with a size between <minsize> and <maxsize> will be played at a volume which is a linear interpolation between <minvolume> and <maxvolume>. -Z <minsize>,<maxsize> The sound to be played is determined by the size of the mail message. If the message is smaller than <minsize>, the first listed sound is played. If the message is larger than <maxsize>, the last listed sound is played. If the message size is between those two values, the appropriate sound from the list is played. -s <subject re> The regular expression supplied will have to match the subject of the message. If this option is not there, the subject of the mes- sage is completely ignored. Be careful that the regular expression does not contain spaces. Due to laziness of the author of this program, this will hopelessly confuse the program. -v <int> Set the volume at which the sound should be played. The range is 0-255. -r Pick a sound at random from the list of sounds provided. -d Turn on debugging. This will produce diagnostic output to stdout. EXAMPLE
The following could appear in the .forward file in your home directory: (This assumes that your username is pickard) pickard, |"/usr/local/bin/mailsound" Here is a sample $HOME/.mailsounds file: Andrew.* -r Passing_Train riot arrp flinstones root.* out! daemon.* -v 220 sci_fi_fun MAILER.* -S 1000,10000 cuckoo pig Oomph *. pigs FILES
$HOME/.mailsounds SEE ALSO
rplay.conf(5), rplayd(1) AUTHOR
This program was written by Andrew Scherpbier at San Diego State University. He can be reached by E-mail as follows: Andrew@SDSU.Edu The mailsound program makes use of Mark Boyns' rplay package which can play multiple sounds on remote machines. He can be reached by E-mail as follows: boyns@sdsu.edu BUGS
The code does very little error checking. No range checking on any of the values is done. 11 August 1993 MAILSOUND(1)
All times are GMT -4. The time now is 01:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy