I'm working with some code to have a robot do vision processing, speech recognition and text-to-speech.

I'm using python2.6 and openCV

The objective of the code is to have the robot recognize faces via webcam and say, "Hello."

It does this more or less perfectly, except for one thing.

A problem I'm encountering - it's more like an inconvenience - is when Text-to-speech starts talking, the python code doesn't process anything until its finished talking. So when my robot says "hello" the vision processing freezes up and doesn't continue until after its done talking. This concerns me because if I - or someone interacting with my robot - moves from one corner to another, the robot could lose track of where it's operator's face is. It isn't just with vision processing either. The same is true for servo motor movement. I've tested it...

So I'm wondering, is there any way to have the text to speech and the vision processing as separate elements? Basically, is there any way text-to-speech can function without pausing the rest of the python script? Can it run as a separate element, sort of like two things running at the same time so the process isn't effected?

I'm implementing the speech.py module to do my voice recognition and text-to-speech.

Any help would be much appreciated.


You need to run the text-to-speech on a different thread. import threading #go from there