Decode MP3s with Ruby

Posted by – September 21, 2007

Here is an example of decoding mp3s using ruby. First make sure to install icanhasaudio. It should just be a “gem install icanhasaudio”. Here is the code:

require 'rubygems'
require 'icanhasaudio'

reader = Audio::MPEG::Decoder.new
reader.decode(File.open(ARGV[0], 'rb'), $stdout)

icanhasaudio just takes two IO streams, an input and an output. In our case the input is the file provided on the command line, and the output is STDOUT. To use the script, simply do:


$ ruby decoder.rb phil_collins.mp3 > phil_collins.wav
[/sourcecode]

1 Comment on Decode MP3s with Ruby

Respond

  1. jax says:

    su su sudeo energy drink!

Respond

Comments

Comments