[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Pygtk does not play nicely with speech-dispatcher
From: |
James Simmons |
Subject: |
Pygtk does not play nicely with speech-dispatcher |
Date: |
Thu, 24 Apr 2008 09:16:17 -0500 |
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
- Problems with "end" callback in Python, (continued)
- Problems with "end" callback in Python, James Simmons, 2008/04/14
- Problems with "end" callback in Python, James Simmons, 2008/04/17
- Problems with "end" callback in Python, Hemant Goyal, 2008/04/18
- Problems with "end" callback in Python, James Simmons, 2008/04/18
- Problems with "end" callback in Python, Hynek Hanke, 2008/04/18
- Problems with "end" callback in Python, James Simmons, 2008/04/18
- Problems with "end" callback in Python, Lukas Loehrer, 2008/04/20
- Problems with "end" callback in Python, Hynek Hanke, 2008/04/21
- Problems with "end" callback in Python, James Simmons, 2008/04/22
- Problems with "end" callback in Python, Hynek Hanke, 2008/04/23
- Pygtk does not play nicely with speech-dispatcher,
James Simmons <=
- [pygtk] Pygtk does not play nicely with speech-dispatcher, Dave Aitel, 2008/04/24
- [pygtk] Pygtk does not play nicely with speech-dispatcher, James Simmons, 2008/04/24
- [pygtk] Pygtk does not play nicely with speech-dispatcher, Michael Urman, 2008/04/24
- [pygtk] Pygtk does not play nicely with speech-dispatcher, James Simmons, 2008/04/25
- [pygtk] Pygtk does not play nicely with speech-dispatcher, Dave Aitel, 2008/04/25
- [pygtk] Pygtk does not play nicely with speech-dispatcher, John Finlay, 2008/04/25
- [pygtk] Pygtk does not play nicely with speech-dispatcher, Hynek Hanke, 2008/04/28
- [pygtk] Pygtk does not play nicely with speech-dispatcher, Hemant Goyal, 2008/04/28