bv2iphone.sh

Well, the problem was that as part of the 1.0 release of the iPhone firmware, WAV files could only be played if they were in the proper format. The issues that I had was that Broadvoice would send a nicely compressed WAV file to me whenever someone left a voicemail. This is convenient and worked great in Gmail. However, on the iPhone, I wanted to be able to play the voicemail while on the go. This script (and the helpful open-source utilities it uses) was the solution. I know I stole most of this from elsewhere on the Internet but in this case I forgot to document.

#!/bin/bash
 
if ! TEMPDIR="`mktemp /tmp/sendwav.XXXXXX`"; then
echo "$0 is unable to create the temporary file."
exit 1
fi
 
# not perfect, but, we'll live
rm $TEMPDIR
mkdir $TEMPDIR
 
mkdir -p $TEMPDIR/source
 
touch $TEMPDIR/pre
 
#absorbs stdin
munpack -C $TEMPDIR/source
 
touch $TEMPDIR/post
 
#convert to GSM
sox $TEMPDIR/source/*.[Ww][Aa][Vv] -r 8000 -c 1 -u $TEMPDIR/voicemail.wav
 
cat $TEMPDIR/source/voice-message.desc | mutt -a $TEMPDIR/voicemail.wav -s "New Voicemail" andrew.flanagan+iphone@gmail.com
 
rm -fr $TEMPDIR
  1. No comments yet.
(will not be published)