11.16.05

Vonage changes WAV format

Posted in General at 2:06 pm by Craig

Looks like Vonage changes the format of the WAV files they send for voicemail-by-email, so that the WAV is now encoded as U-law instead of linear PCM. And of course lame doesn’t know how to read a ulaw encoded WAV file, tries to assume that it’s linearly encoded, and so my WAV->MP3 email converter script doesn’t work right any more. So I’ve updated it, and broken it into two pieces. The perl script, which rips up the MIME to extract the WAV, and then a second script which that one calls out to, which does the WAV->MP3 transformation by calling sox to convert from ulaw to linear PCM, then lame to do the MP3 encoding. I’m still using lame instead of sox to do the encoding, because frankly the MP3 sounds way way better using lame. Here are the files. Shell script:

#!/bin/bash
/usr/bin/sox $1 -t wav -s -w - | /usr/bin/lame --preset phone -v -q 0 -V 9 --quiet - $2
Perl Script:

#!/usr/bin/perl

use MIME::Parser;

$p = new MIME::Parser;
$p->output_to_core(1);
$e = $p->parse( \*STDIN );
$w = "/tmp/$$.wav";
$f = "/tmp/$$.mp3";
open( PIPE, ">$w" );
print PIPE $e->parts(1)->bodyhandle->as_string;
close PIPE;
system("/usr/local/bin/voicemail-compressor.sh",$w,$f);
open( PIPE, "<:bytes", $f );
{
    local $/;
    $mp3 = <PIPE>;
}
close PIPE;
$fh = $e->parts(1)->bodyhandle->open("w");
$fh->print($mp3);
$fh->close;
$e->parts(1)->head->replace( "Content-type", "audio/mpeg" );
$e->parts(1)->head->mime_attr( "content-type.name" => "voice-mail.mp3" );
$e->parts(0)->bodyhandle->as_string =~ /^From: (.*)/m and $callerid = $1
  or $callerid = "Unknown";
$b =
  $e->head->replace( "From",  ""$callerid" <voicemail\@hughes-family.org>" );
$e->head->replace( "Subject", "Voicemail from $callerid" );
$e->head->replace( "X-Mailer", "VoicemailToMP3" );
$e->sync_headers( Length => "COMPUTE" );

open(PIPE, "|/usr/sbin/sendmail -i -f $ARGV[0] $ARGV[1]");
$e->print(PIPE);
close PIPE;
unlink($f);unlink($w);

11.01.05

Stanford Stadium Re-design

Posted in General at 11:14 am by Craig

So I get a questionnaire for alums on the new Stanford Stadium design. One question asks:
  • Where should your seat be relative to the student section?
With answer options:
  • Next to them
  • Where I could see them from across the field
  • As far away as possible
Now is anyone else wondering, if there’s a difference between the 2nd and 3rd options, how many dimensions this new stadium is to be constructed in?