Wikipedia Reader

Summary: My “Wikipedia Reader” application reads Wikipedia pages to you. The current release is a very rough Version 0.1 (alpha) release. What’s new: 1) It works. 2) It’s packaged as a Mac OS X application. 3) It supports the use of multiple reading voices.

Update: I’ll get a new build out this weekend that eliminates the bugs shown in the video.

In my spare time I’ve been working on an application I call a “Wikipedia Reader” (or Wikipedia Page Reader). As its name implies, it reads Wikipedia pages and speaks the page content to you. The functionality is shown in this 112-second video:

About the Wikipedia Reader

I wrote the Reader using the Scala programming language and Akka actors (remote actors, to be specific). It runs on Mac OS X 10.9, and probably works on 10.7 and 10.8 as well.

It does everything you see, including downloading the Wikipedia page, cleaning up the text, and then reading it, with pauses between the sentences and paragraphs, and the ability to read the text in one voice, or multiple voices.

Caution

This is very much an “Alpha” release of this application. If you (a) type in the names of correct voices in the Voices panel, (b) drag articles to the URLs field, (c) select an article, and then (d) click the Play VCR button, everything should work ... at least it works on my two Mac OS X 10.9 systems.

Other features, like the Close, Minimize, and Maximize buttons in the upper-left corner of the application window don’t work yet. To quit the application, use the [Command][Q] keystroke, or select the Quit option from the menu.

Also, your voice selections are only currently remembered when you (a) enter your voices and then (b) press the VCR “Play” button. Your voices are saved when you press Play (and only then, right now).

If you type in the name of invalid voices, leave voice fields blank, drag other URLs to the URLs field, or do other things I haven’t tested, well, I have no idea what will happen.

Download

The Wikipedia Reader is available for free under the terms of the GNU GPL License. By downloading the application you agree to the terms of that license.

You can download the Wikipedia Reader from this link:

Just download that file, then double-click it. This will display the Wikipedia Reader application icon. I didn’t go through the process of “signing” the application, so to run the application the first time, follow these steps:

  1. Right-click the Wikipedia Reader icon
  2. Select “Open”
  3. When OS X warns you that I didn’t sign the application, click the “Okay” button

When the Reader starts, it will speak something like, “The Wikipedia Reader is alive.”

Adding Wikipedia URLs

To add Wikipedia URLs to the Reader:

  1. Open a browser
  2. Navigate to a Wikipedia page you want to listen to, then
  3. Drag the URL from the browser and drop it into the “URLs” area of the main panel. You should see the URL appear there.

Selecting a Voice

The Mac has a great “text to voice” feature that I use in this application. I think all Macs come with the “Alex” voice, so you might want to try that first just to make sure everything is working okay.

Once that’s working, you can see what other voices you have on your system by following these steps:

  1. Click the Apple icon in your Mac menu bar
  2. Click “System Preferences”
  3. When that dialog comes up, click the “Dictation & Speech” icon (it’s on the 4th row)
  4. On that panel, click the “Text to Speech” tab
  5. Now look at the voices that are available in the “System Voice” drop-down list

You can use any voice you see there in the Wikipedia Reader. For instance, you should see a voice named Samantha. To use this voice in the Wikipedia Reader, just go back to the Reader, type Samantha in the “Use One Voice” textfield, make sure that radio button is selected, then go back to the Main tab, select an article, and click the Play button. You should hear the article read in the Samantha voice.

Using Multiple Voices

To use multiple voices, just type the voices you want to hear in the “Alternate Voices” textarea. Put one voice on each line. Like before, you can use any voice you see listed in the System Preferences “Text to Speech” tab.

At the current moment, the Wikipedia Reader uses a different voice for each sentence when this option is chosen, but in a future release it will alternate voices for each paragraph. (Either that, or I’ll have an option to let you choose which you prefer.)

Source code

The source code isn’t great -- I’ve only had a little spare time to work on this -- but you can now find it on Github:

Here’s a little look at the Akka Actor code that actually does the speaking. As you can see, it’s remarkably simple:

package com.alvinalexander.wikipediareader.server

import akka.actor._
import com.alvinalexander.wikipediareader.common.SpeakSentence

/**
 * This `Server` class starts the server process.
 * Pretty much all it does is start the `SentenceSpeaker` actor.
 */
object Server extends App  {

    val system = ActorSystem("WikipediaReaderServerSystem")
    val sentenceSpeaker = system.actorOf(Props[SentenceSpeaker], name = "SentenceSpeaker")
    sentenceSpeaker ! "The speaker is alive"

}

/**
 * The purpose of this class is simply to speak the sentence it is given,
 * with the voice it is given. After the sentence is spoken, it sends a message
 * back to its caller, telling the caller that it finished speaking the text.
 */
class SentenceSpeaker extends Actor {
    var client: ActorRef = _
    def receive = {
      case SpeakSentence(sentence, voice) =>
          client = sender
          speakSentence(sentence, voice)
      case sentence: String =>
          client = sender
          speakSentence(sentence)
      case _ =>
          println("D'oh! SentenceSpeaker got an unexpected message")
    }

    def speakSentence(sentence: String, voice: String) {
        WikipediaReaderUtils.speak(sentence, voice)
        client ! ReadyForNextSentence
    }

    def speakSentence(sentence: String) {
        WikipediaReaderUtils.speak(sentence, "Alex")
        client ! ReadyForNextSentence
    }

}

I’m always amazed at how simple Actor code can be if you keep refactoring it.

Image

Here’s an image of the Wikipedia Reader, taken as it’s reading the Wikipedia page for Martin Odersky:

I created all of the components you see in the image based on this Mac OS X + iOS7 concept. It still needs a lot of work, but it’s a start.

Post new comment

The content of this field is kept private and will not be shown publicly.