web api interface
SpeechSynthesisEvent
The SpeechSynthesisEvent interface of the Web Speech API contains information about the current state of SpeechSynthesisUtterance objects that have been processed in the speech service.
Constructor
SpeechSynthesisEvent()- : Creates a new
SpeechSynthesisEvent.
- : Creates a new
Instance properties
The SpeechSynthesisEvent interface also inherits properties from its parent interface, Event.
charIndexRead only- : Returns the index position of the character in the
textthat was being spoken when the event was triggered.
- : Returns the index position of the character in the
charLengthRead only- : Returns the number of characters left to be spoken after the
charIndexposition, if the speaking engine supports it. Returns 0 if the speaking engine can’t provide the information.
- : Returns the number of characters left to be spoken after the
elapsedTimeRead only- : Returns the elapsed time in seconds after the
textstarted being spoken that the event was triggered at.
- : Returns the elapsed time in seconds after the
nameRead onlyutteranceRead only- : Returns the
SpeechSynthesisUtteranceinstance that the event was triggered on.
- : Returns the
Instance methods
The SpeechSynthesisEvent interface also inherits methods from its parent interface, Event.
Examples
utterThis.onpause = (event) => {
const char = event.utterance.text.charAt(event.charIndex);
console.log(
`Speech paused at character ${event.charIndex} of "${event.utterance.text}", which is "${char}".`,
);
};
utterThis.onboundary = (event) => {
console.log(
`${event.name} boundary reached after ${event.elapsedTime} seconds.`,
);
};
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.