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.
TheSpeechSynthesisEvent() constructor creates a newSpeechSynthesisEvent object.
Note:A web developer doesn't typically need to call this constructor, as the browser creates these objects itself when firing events.
In this article
Syntax
new SpeechSynthesisEvent(type, options)Parameters
typeA string with the name of the event.It is case-sensitive and browsers set it to
start,end,error,pause,resume,mark, orboundary.optionsAn object that,in addition to the properties defined in
Event(), has the following properties:utteranceA
SpeechSynthesisUtteranceobject, which is the speech request the event was triggered on.charIndexOptionalThe index position of the character in
SpeechSynthesisUtterance.textthat was being spoken when the event was triggered. Its default value is0.charLengthOptionalThe number of characters left to be spoken after the character at the
charIndexposition. Its default value is0.elapsedTimeOptionalThe elapsed time in seconds, after the
SpeechSynthesisUtterance.textstarted being spoken, at which the event was triggered. Its default value is0.nameOptionalThe name associated with certain types of events: the name of theSSML 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 newSpeechSynthesisEvent object.
Specifications
| Specification |
|---|
| Web Speech API> # dom-speechsynthesisevent-speechsynthesisevent> |