[pygtk] gobject.timeout_add() problems using speech-dispatcher

James Simmons jim.simmons at walgreens.com
Tue Apr 15 23:02:54 WST 2008


I am working on an Activity for the One Laptop Per Child project.  As =

you may know, OLPC activities often use pygtk.  My activity is for =

reading Project Gutenberg Etexts, and I have been asked to add text to =

speech to that Activity using speech-dispatcher.  The idea is to have =

karaoke-style highlighting, so that as each word is spoken it is also =

highlighted in the text.  This should help children learn to read.  To =

do this I have to synchronize highlighting and speaking.

Speech-dispatcher can do callbacks when it is finished speaking, so my =

plan was to use gobject.timeout_add() to call a function at regular =

intervals.  This function would check a flag that would be set to True =

if speech-dispatcher was finished speaking.  If True I would highlight =

and speak the next word, if false I would not.  I would use =

speech-dispatcher callbacks to set the flag to True every time it =

finished speaking.

What I found out was that speech-dispatcher would not consistently =

execute the callbacks.  When I pointed this out to the speech-dispatcher =

mailing list one of the developers recreated my problem, then found that =

it he just executed my method in a loop rather than using =

gobject.timeout_add() that the code in speech-dispatcher worked =

perfectly and all callbacks got executed.  He is convinced that using =

gobject.timeout_add() interferes with socket activities in other =

threads.  I have forwarded his email below.

Unfortunately, running that code in a loop is less than optimum.  I need =

to be able to turn speech on and off, which I can't do in a simple =

loop.  I need gobject.timeout_add() to work, or something similar, to =

get text to speech with highlighting.

I would appreciate any suggestions you have to offer.

James Simmons

-------------- next part --------------
An embedded message was scrubbed...
From: Hynek Hanke <hanke at brailcom.org>
Subject: Re: Problems with "end" callback in Python
Date: Mon, 14 Apr 2008 14:33:41 +0200
Size: 4493
Url: http://www.daa.com.au/pipermail/pygtk/attachments/20080415/6cbb6bc0/Pr=
oblemswithendcallbackinPython.eml


More information about the pygtk mailing list