Last night, I had my first look into the Anki Cozmo robot’s SDK that uses Python. It was a little nerdy to install and set up, but the videos were well put together. Now, the real fun begins!
My strategy for learning these programs is to alter them in some way, to be creative but also to get some hands on coding done, and maybe to do some independent things rather than just following instructions without having to think much. It’s one thing to repeat words and phrases to learn a language. It’s another to make your own, or at least tweak, the words and phrases you got taught. I learn much better the latter way.
For this first program, all it got Cozmo to do was to say “Hello world”. It’s a standard Python program if you were learning introductory Python, applied to Cozmo. Instead of just running it, or changing a few words, which were fun, I added pauses using the natural pauses in the way the code written is ran. I added sufficient amount to let me sneak in phrases so it would seem like we were having a dialogue, as you can see. And putting the geeky Star Trek Borg and Khan references in kept it funner.
Just for the record, if you don’t know what these codes involve, the code is below. Nothing fancy. I didn’t even find a true “pause” code. I just used what was there creatively, and also discovered a few things about the phonetics of the Python speech engine. It won’t get every English word quite right, as none except some big databases with AI these days might. The example is the word “futile”. Cozmo reads more like FEW-tul, phonetically. Seeing it knows the basic pronunciation for spelling, I went with FEW TILE to get it to say “futile” the way the Borgs say it on Star Trek, using two words it knows. And I fixed some phonetics to get a better sounding read, like the word resistance to resistuns. Its laughing was also better done with hah rather than ha. But that’s the stuff you find out experimenting.
import cozmo def cozmo_program(robot: cozmo.robot.Robot): robot.say_text(" ").wait_for_completed() robot.say_text(" ").wait_for_completed() robot.say_text(" ").wait_for_completed() robot.say_text(" ").wait_for_completed() robot.say_text("Hi Minh").wait_for_completed() robot.say_text("Hello Humans.").wait_for_completed() robot.say_text("Resistuns, is few tile.").wait_for_completed() robot.say_text("Hah hah hah hah hah. Hah hah hah hah hah!").wait_for_completed() cozmo.run_program(cozmo_program)
There is a module (or whatever it’s properly called) that can help with more speech control in Python that I’ll explore, dealing with ARPAbets and phonemes… which WordPress doesn’t even recognize as a legitimate word! I was very impressed looking at it, but we’ll see if I’ll be able to integrate it into programs for Cozmo.
In the meanwhile, stay tuned for more fun Cozmo developments as I learn to program it more!