IRC Text to Speech with Java

Internet Relay Chat (IRC) is a network chat system used by millions of people all
over the world. It has been around for several years and is used by groups of friends,
programmers, universities, and even banks to facilitate discussions, the exchanging of
ideas, and collaborative research.

Because IRC is very much a real-time chat system, you will rarely benefit from using
it unless you are able to pay close attention to the sequence of dialog as it transpires.
Unfortunately, this can lead to a lack of productivity in the workplace, which is why
many employers naively frown upon the use of IRC. However, when used properly,
IRC can let employees work effectively with remote colleagues, regardless of whether
they are on the other side of the planet or just in the next building. Real-time group
chat systems like IRC make it easier to organize meetings (and possibly even carry
out virtual meetings), ask questions, and to negotiate the less-important things such as
where to go for lunch.

Many bosses would argue that the most obvious way to boost productivity in the
workplace is to avoid using IRC altogether. While this may be true to some extent,
there really are cases where IRC can be useful. When you carry out a conversation on
IRC--even if it's with someone in the same office--your colleagues elsewhere will
be able to see what you are both saying. You will also be able to see what was
discussed while you were away from your desk. These are both important aspects that
cannot be achieved easily using a telephone or conventional peer-to-peer chat system.

The ideal solution is to engineer a way to keep track of IRC dialog without having to
constantly check to see if there are any new messages to read. As long as your IRC
channel is not too busy, a text-to-speech system provides an excellent solution. By
reading out messages as they arrive, you will be able to continue working and only
divert your attention to IRC when absolutely necessary.

This article will show you how to create a multi-platform IRC bot (an automated
client) that uses the FreeTTS Java speech synthesizer library to convert IRC messages
into audible speech.

You can now compile the IRC bot. Make sure to include the necessary .jar files in
the classpath:

javac -classpath .;./lib/pircbot.jar;./lib/freetts.jar
SpeechBot.java

Note that this way of specifying the classpath will only work on Windows systems.
On Unix/Linux systems, you will need to use a colon (:) instead of a semicolon (;) to separate the entries.
You will also need to specify the classpath when running the IRC bot.

When running the bot, you will need to provide a couple of command-line parameters
to tell it which IRC server to connect to and which IRC channel to join:

Note: Make sure your directory names do not contain any spaces, as the version of
FreeTTS used here seems to have trouble reading itself when there is a space in the
path.

After you have launched the bot, it will shortly join the specified IRC channel (in this
case, #irchacks on the freenode IRC network). You can now test the bot by sending a
message to the channel. If everything is set up properly, you will now hear the bot
speak to you:

"Jibbler on #irchacks says: Hello, world!"

Now you can carry on working hard while you listen to IRC!

Paul Mutton
is the author of the PircBot IRC framework
and several other Java programs that can be found on
his web site.