User Tools

Site Tools


voip:create_moh_files

This is an old revision of the document!


Quick script I wrote to convert .mp3 files to .wav

Example: “ArtistGuy - SongTitle.mp3” will be converted to:
8000_ArtistGuy_-_SongTitle.wav
16000_ArtistGuy_-_SongTitle.wav
32000_ArtistGuy_-_SongTitle.wav
48000_ArtistGuy_-_SongTitle.wav

So, HZ is added and space is converted to underscore.

convertsongs.sh
#!/bin/bash
IFSORG=$IFS
BITRATES="8000 16000 32000 48000"
IFS=$'\n';
for x in `ls *.mp3`; do
# Convert the name to something FS can use
	SONGNAME=`echo $x | tr " " _ | sed 's/\.mp3/\.wav/'`

# Now convert 'em songs!
	echo "Converting $x:";
	IFS=$IFSORG;
	for y in $BITRATES; do
		echo -n "$y Hz.. ";
		mpg123 -q -s -f 8192 --mono -r $y -w "${y}_$SONGNAME" "$x"
	done
	echo "";
	IFS=$'\n';
done
IFS=$IFSORG

echo "Done converting."
voip/create_moh_files.1392214215.txt.gz · Last modified: 2015/08/15 22:56 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki