Monday, 4 August 2008 @ 11:44am • earworm, icanhasaudio, life
Ben Bleything inspired me (or rather distracted me from my yak shaving) to get my music library cleaned up and remove duplicates. Unfortunately my duplicates don't necessarily have ID3 tags, and they may be in different formats, so I wrote a gem called "earworm" which will identify unknown music. First I'll give you a code sample, then explain how to get earworm working, and finally explain how earworm works.
Here is the code sample:
ew = Earworm::Client.new('MY Music DNS Key')
info = ew.identify(:file => '/home/aaron/unknown.wav')
puts "#{info.artist_name} - #{info.title}"
Earworm just needs a MusicDNS key and a file name to return information about your unknown audio.
Okay, now for getting the gem to work. Unfortunately this takes a little work right now. You need to install a few libraries before earworm will work. These libraries let you decode and identify mp3, ogg, and wav files.
For OS X (assuming you have MacPorts already installed) do this:
$ sudo port install libogg libvorbis lame libofa
For Linux:
$ sudo yum install libogg-devel libvorbis-devel lame-devel libofa
Then just install the gem like so:
$ sudo gem install earworm
The final thing you need is a key from MusicDNS which you can obtain here. The key is free for non-commercial applications. Now you should be set! Earworm will automatically decode mp3 files and ogg files for you, so you don't have to do that yourself.
How does earworm work? First, it relies on icanhasaudio for audio decoding. Second, it uses DL to wrap libofa. libofa takes between 10 and 135 seconds of audio and generates a hash. After getting the hash for the audio snippet, earworm posts the hash (along with your key and some other info) to MusicDNS's web service. The web services returns an XML document with information about the audio snippet. Earworm parses the XML document and returns a nice object containing the information you requested. Thats it! No magic, and very simple (IMO) source code.
Enjoy!
Posted by Aaron Patterson •
Permalink •
Comments (1) •
Leave your Comment »
Tuesday, 8 July 2008 @ 11:34am • life
I'm finally back home. I went to Japan a few weeks ago for vacation, and I also spoke at Ruby Kaigi 2008. Ruby Kaigi was so much fun! I've been studying Japanese for a little over a year, but I've never been to Japan. It was exciting and fun to talk to people, and I made a bunch of new Japanese friends. I'd really like to thank Leonard Chin for helping out at the Kaigi. My language skills aren't good enough, and he was kind enough to fill in the gaps. Thank you!
While I was in Japan, I noticed QR Codes everywhere. QR Codes are basically really awesome bar codes. They can hold much more information in a smaller amount of space. They can be easily decoded from images taken with digital cameras. They have these codes everywhere in Japan, and the idea is that people can take a photo with the camera on their cell phone, then the phone decodes the QR Code. I believe most of the QR codes contain information about the company, or possibly a URL to the company's website.
The company that created the format says that the format is open, but unfortunately I have to pay for the spec. I can download the spec in Japanese for free, but my Japanese isn't that good! So unfortunately I'm stuck with either the ISO spec (which is over $200) or the AIM spec ($85). I don't understand why they are so expensive..... I think I'll buy the AIM one, and hope that it is the same as the ISO one.
Posted by Aaron Patterson •
Permalink •
Comments (2) •
Leave your Comment »
Saturday, 15 March 2008 @ 10:19am • life
The Mechanize library is used for automating interaction with websites.
Mechanize automatically stores and sends cookies, follows redirects,
can follow links, and submit forms. Form fields can be populated and
submitted. Mechanize also keeps track of the sites that you have visited as
a history.
Changes:
# Mechanize CHANGELOG
## 0.7.5
Posted by Aaron Patterson •
Permalink •
Comments (0) •
Leave your Comment »
Tuesday, 4 March 2008 @ 8:42pm • life
The Mechanize library is used for automating interaction with websites.
Mechanize automatically stores and sends cookies, follows redirects,
can follow links, and submit forms. Form fields can be populated and
submitted. Mechanize also keeps track of the sites that you have visited as
a history.
Changes:
# Mechanize CHANGELOG
## 0.7.1
Posted by Aaron Patterson •
Permalink •
Comments (1) •
Leave your Comment »
Friday, 22 February 2008 @ 11:27pm • betabrite, life
I signed up my BetaBrite for a twitter account. Now I'm getting twitter messages in my living room. Yay! Leave a comment, or follow me on twitter so I can get your messages on my sign. I think next I will try to wire up a webcam to automagically take pictures.
Anyway, here is the code:
twitter = Twitter::Base.
new('betabrite', '%%%%%%%%'
)
seen = {}
DATA.each_line { |l| seen[l.chomp] = true }
twit = nil
twitter.timeline(:friends).each do |tweet|
next if seen[tweet.id]
twit = tweet
end
if twit
File.open(__FILE__, 'a') { |db| db.puts(twit.id) }
puts "#{twit.text} (#{twit.user.name})"
bb = BetaBrite::USB.new { |sign|
sign.stringfile('0') do
print string("#{twit.text}")
end
sign.stringfile('1') do
print string("(#{twit.user.name})").red
end
}.write!
end
__END__
My favorite part is that I use the script for its own database. It keeps appending twitter ids it has seen to the end of the file.
Posted by Aaron Patterson •
Permalink •
Comments (5) •
Leave your Comment »
Friday, 15 February 2008 @ 7:32pm • life
Provides a Ruby interface to BetaBrite LED signs.
Changes:
### 1.0.1
Posted by Aaron Patterson •
Permalink •
Comments (1) •
Leave your Comment »
Friday, 15 February 2008 @ 7:16pm • life
Hai! icanhasaudio? is an interface to lame for decoding ur MP3s. I iz in ur
computer. Decodin ur mp3s. Whatevs! I also decodin ur OGGz! I kin also
encodin' ur WAV and AIFF to mp3z!
## SYNOPSYS ROFLOL
require 'icanhasaudio'
reader = Audio::MPEG::Decoder.new
File.open(ARGV[0], 'rb') { |input_lol|
File.open(ARGV[1], 'wb') { |output_lol|
reader.decode(input_lol, output_lol)
}
}
Changes:
### 0.1.0
Posted by Aaron Patterson •
Permalink •
Comments (0) •
Leave your Comment »
Friday, 15 February 2008 @ 3:25pm • life
Last week I bought my plane tickets to Japan! I'm leaving June 18th, and returning July 5th. I'll be there in time for the Japanese Ruby Conference. I submitted a talk proposal on RKelly, and hopefully that will get accepted. I know I'm going to be staying in Tokyo for a while, but I'm not sure where else I'll travel. I'd like to go to Kyoto because it looks very interesting. I'm most excited about getting to visit Daisuke, and speaking Japanese. I'm trying hard to hone my language skillz before I go so that I can communicate!
One thing I've noticed about the Japanese language that differs from English and kind of annoys me is the timing of words in sentences. In English when I quote someone, the listener knows much sooner that it is a quote than in Japanese. For example:
Pam said "blah blah".
In Japanese:
Pam は blah blah と言っていました。
You don't know until the end of the sentence that "blah blah" is what Pam said. If you died or something before the end of that sentence, the listener wouldn't know it was a quote! There might be ways to get around that, but I don't know them yet......
Posted by Aaron Patterson •
Permalink •
Comments (1) •
Leave your Comment »
Monday, 11 February 2008 @ 9:03pm • life
Provides a Ruby interface to BetaBrite LED signs.
Changes:
### 1.0.0
Posted by Aaron Patterson •
Permalink •
Comments (0) •
Leave your Comment »
Tuesday, 15 January 2008 @ 12:00am • life
The Mechanize library is used for automating interaction with websites.
Mechanize automatically stores and sends cookies, follows redirects,
can follow links, and submit forms. Form fields can be populated and
submitted. Mechanize also keeps track of the sites that you have visited as
a history.
Changes:
# Mechanize CHANGELOG
## 0.7.0
Posted by Aaron Patterson •
Permalink •
Comments (0) •
Leave your Comment »