Categories

  • Apple (15)
  • Coding (4)
  • del.icio.us (14)
  • General (136)
  • Life (10)
    • Remodel (1)
  • Politics (16)
  • Project Steamroller (1)
  • Spam (11)
  • Sysadmin (9)
  • Tech/Geek (15)
  • Uncategorized (52)

Ye Olde Posts

  • March 2010 (1)
  • January 2010 (3)
  • December 2009 (1)
  • November 2009 (1)
  • October 2009 (2)
  • September 2009 (1)
  • August 2009 (3)
  • July 2009 (3)
  • June 2009 (2)
  • May 2009 (2)
  • April 2009 (1)
  • March 2009 (4)
  • February 2009 (2)
  • January 2009 (1)
  • December 2008 (1)
  • September 2008 (1)
  • July 2008 (1)
  • May 2008 (5)
  • April 2008 (2)
  • March 2008 (9)
  • February 2008 (5)
  • January 2008 (6)
  • December 2007 (7)
  • November 2007 (2)
  • October 2007 (6)
  • August 2007 (7)
  • July 2007 (2)
  • June 2007 (3)
  • May 2007 (3)
  • April 2007 (8)
  • March 2007 (8)
  • February 2007 (10)
  • January 2007 (3)
  • December 2006 (2)
  • November 2006 (1)
  • October 2006 (2)
  • August 2006 (2)
  • July 2006 (2)
  • June 2006 (2)
  • May 2006 (5)
  • April 2006 (2)
  • February 2006 (1)
  • January 2006 (2)
  • December 2005 (2)
  • November 2005 (2)
  • October 2005 (3)
  • September 2005 (1)
  • August 2005 (1)
  • July 2005 (3)
  • June 2005 (3)
  • May 2005 (1)
  • April 2005 (1)
  • March 2005 (1)
  • February 2005 (4)
  • January 2005 (1)
  • December 2004 (3)
  • October 2004 (3)
  • July 2004 (1)
  • April 2004 (5)
  • March 2004 (5)
  • February 2004 (5)
  • January 2004 (3)
  • December 2003 (2)
  • November 2003 (9)
  • October 2003 (5)
  • September 2003 (4)
  • August 2003 (3)
  • July 2003 (2)
  • June 2003 (8)
  • May 2003 (5)
  • April 2003 (4)
  • March 2003 (10)
  • February 2003 (25)
  • January 2003 (12)

Vonage changes WAV format

Nov16
2005
Leave a Comment Written 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);
Posted in General
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail

No Comments Yet

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

*

*

CAPTCHA Image
Refresh Image

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" cssfile="">

Translate

EnglishFrenchGermanItalianPortugueseRussianSlovenianSpanish

Search

Recent Comments

  • Craig on On the efficiency of Virtual Machines
  • flickr.com/photos/jm on On the efficiency of Virtual Machines
  • jmason on Neat. A new way to track website visitors!
  • jmason on On the time domain, with regard to spam
  • pooya on Interesting Tivo trivia bit

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org

EvoLve theme by Blogatize  •  Powered by WordPress Craigalog
Craig's musings