January 2007

The Speech Code Generator.

About a week ago Vern got a Soundgin™ sound module. He had a few hours to play with it before I took it away. Besides just being an awesome sound generator it has about 70 built in allophones for speech synthesis. The one he ordered came with the chip and a board with a rs-232 interface, an amp, and power circuit. Its super easy to talk to the chip over a serial connection. Commands are given to it by sending bytes of data. Speech is done the same way just send the code for an ‘a’ (which is xC1) and the chip will gladly say ‘a’ until you give it another command. Like pause (xFC).

Vern does most of his robot development using the Basic Stamp II which is a really nice board. So I set out to write some code that would generate BS2 code to generate speech. To accomplish this there are a few steps.

First the English text needs to be converted into a machine format. Luckily CMU did all the work for this when they made Festival and Flite (Festival Lite.) I am using a package from flite called t2p. Its operation is pretty simple:

$t2p "Hello World"
gives: pau hh ax l ow1 w er1 l d pau

Next those phones that t2p spit out have to be converted into the format that the sound module uses. For this I wrote a php program inspired by one that someone else had written in perl for his tts project using the speakjet chip. The code comes down to two things. A translation table and a preg_replace line.

$patterns[70] = '/PAU /'; $replacements[70]="\xFC"; // .FD0
$patterns[71] = '/AX /'; $replacements[71]="\xC1"; // .au
$say=preg_replace($patterns, $replacements, strtoupper($input_text));

Then for testing the codes I wrote a python program to just simply take stdin one character at a time and send it to the chip. Keeping a close watch on the CTS line. My testing flow looked like this:

t2p "Hello World" | php5 -q ./cmu2sg.php | ./send_to_serial.py

Now that the main part of testing is over I have written the php code to call t2p then give the output in BS2 format. I’m sure a lot more tweaking could be done to the conversation table. To improve the CMU phones to sound chip conversion. Right now I think I am only using about 1/2 of the available ones.

Sometime last year I was given a laser pointer that had 3 buttons on it. One to light the laser, an up arrow and a down arrow. It came with a IR to usb receiver that showed up under linux as a keyboard device. Obviously this was meant for doing presentations using the up and down buttons to advance the slide show. I hooked it up and used it to control XMMS.

Even though the commands that the thing was sending didn’t line up XMMS’s previous(Z) and next(B) buttons. I learned that by pulling up the menu and pointing to an option then hitting the key would reassign the function to that key.

About 2 dance parties later and the remote fell out of my pocket and was damaged.

Since then I have tried a couple of different things. None were to my satisfaction. Most of the presenter remotes or IR->USB adapters are in the $60-80 range. Way to high for me.

One thing I tried was using a Playstation 2 to usb adapter and connecting that with a wireless PS2 joystick. It worked ok. But having to have a huge ps2 adapter on you just to change songs kinda sucked…. Plus it was a little clumsy to FF and REW.

Today when I was at Frys I saw a little package in the PS2 isle (sku 3638375 ). It had a wired ps2 vibrating controller, a old school ps2 vertical stand, and a IR wireless remote and adapter for $7.90, I bought it. That is in my price range. (I am sure the price was only that low because the stand in it is for an old model ps2 that Frys no longer carries.)

I hooked it up enabled the Joystick Control 1.2.10 plugin for XMMS then mapped the keys. This thing works perfectly. It is really responsive. As a plus I also have an extra ps2 controller.

As part of the purging process of becoming a nomad we are trying to make an archive of important data. This is not an easy task. We have about 30 Gigs of photos. I know there are duplicates in the data but I haven't done anything about it until now.

In integrity part1 I told how to check the md5deep database (just a text file with md5sum and filename) to see if there are any duplicates. Example:  sort -n md5.test_data.txt | uniq -D -w 32 This will check the first 32 bytes of the md5 sums after sorting them. This works great for detecting duplicates.

But what can I do about them? Sometimes I have a duplicate on purpose. For example if I have a directory tree with 500 photos from a single shoot I want to make a directory with the "best of." I could do several things: Make symbolic links to the files, copy them to a new folder, or store best of stuff outside the main backup tree. I opt for just making a copy of the file into a "bob" folder. It is wasteful of space but this is the method that I choose.

So now that I have copied them I have files with duplicate md5sums. After pondering on this for a while I came up with the idea of changing the jpeg comment field to say something like: "I know this is a copy" or "Best Of Photos."

To accomplish this I am using my good friend jhead – the jpeg header manipulator. Example:

find ./best_of_best/ -type f | xargs -n1 jhead -cl \"Best of Photos\" 

This does the trick… now each file even though it is really the same photo with the same image data and same file name has a different md5sum.

Some duplicates in the archive are caused by sloppy photo management. Sometimes I do not delete the files off of a card before taking more and end up having more than one copy of a photo in different directories. With the jpeg header trick I can now either delete them or just change the comment field.

I suppose in the future when I start using the comment field more this method could overwrite valuable comment info. I guess when that becomes a problem I will add checks to make sure the comment field is empty before overwriting.