Friday, April 10, 2009

Phoning it Home.

I have a Samsung SGH-A707 cell phone. It's nothing amazing, but it has a few features that I like.

One of them is voice memo. I can hit a button and record a quick message on my phone. Later, using Samsung's crappy PC Studio, I can pull the sound files off my phone and onto my Windows box. From there it's a hop, skip and a Samba on to my beloved Linux box.

The problem I have is that the files are in a format called ".amr". Oy! God forbid they use something standard.

Fortunately it's not too hard to convert them to a format that the "sox" command can understand. From there you can go to .wav, .mp3 or .ogg.

First, get the sound file from your phone to your Linux box. I can't get the bitpim program to work on my Red Hat box so I go via Windows.

Once you have the file, I'll call it "foo.amr", on to your Linux box, use the program "amrnb-decoder" to convert it to raw format.

amrnb-decoder was already on my Red Hat box. You may have to hunt around for it.

Decode the file with:

amrnb-decoder foo.amr foo.raw

This produces a raw, signed, 2 byte word, audio file at 8000 hertz.

Convert it to an ogg file with:

sox -r 8000 -s -w foo.raw foo.ogg

You should be good to go. If you change foo.ogg to foo.wav you'll get a wave file. Creating an mp3 is left as an exorcise for the reader.

You can simplify this a little bit by naming the raw file "foo.sw". Sox sees files that end with ".sw" as being short hand for "raw, signed word" files so you don't have to include that info on the command line.

You could do the above as:

amrnb-decoder foo.amr foo.sw
sox -r 8000 foo.sw foo.ogg

If the volume of the final .ogg file is too low, use sox to increase it:

amrnb-decoder foo.amr foo.sw
sox -v 7 -r 8000 foo.sw foo.ogg

For some reason all the other instructions sets I've seen have had dumb little typos in them. Let me know if you find any here.

1 comment:

Hans said...

Thanks, your article helped me in trying to offload audio from a similar phone.

FWIW, my sox command line was:

sox -r 8000 -b 16 -c 1 -e signed-integer "$raw" "$wav"

Your command line option "-w" was not recognized by my version of sox.