Audio recording on the web

One of the things I want to include in Memoratiā„¢, is the ability to record audio snippets to attach to flash cards. I've been thinking about this for a long time now. There are basically two parts to the problem:

  1. Getting permission to record from the clients microphone.
  2. Encoding the audio so it is small enough to send over the network.

I had been considering Flash, Java or Silverlight 2.0 for this. It was actually the recent Silverlight 2.0 beta (and a certain co-workers enthusiasm for it) that got this back to the front of my brain. I had figured that it might be easier to port an audio encoder from C to C# or Python, rather than to Java or ActionScript.

But alas! Things seem to have shifted in favor of Java because then I wouldn't have to write any encoder! On Friday, I discovered this pure Java port of the Ogg Vorbis reference implementation:

It currently doesn't support decoding, but there is another pure Java package that does:

This leaves the question of getting permission to record in an applet. Over the weekend I was able to get the answering machine example on JSResources to work on my local machine. This uses the Trintonus plugins for encoding, which depend on native libraries that I had to install manually into my JRE. However, using vorbis-java would eliminate this requirement.

Getting permission to record audio in a Java Applet can be done in one of two ways:

  • Getting your applet signed. I haven't look too deep into this, but it involves the exchange of currency. Depending on how much this costs I definitely would consider this for Memorati.
  • Or! Placing the following 3-lines into a text file in your home directory (for the Windows folks, this is your users "Documents and Settings" folder) called .java.policy:

grant {
permission javax.sound.sampled.AudioPermission "record";

Not bad! Definitely acceptable for getting this off the ground.

I'm pretty excited. It requires only a minimal investment from me, just connecting the various Open Source bits that are already out there. I'll get a working prototype some time after I get the website for the The Lingwo Project online.