Vim, Ruby, and Family History
On the side, I’m an aspiring amateur genealogist and family history researcher. My latest “thing” is to record my grandparents talking about their childhood, and then transcribe the recording and organize it into a book format. To that end, I’ve got an hour and a half of audio in OGG format of my grandfather telling about his childhood, his experiences in WWII, and so forth.
My wife, who worked as a personal history transcriber in college, has a transcribing machine. It’s like a bulky tape recorder, with doodads for speeding up or slowing down the playback, and for jumping backwards a few secodns in the recording. Also, when you pause the recording and start it again, it automatically jumps back a few seconds. These features are essential for transcribing audio.
Thus, given the OGG recording of my grandfather’s history, I have been looking for a program that has the features of a mechanical transcriber, especially for linux. The few programs that seemed to come close were either ugly as sin and not very stable, or had no support for OGG files. (True, I could always just convert the OGG file to something else, but I wanted to make the process as painless as possible.)
I then experimented withing using the Ruby bindings to GStreamer, to write my own transcribing program. It almost worked, but the problem I had with GStreamer was that it is buffered, for streaming audio, which means it doesn’t behave very responsively when I want to pause or fast-forward. (That was my experience, anyway.)
So I went looking elsewhere. I had heard of the FMOD library, but couldn’t find any Ruby bindings for it. I wasn’t particularly in the mood for writing the bindings myself, in C…but wait! I wondered if the DL module in Ruby could help me…
The DL module allows scripts to access C functions directly, without intervening glue code. It turned out to be ridiculously simple to write a Ruby module that calls into the FMOD routines via Ruby/DL.
So I took the Simple Audio Player demo from the Ruby/Gnome2 project and reworked it so that it used my FMOD layer instead of GStreamer. Then I added a slider to manipulate the playback rate, and made the “pause” button also rewind the audio a few seconds. Voila! A transcriber program!
Now, the problem was that there was no convenient way to manipulate my transcriber via Vim, my editor of choice.
I sat down and hacked some named pipe support into it. This allowed me to write a Vim plugin (in Ruby, naturally) that communicated with the transcriber over the named pipes, sending commands and receiving responses. Then I mapped the plugin’s commands to some convenient keys, and away I went. It worked flawlessly.
I wanted to share this contraption I had devised, but the setup was rather horrendous. You had to have GTK2 installed, and due to the dependency on named pipes, it would only work on Unix-like systems.
However, if I could write Vim plugins in Ruby, why couldn’t I write the entire transcribing system as a Vim plugin? Then the only dependencies would be FMOD, and a Vim that was compiled with Ruby support.
It turned out to be very simple to convert. I now simply load a file to transcribe with the
:VSLoad command, start it playing with
:VSPlay, toggle the pause with
ctrl-space, speed it up with
alt-rightarrow, and so forth. (I’ll probably register a RubyForge project soon, to host this and a few other genealogical utilities I’ve written.)
Meanwhile, I’ve got about 14 minutes of my grandpa’s 90 minute narration transcribed. A few more weekends should see the transcribing completed!
30 May 2006