- From: Dominic Mazzoni <dmazzoni@google.com>
- Date: Tue, 11 Sep 2012 01:19:59 -0700
- To: public-speech-api@w3.org
I propose adding a mechanism by which JavaScript clients can attach event listeners to an utterance to get notified when it starts speaking, when it finishes, and optionally with updates of the progress. Here's what could be added to the spec: callback SpeechSynthesisStartCallback = void(); callback SpeechSynthesisEndCallback = void(); callback SpeechSynthesisUpdateCallback = void(DOMString markerName, unsigned long charIndex, float elapsedTime); interface SpeechSynthesisUtterance { ... attribute SpeechSynthesisStartCallback onstart; attribute SpeechSynthesisEndCallback onend; attribute SpeechSynthesisUpdateCallback onupdate; } I propose that "onstart" and "onend" must be supported for an implementation to be fully compliant. There are too many applications that can't be implemented without these. I think "onupdate" should be optional because it depends on what's possible in the speech engine. If the speech engine provides word-level information, for example, then every time there's a break between works it'd call onupdate() with the character index (into the original utterance string) and the elapsed time since speech began. An engine might also notify when certain named "markers" (e.g. in SSML) are reached. Other ideas - in the Chrome TTS extension API I also implemented these events - what do you think? * Error * Cancelled (stopAndFlushQueue called before it ever started playing) * Interrupted (stop called while it was in the middle of speaking) - Dominic
Received on Tuesday, 11 September 2012 08:20:31 UTC