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.

AttachmentSize
sam.tar.gz22.81 KB

Comment viewing options

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

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,

Rudi

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,

Rudi

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

Yeah, I am Gabriel Petrut and Clive Webster is Webbot on the SoR forum. He said anyone can use the code, modify it, etc. just keep the credentials there. He is the original author of the C code that works in AVR Studio 4. I cut out from the original code all the debugging code to shrink it to the minimum to fit into a 168. I think you should also get the original code (from the link to the SoR tutorial) and see the differences. There are also a few ways to output the sound, I chose PWM, but there are other connections that may bring more understandability to the speach.

Oh, one more thing, Webbot has added the speach sinthesizer code to his WebbotLib:

http://webbot.org.uk/iPoint/45.page

I have posted a couple of schematics for simple sound cards for an Arduino or any other MCU. 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.

Your code will need to send the audio data at an apropriate sample rate so a timer interrupt may be required depending on your code. WAV files can be unencoded raw audio data that can be stored on an SD card and read by the MCU.

 

Hi guys,

I´ve been working for a while with the library of PCM reproducing WAVs stored in programming memory. Sure, it´s slow, it´s dumb and the sound is not perfect. But it´s much nicer than hearing my robots doing an unattractive -beeep- and when they get excited -beep beeep- . Now they say ¨OUCH¨ and I repeat a loop of ¨ha- ha- ¨ . 

It´s not much more than that, I can record almost 4s of sound and that´s all I can do. But I think that OddBot idea is amazing. My audio interface is 1 transistor, 1 resistor and a cellphone speaker. So it costs almost the same than a buzzer but it´s crazy funnier. Why not building a basic table of phonemas (is that the right word?) and combine them into some limited vocabulary.

Sure that with an MP3 shield or whatever other hardware you can get amazing things done. But I think that there is beauty in exploring till the maximum the resources. At least I was very happy when my silly robot said to me his first ¨he-lo¨ from exactly the same hardware that I had making beepbeeeeps.

I hope you get my point and also support his concept. I don´t think that porting the original code is even feasible. Even some reasons that Maxhirez stated. But hacking it to a reduced set of commands sounds doable. After all, do we really need to establish a long conversation ? how many phonemas do we need?

I am currently getting my libraries tidy enough to port it to the graphical interface (arduino compatible) minibloq. I will post the code online at multiplo.org, but if somebody is going to build an adventurous code to really talk... count me in.

Excited about this idea,

Rudi

The price of the Speakjet chipset would be acceptable, but the synthezied speech quality is just too bad :)

I think SAM is slightly better than Speakjet but not much. Regardless, if the code could be converted to an Arduino library then it would be a major bonus.

Sounds really a bit better: http://www.youtube.com/watch?v=Rm4ZCGgzeeU