Re: Proposal to add start, stop, and update events to TTS

On Fri, Oct 5, 2012 at 1:27 AM, Glen Shires <gshires@google.com> wrote:
> Instead of the callbacks, I propose this cleaner, more extensible IDL (which
> is similar in style to SpeechRecognition).  This also has the benefit that
> if a web author wanted to, he could write a single function to handle all of
> the events (by assigning each event that he was interested in handling to
> that function).
>
> The definitions and functionality don't change.  If there's no disagreement,
> I'll update the spec with this on Monday.
>
>
> All the SpeechSynthesisUtterance events would be simple Functions with a
> SpeechSynthesisEvent object, and that object contains all the attributes
> (and supports future extensibility):
>
>     interface SpeechSynthesisUtterance {
>         ...
>         attribute Function onstart;
>         attribute Function onend;
>         attribute Function onpause;
>         attribute Function onresume;
>         attribute Function onupdate;
>     };
>
>     interface SpeechSynthesisEvent : Event {
>         readonly attribute EventType eventType;
>         readonly attribute double elapsedTime;
>         readonly attribute unsigned long charIndex;
>         readonly attribute DOMString name;
>     };
>
>     enum EventType { "start", "stop", "pause", "resume", "mark", "word",
> "sentence" };

Sorry, I haven't been following this discussion very closely, but I'm
worried about the 'eventType' attribute.

An Event object already has a 'type' attribute, and I think it would
be confusing to add another one.

I think it's better to have separate event handlers, something like:

  attribute Function onstart;
  attribute Function onend;
  attribute Function onpause;
  attribute Function onresume;
  attribute Function onmark;
  attribute Function onwordboundary;
  attribute Function onsentence;

And if the developer wants to use the same function for all of them,
he can just check the 'type' attribute to see what kind of event it
was (start, end, pause, resume, mark, wordbounary, or sentence).

Thanks,
Hans

Received on Friday, 5 October 2012 09:42:30 UTC