- LOL: The Life of Leo - http://leoville.com -

They Might Be Finished!

Posted By Leo On December 14, 2003 @ 9:33 pm In Blog | No Comments

I‘ve been working here and there on setting up a Linux based Dial-A-Song answering machine for They Might Be Giants. I promised it to them in April, really buckled down in October, and I’m finally (almost) done today. If you want to follow the saga read my previous posts explaining the project [1] and detailing some of the issues [2].

I did finally find a voice modem that works with vgetty – an old US Robotics external Voice/Fax/Data modem. After some trial and error I discovered that if I resampled the MP3s to 16-bit, 8Khz, mono sound files they’d work with the modem. It was such a thrill to dial up and hear a TMBG song on the other end.

The basics of the shell script follow – minus the extensive error checking code. If an error occurs anywhere (no CD, can’t read the disc, etc.), the script falls back to a default message stored on the hard drive.


#! /bin/bash
# -----------------------------------------------------------
# newsong - Leo Laporte, April-December 2003
# -----------------------------------------------------------
# this shell script is designed to be run hourly by cron
# it pulls a random MP3 off a CD in drive, combines it with the
# outgoing message (message.mp3) on the same disc, then
# converts it to the appropriate RMD format and moves it
# into the outgoing message directory for vgetty
#
# requires:
# pickrandom - a perl script to pick a random song
# SoX for the MP3 to WAV conversion
# vgetty's PVF utilities to convert the WAV to RMD
#
# Written for They Might Be Giants Dial-A-Song
# -----------------------------------------------------------

cd /var/spool/voice/work/
touch /var/spool/voice/work/startrun

# mount CD
mount /dev/cdrom /mnt/cdrom
ls /mnt/cdrom/*.mp3 >/var/spool/voice/work/files

# call an external perl script to select a random title from files
tune=$(/var/spool/voice/work/pickrandom)
echo "$tune" >currentsong.txt
cp -f "$tune" tune.mp3
cp -f /mnt/cdrom/*message.mp3 message.mp3

# convert the MP3s to raw audio (signed, 16-bit, 8khz, mono)...
sox -V tune.mp3 -s -w -r 8000 -c 1 tune.raw
sox -V message.mp3 -s -w -r 8000 -c 1 message.raw

# combine the raw files...
cat message.raw >>tune.raw

# convert to RMD via SoX and PVF tools...
sox -V -s -w -r 8000 -c 1 tune.raw -s -w -r 8000 -c 1 standard.wav
wavtopvf -16 standard.wav standard.pvf
pvftormd US_Robotics 1 standard.pvf standard.rmd

# copy converted file to messages directory...
mv -f standard.rmd /var/spool/voice/messages/standard.rmd

touch /var/spool/voice/work/endrun

The little randomizing perl script:


#!/usr/bin/perl
# picks a random song from the file list
my $tune;
open(TUNES, "files") or die 1;
srand;
do {
rand($.) < 1 && ($tune = $_) while ;
} until $tune !=~ /message.mp3/i ;
print $tune;
exit 0;

A cron job will run the script hourly. I’ve been running it every ten minutes for several days and it’s been working without a hitch. (Here’s a cool little cron feature I’ve not used before. If you define a MAILTO environment variable in the crontab, cron will mail the output of each job to that address every time it runs. I’ve added MAILTO=root to the crontab, and now I can use pine to check the results of each run. Very handy for checking up on problems after the fact. )

Since this is a headless machine I’m planning to add audio error messages using pre-recorded WAVs on the hard drive. That way John can tell how the thing is working just by turning up the speaker.

We’re ordering the parts and plan to build the machine this week. I’m going to put it in a small case [3] with a Celeron, small hard drive, and 256MB RAM. It’ll probably run SuSE Linux – my current favorite. Total cost well under $500. I’ll set it up so that I can SSH into the box if something goes wrong, but it won’t normally be connected to the network.

John and John live in Brooklyn so Joshua Brentano and I are hoping to fly out and deliver this to them for Christmas. With any luck it will run without maintenance for years.


Loading Facebook Comments ...

No Responses to “They Might Be Finished!”

  1. Anonymous on December 14th, 2003 9:58 pm

    Woohoo! Congrats, Leo! :)

  2. Anonymous on December 15th, 2003 1:06 am

    Good job on such a big project!

  3. Anonymous on December 15th, 2003 1:21 am

    Awesome! Sounds like a really challenging project – impressive.

  4. Anonymous on December 15th, 2003 8:03 am

    Congrats Leo! I await the chance to call it.

  5. Anonymous on December 15th, 2003 6:05 pm

    I can’t wait to call up TMBG’s dial-a-song number soon and know that your hard work is on the other end. Way to go Leo! You’ve made TMBG history!!!

  6. Anonymous on December 16th, 2003 12:31 am

    Good work. You went with a US Robotics modem? What version? If you ever need a replacement, I can strip the ISA one out of my old P2 233.

  7. Anonymous on December 16th, 2003 6:05 am

    I was wondering could you post an image of the drive so that if we want to set one up we can just blast it up on a drive and have it going in minutes. Asssumeing we meet the hardwear specs of vgetty.

  8. Anonymous on December 16th, 2003 12:27 pm

    That’s awesome. Not a big fan of the ‘Giants’ but if I’m not totally mistaken Modest Mouse had something similar wherein you could dial up a phone number and listen to whatever new songs they had been working on, albeit with horrible quality. Who knows, Leo? Maybe you’ll be making more of these things should the demand arise.

  9. Anonymous on December 28th, 2003 8:51 am

    Leo, I was wondering if the issue of cooling has been addressed. If I remember correctly, the biggest problem with the last computer setup that ran Dial-a-Song was that the Johns’ Brooklyn apartment that is the home to the infamous phone number was not air conditioned and would periodically break down through the hotter months of the year. Has this been discussed? I’m not sure how cost effective it would be to cool the entire apartment just for dial-a-song, perhaps liquid cooling is the answer? Or maybe They could move the phone number to a location that already has climate control. What do you think?

    -Mike Levy

    http://www.theymightbegiants.org

Feel free to leave a comment...
and oh, if you want a pic to show with your comment, go get a gravatar!





Article printed from LOL: The Life of Leo: http://leoville.com

URL to article: http://leoville.com/they_might_be_finished

URLs in this post:

[1] explaining the project: http://leo.typepad.com/tsn/2003/10/dialasong_diary.html

[2] detailing some of the issues: http://leo.typepad.com/tsn/2003/10/tmbg_day_4.html

[3] small case: http://www.centralcomputer.com/emerchant/itemdetail.asp?item=SYSAMSEG65DR