I've programmed personal computers ever since my first Radio Shack TRS-80 Model I back in 1976. I got my first Apple II a year later, and have stayed in the Apple fold ever since. Since 1976, I've programmed in Basic, Fortran, assembly language, several machine languages, Pascal, Python, S, R, C, Perl and a few others.
For the past few years, I've been closely eyeing Ruby, a relatively new language, but haven't had the right incentive to dive into it. However, there's nothing like building a cool, new project to learn a new language.
I've spent much of my academic time in the past two weeks writing a web-based text-to-speech application in Ruby. My goal: type in the volume, issue and page number of some article in a major radiology journal and get back an .mp3 version of that article, read by a fairly decent computerized voice.
It turned out to be a lot easier than I thought it would be, even with a few years of web-apps under my belt. Ruby is a fine language, with a fine library of built-in tools, making it easy to scrape a whole web page with just a few lines of Ruby code. For example, the following code is all that's necessary to grab a whole article from the American Journal of Roentgenology and assign it to the variable ajr_html:
I have recently become a big fan of text-to-speech conversion. In December, I discovered a new Mac program called Textcast. Since then, I've used Textcast to make one or two hundred podcasts for my iPhone from NY Times articles and various blogs I follow. These have been a major defense against boredom during my work commutes -- sort of like having an NPR station where all the stories are interesting.urlRaw = "http://www.ajronline.org/cgi/content/full/"
+ ajrVolume +"/" + ajrIssue + "/" + ajrPage
ajr_url = open(urlRaw)
ajr_html = ajr_url.read
The only issue I have with Textcast is that it is optimized only for pages from Safari or NetNewsWire. If I want to use it to grab and convert an article from AJR or Radiology, I need to first do some serious hand-scrubbing of the text from their websites before I can feed it into Textcast. I got pretty tired of this after laundering a few articles by hand. My new Ruby script takes virtually all of the drudgery out of this process.
Now that I've refined my program into a reasonably stable version, I've asked several of my residents, fellows and fellow faculty to do some alpha testing. Once I get their feedback, I'll write it up for one of our radiology journals. Might as well get some academic mileage out of it.