Thu 25 Jan 2007
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.
February 28th, 2008 at 1:02 pm
Hi,
Your programme is brilliant. I am a school teacher in the UK, and we use Picaxe chips a lot over here.
Any plans to make a code generator for Picaxe?