SpeechSynthesisEvent: SpeechSynthesisEvent() constructor
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2022.
The SpeechSynthesisEvent() constructor creates a new SpeechSynthesisEvent object.
Note: A web developer doesn't typically need to call this constructor, as the browser creates these objects itself when firing events.
Syntax
new SpeechSynthesisEvent(type, options)
Parameters
type-
A string with the name of the event. It is case-sensitive and browsers set it to
start,end,error,pause,resume,mark, orboundary. options-
An object that, in addition to the properties defined in
Event(), has the following properties:utterance-
A
SpeechSynthesisUtteranceobject, which is the speech request the event was triggered on. charIndexOptional-
The index position of the character in
SpeechSynthesisUtterance.textthat was being spoken when the event was triggered. Its default value is0. charLengthOptional-
The number of characters left to be spoken after the character at the
charIndexposition. Its default value is0. elapsedTimeOptional-
The elapsed time in seconds, after the
SpeechSynthesisUtterance.textstarted being spoken, at which the event was triggered. Its default value is0. nameOptional-
The name associated with certain types of events: the name of the SSML marker reached in the case of a
markevent, or the type of boundary reached in the case of aboundaryevent. It defaults to the empty string ("").
Return value
A new SpeechSynthesisEvent object.
Specifications
| Specification |
|---|
| Web Speech API> # dom-speechsynthesisevent-speechsynthesisevent> |
Browser compatibility
Loading…