Interface SpeechSynthesis
onvoiceschanged: ((this: SpeechSynthesis, ev: Event) => any) | null;
paused: boolean;
pending: boolean;
speaking: boolean;
addEventListener<K extends "voiceschanged">(
type: K,
listener: (this: SpeechSynthesis, ev: SpeechSynthesisEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): void;
addEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions,
): void;
cancel(): void;
dispatchEvent(event: Event): boolean;
getVoices(): SpeechSynthesisVoice[];
pause(): void;
removeEventListener<K extends "voiceschanged">(
type: K,
listener: (this: SpeechSynthesis, ev: SpeechSynthesisEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): void;
removeEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | EventListenerOptions,
): void;
resume(): void;
speak(utterance: SpeechSynthesisUtterance): void;
}
Hierarchy
- EventTarget
- SpeechSynthesis
Index
Properties
onvoiceschanged
Readonlypaused
The paused read-only property of the true if the SpeechSynthesis object is in a paused state, or false if not.
Readonlypending
The pending read-only property of the true if the utterance queue contains as-yet-unspoken utterances.
Readonlyspeaking
The speaking read-only property of the true if an utterance is currently in the process of being spoken — even if SpeechSynthesis is in a A boolean value.
Methods
addEventListener
- addEventListener<K extends "voiceschanged">(
type: K,
listener: (this: SpeechSynthesis, ev: SpeechSynthesisEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): voidThe
addEventListener()method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.Type Parameters
- K extends "voiceschanged"
Parameters
- type: K
- listener: (this: SpeechSynthesis, ev: SpeechSynthesisEventMap[K]) => any
Optionaloptions: boolean | AddEventListenerOptions
Returns void
- addEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions,
): voidThe
addEventListener()method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.Parameters
- type: string
- listener: EventListenerOrEventListenerObject
Optionaloptions: boolean | AddEventListenerOptions
Returns void
cancel
The
cancel()method of the SpeechSynthesis interface removes all utterances from the utterance queue.Returns void
dispatchEvent
The
dispatchEvent()method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.Parameters
- event: Event
Returns boolean
getVoices
The
getVoices()method of the current device.Returns SpeechSynthesisVoice[]
pause
The
pause()method of the SpeechSynthesis interface puts theSpeechSynthesisobject into a paused state.Returns void
removeEventListener
- removeEventListener<K extends "voiceschanged">(
type: K,
listener: (this: SpeechSynthesis, ev: SpeechSynthesisEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): voidThe
removeEventListener()method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target.Type Parameters
- K extends "voiceschanged"
Parameters
- type: K
- listener: (this: SpeechSynthesis, ev: SpeechSynthesisEventMap[K]) => any
Optionaloptions: boolean | EventListenerOptions
Returns void
- removeEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | EventListenerOptions,
): voidThe
removeEventListener()method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target.Parameters
- type: string
- listener: EventListenerOrEventListenerObject
Optionaloptions: boolean | EventListenerOptions
Returns void
resume
The
resume()method of the SpeechSynthesis interface puts theSpeechSynthesisobject into a non-paused state: resumes it if it was already paused.Returns void
speak
The
speak()method of the SpeechSynthesis interface adds an SpeechSynthesisUtterance to the utterance queue; it will be spoken when any other utterances queued before it have been spoken.Parameters
- utterance: SpeechSynthesisUtterance
Returns void
The
SpeechSynthesisinterface of the Web Speech API is the controller interface for the speech service; this can be used to retrieve information about the synthesis voices available on the device, start and pause speech, and other commands besides.MDN Reference