Menu

Ganzbot: An Arduino robot who reads Twitter

This funny little robot has eyes, eyebrows and a mouth and will verbally read your latest Twitter status to you. It uses an Arduino Decima to control the head actions and receives the latest Twitter status information over USB from a host computer.

You can also send the robot something to say directly from the command line with a few Ganzbot moods to choose from. More information after the videos.

Steve’s Reaction

Background

A couple months ago a few people at LinkedIn decided to create a Twitter account called “Ganzbot”, named after Steve Ganz, as a joke. Then when Steve left to compete in the PDGA World Championships we decided to build a “real” Ganz Robot to occupy his cube when he returns.

How it works

At a high level, there is a Java program on the host computer which retrieves the latest Twitter status, passes facial and word data to the head and then speaks the Twitter status through the computer speakers using FreeTTS, an open source Java text-to-speech synthesis library. I would have liked to put a speech synthesis chip in the head instead, but didn’t have the time.

LED Lips — how to make them talk

Getting the LED lips to be synchronized with the words was a bit tricky. Unfortunately FreeTTS doesn’t implement 100% of the JSAPI, so when it’s speaking there is no way to know when one word ends and another begins. Instead, the Java program on the computer splits up the text into individual words, sets the volume to zero and speaks each one to figure out how long it takes to say. Then the program passes the word times to the head and starts speaking the entire sentence with the volume at the normal level. The lip synchronization isn’t perfect, but it’s pretty good.

Another option might be to light up the LED lips from an audio spectrum analyzer.

Circuit

To keep it simple I took a standard perf board from Radio Shack and added header pins to turn it into an Arduino shield. This makes it really easy to connect it to the Arduino and ensures all the pins are in the correct sockets. The circuit below was created to show the pins and voltage source as they appear on the board. More details on the circuit after the diagram.

Transistors

Unfortunately there wasn’t enough juice coming from the Arduino chip to power the LEDs very bright, so I had to use standard NPN transistors to feed the LEDs power directly from the board.

Lips and Eyes

I only included half of the lips and eyes in the circuit diagram since the other halves are simply connected in parallel and I didn’t want to clutter it up. I’m sure you can figure it out. If you have trouble, leave a comment below.

Eyes

The eyes are simple multi-color LEDs I picked up from Radio shack. They can output red, green and blue, but the Ganzbot only uses red and blue. The longest pin is positive and the color depends on which pin you put to ground. I suggest testing it on a breadboard before soldering it into place.

Software

On the host computer a Java program retrieves the Twitter information (or command line message) and sends the word times to Arduino over the USB cable. All the robot needs to know is the mood it should be in (neutral, sad, angry) and how many milliseconds each word takes the speech synthesis program to say. If the program is started in “-twitter” mode, it’ll continue checking Twitter for updates every 2 minutes until you stop it.

Download

Requirements

OS: Any
Java: version 1.5 or greater

I compiled the program using Java 1.5, so as long as you have version or greater you should be able to use it out of the box. If not, you can simply compile the app to your version Java (see the Build section below).

Libraries

The GanzBot program relies on the following libraries, which are all included in the download:

Build

To build the Ganzbot source code you first need to install the Apache Ant build tool. Then go into the “src” directory and simply run “ant”. It should take care of compiling both Ganzbot and JSON and placing their Jar files in the correct locations.

FreeTTS comes precompiled from Java 1.4. If you are using an older version of Java you’ll need to download their source code and build it manually. Once completed put the jar files it created in it’s lib directory in the Ganzbot lib directory.

RXTX is the same as FreeTTS and comes precompiled. To compile it to another OS or version of Java, follow the instructions on their wiki.

Installer

In the download I’ve included an “install.sh” script that will install the RXTX library and Mac USB drivers that are needed to communicate with the Arduino. The installer is specific to Apple and wont work on other operating systems. The simplest way to make it work on other systems is to install the Arduino software. Otherwise you can always install RXTX and the FTDI USB/Serial driver manually.

Running the Program

To run the progam start by plugging in the Ganzbot and then open up a command line terminal.

In the command line, go to the place you downloaded and extracted the program.

If the program gave you an error, it’s likely because it doesn’t know which USB/Comm port that the Arduino is plugged into. It should list the available ports you can choose from in the error message. Then run the command again with the “-port” flag, like this:

For windows you’ll probably use something like “COM1” instead of the “/dev/tty…” string.

You can also type java -jar ganzbot.jar -help for more options.

Reading Twitter

To speak a Twitter status message enter a command like this (where jgillick is the twitter user) :

java -jar ganzbot.jar -twitter jgillick

Ganzbot wont read the same twitter message twice. The program saves the last tweet ID in a file called “.tweetid”, remove this file to have it say the last Twitter message again.

Moods

Ganzbot can be a bit moody sometimes. To define the mood he should speak in, add the mood text to the very beginning of the message. Here are a few examples:

“[angry]I am very angry right now. Destroy, Destroy.”

“[sad]When I’m sad I whine alot.”

“I am not angry or sad, for I am a robot.”

Rails Application

For fun I also created a super simple rails application that let anyone queue up messages to be spoken instead of using Twitter. If the Ganzbot program is in Twitter mode it’ll automatically check that queue if there isn’t a new Twitter status message. The app is hardcoded to look at http://localhost:1024/ for the queue. You can change that in GanzBot.java if you need.

In order to run the web application you first need to make sure you have both Ruby and Ruby on Rails installed. Then download the package (see download section), extract it and run the following from the command line in the “GanzbotRails” directory.:

Cool project. I noticed though that the transistors driving the multicolored lED are backwards. Reverse the E and C and they will work. Also, the transistors driving the other LEDs should have the LEDs on the collector side, so that the LED voltage drop does not interfere with the base bias. It’s standard practice to use a single resistor for each LED also 🙂 Keep up the good work.

[…] see, and it can read text from your computer to boot. Builder Jeremy Gillick and his crew over at The Mozmonkey Blog created the Ganzbot when friend Ganz left to compete in the PDGA World Championships, and had it […]

[…] Ganzbot: An Arduino robot who reads Twitter This funny little robot has eyes, eyebrows and a mouth and will verbally read your latest Twitter status to you. It uses an Arduino Decima to control the head actions and receives the latest Twitter status information over USB from a host computer. […]

I really like the Gazbot. I would like to build one. I have an arduino MegaBoard. But, I am new to the arduino. I am still waiting for my shield to come in. Is there a place I can get more information on the construction of this bot? Maybe , another more simple tutorial outlining everything I need to make one.

hi all, i try to program a serial link with arduino mega and mac os X, but the rxtx library make a exception, portinuseexception, but i have no program that use the serial link of my arduino, i can’t send or receive line with my arduino on mac os X, but on windows its works. can you send me the java source you use to the serial link ?

Hey Jeremy, i found this, and i want you to know you don’t have to speak the word ahead to synchronize the text.
The information is all in the Freetts engine and is accessible by adding a UtteranceProcessor to the voice % a few bugs.

[…] had been having all week. Our adruino code seemed perfect. However, The code we adapted from the Ganzbot site was written for an older version of the adruino board. Our LED’s for our mouth and eyes […]