dotfiles/bin/wav2alaw
Jacob Kiers bfa37857c6 Added bin/wav2alaw
Signed-off-by: Jacob Kiers <jacob@alphacomm.nl>
2014-05-07 07:53:02 +02:00

27 lines
516 B
Bash
Executable File

#!/bin/bash
# Converts all wav-files in a directory to alaw.
if [[ -z "$1" ]]; then
DIR='.'
else
if [ ! -d "$1" ]; then
echo "Directory does not exist!"
exit
else
DIR=$1
fi
fi
cd $DIR
for f in `ls -1 *.wav | sed 's/\.[^.]*$//' | sort -n`; do
echo "Converting $f.wav to $f.alaw..."
`sox $f.wav --channels 1 --encoding a-law --rate 8000 --type raw $f.alaw.wav`
if [ $? -eq 0 ]; then
`mv $f.alaw.wav $f.alaw`
`rm $f.wav`
fi
done
echo "Done."