speechd-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[pygtk] Pygtk does not play nicely with speech-dispatcher


From: Dave Aitel
Subject: [pygtk] Pygtk does not play nicely with speech-dispatcher
Date: Thu, 24 Apr 2008 10:56:24 -0400

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Threading and pyGTK can be very complex - do your callbacks get called 
right out of your main thread (where I assume pyGTK's loop is running?)

It might be worth you posting a bit to the list. There are lots of 
programs that both do network processing and use PyGTK quite a bit, so 
it is possible. A simple fix to the threads will probably be in order. :>

FWIW, I would use this:

o Main thread running pyGTK with a gui_queue, that handles GUI events 
and also clears the gui_queue when it is idle. One of the gui_queue 
commands would be "trigger speech dispatcher callback" which would then 
use a speech dispatcher queue to tell that thread what to do.
o speech dispatcher thread which then clears it's own queue and does 
callbacks based on that. You don't want the GUI thread doing speech, of 
course.

- -dave


- -dave

James Simmons wrote:
| I have been working on a Pygtk pgrogram for the OLPC project which is 
a reading program for Project Gutenberg Etexts.  Several people on the 
OLPC mailing list suggested enhancing it to work with speech-dispatcher 
so that the program could read the texts aloud, at the same time 
highlighting the word as it is spoken.  They felt it would be useful to 
students trying to improve their reading skills, etc.  What I have found 
is that getting the program to read aloud is easy, getting a Pygtk 
program to highlight words one a a time is easy, but getting the two to 
work together might be impossible.
|
| Speech-dispatcher runs in its own thread.  It has callbacks that I 
have configured to execute a Python method every time a word ends.  
Using this it *should* be trivial to highlight the word as it is 
spoken.  Trouble is, when the Pygtk event loop is allowed to run at the 
same time as speech-dispatcher, none of the callbacks are ever invoked.  
If I do a wait loop after invoking speech-dispatcher, then all of the 
callbacks work but the screen does not get updated to show the words 
being highlighted.  Only the final word on the page gets highlighted.  
Hynek Hanke of the speech-dispatcher project has noticed that 
socket.recv() does not work in speech-dispatcher if it is allowed to run 
at the same time as the event loop.
|
| I can supply code to demonstrate this problem.  I am hoping that one 
of you can suggest a good workaround.
|
| Thanks,
|
| James Simmons
|
|
|
| Hynek Hanke wrote:
|
|>
|> Hello James,
|>
|> it is an interesting problem. I think pygtk needs to be fixed if it
|> seems to behave so badly with other libraries using threads.
|> This has little to do with speech callbacks specifically. More
|> important is the thing that when you run basic system functions
|> like socket.recv() from other threads, they behave badly.
|> Would you like to raise this issue with the PyGTK developers
|> to see if it is possible to fix it or to use PyGTK in some other
|> way that avoids the conflict?
|>
|> As a workaround, you can try to avoid the pygtk loop and do
|> your own asynchronous thread to highlight the words. Threads
|> are easy in Python. However, unless we find out where in
|> PyGTK the problem lies exactly, it is always possible, that you will
|> run into the very same problems and they will prevent your
|> thread to work correctly.
|>
|> Anyway, old or new implementation of speechd, threads will
|> always be used in the python communication library, since they
|> are technically necessary to handle asynchronous callbacks.
|> So it would be very useful to try to find a solution with pygtk.
|>
|> With regards,
|> Hynek Hanke
|
|
|
| _______________________________________________
| pygtk mailing list   pygtk at daa.com.au
| http://www.daa.com.au/mailman/listinfo/pygtk
| Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIEJ+YtehAhL0gheoRAi2bAJoCzDKr1+dOUSoBTFzphV2W4Y0JowCfchcQ
NnY0OLqwU66X1LHlPfHZZQc=
=YgAY
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]