Problems with "end" callback in Python

James Simmons jim.simmons at
Fri Apr 11 16:20:30 CEST 2008

I am currently trying to use speech-dispatcher with espeak to create a 
book reading activity for the One Laptop Per Child project.  This 
activity provides an ebook reader for Project Gutenberg Etexts.  Several 
people on their mailing list suggested that I add a text to speech 
feature so that the child could have the book read to him while he sees 
the spoken words highlighted on the screen, sort of like karaoke 
highlighting.  That of course requires synchronizing the highlighted 
words and the spoken words.  I have tried to implement this in python as 

When the user turns on speech some flags are set and a timer starts 
invoking a function "next_word" at regular intervals.  In that function 
I check the flags and if the flags say it is OK to speak I have speech 
dispatcher speak one word, after highlighting it on the screen.  I have 
a callback for speech dispatcher which *should* tell me when the word 
has finished being spoken.  When the callback function is invoked I set 
a flag to True saying that it is OK to highlight and speak the next word.

The problem is, the callbacks are not always being received.  In fact, 
more often than not they are not received, but occasionally they are.  
This results in the app speaking one word, then stopping.  I turn speech 
off and then on and I might get the next word, or if I'm lucky the next 
few words.  If I get the next few words the highlighting works 
perfectly.  I just need to know how to make the ending callback work 

I have code I could send you if that would help.


James Simmons

More information about the Speechd mailing list