Let's Make Robots!

S.A.M. as an Arduino Library - Software to make our robots talk

Back in the good old days of Atari's and Commodore64's there was a program called S.A.M. the software automated mouth. Considering this was available about 30 years ago I have always been dissapointed at the lack of progress in robotic speach since then.

I know there is some much better speech programs available now but how often have you had a computer talk to you?
S.A.M. is actually built into Adobe Reader. Just open a PDF file, go to the "View" menu and at the bottom you will find "Read Aloud".

After looking at the price of the Speakjet chipset I decided there had to be a better way so I went to research S.A.M. It seems SAM is a small (39K) C language program and the source code is freely available here:  http://simulationcorner.net/index.php?page=sam

Unfortunately I am not a programmer so for me to make this into an Arduino library is not practical but I know many of our LMR members are. I am hoping someone will be able to convert this to an Arduino library free for everyone to use.

Because of the memory size it might only work on the Mega series of Arduinos but that would still be cool. It is cheaper to but an Arduino Mega than to buy a Speakjet chipset and you get a lot more Arduino goodness to play with.

Below is an example of a simple "Serial Input - Audio Output" circuit that might be used with such software.

Here is an I2C version:

The first Serial In - Audio Out, circuit requires the processor to send 8 serial bits followed by a pulse to the "update" pin. This cycle would have to be repeated at the sample frequency of the sound being played. This circuit uses an 8-bit shift register to covert the serial data to parallel and an R2R ladder to convert the parallel data to analog.

The second circuit works the same way except using a 12-bit SMD I2C DAC. If your audio sample is only 8-bit then make your 4 least significant bits 0's. If your audio sample is 16-bit then only send the 12 most significant bits.

With both circuits I have shown an audio amplifier that is commonly found in cheap computer speakers. At 5V it will deliver up to 1.4W into an 8Ω speaker with surprisingly little distortion.

sam.tar.gz22.81 KB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

...will there be enough space left on the Mega for the Robot to do anything but talk?

I'm not sure about the SAM code, but the "retro" robot voice lib fits in a 328 with room for other stuff. For instance, I have used one 328 in my MiniEric robot as a speech controller, talking serially to a VRbot speech recognition module, send I2C commands to the other modules depending on the recognized command and respond with speech when necessary.

Perhaps the problem is the sample code I supplied which admittedly seems designed more for PC's. The first time I heard SAM was on my Atari 600XL. That only had 16K of memory and a 2.5MHz 6502 processor. I had expected the code would be easily adapted to the Arduino. I will have to see if I can find the Atari version of the code.

... never got to test though:


Should do on a ATMega168 ...

I have "translated" that into an Arduino library long time ago. I have no idea how I did it, I just deleted the debugging stuff and wrapped the functions in C++ style (with some help from the Arduino forum, as I don't know enough programming to do it on my own). The code does not work as good as a SpeakJet and I had no idea how (or if) things can be improved so I dropped it all together. The code is attached to my MiniEric robot page (TTSzip.txt - rename it TTS.zip), feel free to grab it and experiment.

And also, which kind of speaker - audio interface are you using in the video ? 

Hi Ro-Bot-X

Looks like you ´ve put many parts together in your MiniEric. It´s actually a very cool project. Did you finally got ¨understandable¨ phonemas reproduced ? I read in your blog that you still needed to adjust some parameters. How did that go ? Can you tell us from your experience how good can they be reproduced? Or even better, do you have any recording of the actual sound reproduced ?

Thanks for your support,


I used the same amplifier as for a SpeakJet. I just searched for a SpeakJet schematic and instead of the SpeakJet output pin I used a 16 bit PWM pin from the ATmega328 (I think the code fits a 168, but not with much room left). I remember when using a powered amplifier after the RC filter I got better results. I could understand what the bot was saying, but I knew what it was supposed to say. My wife could not understand a thing, but she has a problem understanding speach in general. I do not have any recordings, mainly because I wasn't happy about how it sounded. However, in a few videos the robot speaks a bit. I've been told by the original programmer (Webbot) that using phonemes makes a better output but I never got around to try it. In his tutorial there is a list of phonemes, try it out and let us know how things work. I could not improve the code because it is waaaay over my level of understanding. Funny thing is, I could make it work as a library even with my limited programming knowlege (with help from Arduino forum). 

I've been taking a look at the code that you came with. Needs optimization, testing, etc etc. Specially to see how fast it goes. But you've got something I think we can come with a reduced version that reproduces a set of words in a reduced space of memory, that was my goal. It's on my top list for this weekend. I'll let you know what I come with.

After testing, I will also start looking around if I find any of these people>   " Clive Webster or  Gabriel Petrut "  . They seem to have some copyright over the code. I don't see any CC or GNU mention over there.

I'll keep you updated,


I think you need to look no further. Gabriel Petrut is none other than Ro-Bot-X! :)