---
title: "SpeechSynthesis | JavaScript maps SDK"
description: "Documentation for MapTiler SDK"
---

> For AI agents: a documentation index is available at [/llms.txt](https://docs.maptiler.com/llms.txt). Markdown versions of all pages are available by appending .md to any URL.

# Interface SpeechSynthesis

The **`SpeechSynthesis`** interface 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](https://developer.mozilla.org/docs/Web/API/SpeechSynthesis)

interface SpeechSynthesis {  
    [onvoiceschanged](#onvoiceschanged): ((this: SpeechSynthesis, ev: Event) \=> any) | null;  
    [paused](#paused): boolean;  
    [pending](#pending): boolean;  
    [speaking](#speaking): boolean;  
    [addEventListener](#addeventlistener-1)<[K](#addeventlistenerk) extends "voiceschanged"\>(  
        type: [K](#addeventlistenerk),  
        listener: (this: SpeechSynthesis, ev: [SpeechSynthesisEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisEventMap/)\[[K](#addeventlistenerk)\]) \=> any,  
        options?: boolean | AddEventListenerOptions,  
    ): void;  
    [addEventListener](#addeventlistener-2)(  
        type: string,  
        listener: [EventListenerOrEventListenerObject](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.EventListenerOrEventListenerObject/),  
        options?: boolean | AddEventListenerOptions,  
    ): void;  
    [cancel](#cancel-1)(): void;  
    [dispatchEvent](#dispatchevent-1)(event: Event): boolean;  
    [getVoices](#getvoices-1)(): [SpeechSynthesisVoice](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisVoice/)\[\];  
    [pause](#pause-1)(): void;  
    [removeEventListener](#removeeventlistener-1)<[K](#removeeventlistenerk) extends "voiceschanged"\>(  
        type: [K](#removeeventlistenerk),  
        listener: (this: SpeechSynthesis, ev: [SpeechSynthesisEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisEventMap/)\[[K](#removeeventlistenerk)\]) \=> any,  
        options?: boolean | EventListenerOptions,  
    ): void;  
    [removeEventListener](#removeeventlistener-2)(  
        type: string,  
        listener: [EventListenerOrEventListenerObject](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.EventListenerOrEventListenerObject/),  
        options?: boolean | EventListenerOptions,  
    ): void;  
    [resume](#resume-1)(): void;  
    [speak](#speak-1)(utterance: [SpeechSynthesisUtterance](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisUtterance/)): void;  
}

#### Hierarchy

-   EventTarget
    -   SpeechSynthesis

##### Index

### Properties[](#properties)

[onvoiceschanged](#onvoiceschanged) [paused](#paused) [pending](#pending) [speaking](#speaking)

### Methods[](#methods)

[addEventListener](#addeventlistener) [cancel](#cancel) [dispatchEvent](#dispatchevent) [getVoices](#getvoices) [pause](#pause) [removeEventListener](#removeeventlistener) [resume](#resume) [speak](#speak)

## Properties[](#properties-1)

### onvoiceschanged[](#onvoiceschanged)

onvoiceschanged: ((this: SpeechSynthesis, ev: Event) \=> any) | null

[MDN Reference](https://developer.mozilla.org/docs/Web/API/SpeechSynthesis/voiceschanged_event)

### `Readonly`paused[](#paused)

paused: boolean

The **`paused`** read-only property of the SpeechSynthesis interface is a boolean value that returns true if the SpeechSynthesis object is in a paused state, or false if not.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/SpeechSynthesis/paused)

### `Readonly`pending[](#pending)

pending: boolean

The **`pending`** read-only property of the SpeechSynthesis interface is a boolean value that returns true if the utterance queue contains as-yet-unspoken utterances.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/SpeechSynthesis/pending)

### `Readonly`speaking[](#speaking)

speaking: boolean

The **`speaking`** read-only property of the SpeechSynthesis interface is a boolean value that returns true if an utterance is currently in the process of being spoken — even if SpeechSynthesis is in a paused state.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/SpeechSynthesis/speaking)

## Methods[](#methods-1)

### addEventListener[](#addeventlistener)

-   addEventListener<[K](#addeventlistenerk) extends "voiceschanged"\>(  
        type: [K](#addeventlistenerk),  
        listener: (this: SpeechSynthesis, ev: [SpeechSynthesisEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisEventMap/)\[[K](#addeventlistenerk)\]) \=> any,  
        options?: boolean | AddEventListenerOptions,  
    ): void[](#addeventlistener-1)
    
    The **`addEventListener()`** method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener)
    
    #### Type Parameters
    
    -   K extends "voiceschanged"
    
    #### Parameters
    
    -   type: [K](#addeventlistenerk)
    -   listener: (this: SpeechSynthesis, ev: [SpeechSynthesisEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisEventMap/)\[[K](#addeventlistenerk)\]) \=> any
    -   `Optional`options: boolean | AddEventListenerOptions
    
    #### Returns void
    
    Overrides EventTarget.addEventListener
    
-   addEventListener(  
        type: string,  
        listener: [EventListenerOrEventListenerObject](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.EventListenerOrEventListenerObject/),  
        options?: boolean | AddEventListenerOptions,  
    ): void[](#addeventlistener-2)
    
    The **`addEventListener()`** method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener)
    
    #### Parameters
    
    -   type: string
    -   listener: [EventListenerOrEventListenerObject](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.EventListenerOrEventListenerObject/)
    -   `Optional`options: boolean | AddEventListenerOptions
    
    #### Returns void
    
    Overrides EventTarget.addEventListener
    

### cancel[](#cancel)

-   cancel(): void[](#cancel-1)
    
    The **`cancel()`** method of the SpeechSynthesis interface removes all utterances from the utterance queue.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/SpeechSynthesis/cancel)
    
    #### Returns void
    

### dispatchEvent[](#dispatchevent)

-   dispatchEvent(event: Event): boolean[](#dispatchevent-1)
    
    The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
    
    #### Parameters
    
    -   event: Event
    
    #### Returns boolean
    
    Inherited from EventTarget.dispatchEvent
    

### getVoices[](#getvoices)

-   getVoices(): [SpeechSynthesisVoice](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisVoice/)\[\][](#getvoices-1)
    
    The **`getVoices()`** method of the SpeechSynthesis interface returns a list of SpeechSynthesisVoice objects representing all the available voices on the current device.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/SpeechSynthesis/getVoices)
    
    #### Returns [SpeechSynthesisVoice](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisVoice/)\[\]
    

### pause[](#pause)

-   pause(): void[](#pause-1)
    
    The **`pause()`** method of the SpeechSynthesis interface puts the SpeechSynthesis object into a paused state.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/SpeechSynthesis/pause)
    
    #### Returns void
    

### removeEventListener[](#removeeventlistener)

-   removeEventListener<[K](#removeeventlistenerk) extends "voiceschanged"\>(  
        type: [K](#removeeventlistenerk),  
        listener: (this: SpeechSynthesis, ev: [SpeechSynthesisEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisEventMap/)\[[K](#removeeventlistenerk)\]) \=> any,  
        options?: boolean | EventListenerOptions,  
    ): void[](#removeeventlistener-1)
    
    The **`removeEventListener()`** method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener)
    
    #### Type Parameters
    
    -   K extends "voiceschanged"
    
    #### Parameters
    
    -   type: [K](#removeeventlistenerk)
    -   listener: (this: SpeechSynthesis, ev: [SpeechSynthesisEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisEventMap/)\[[K](#removeeventlistenerk)\]) \=> any
    -   `Optional`options: boolean | EventListenerOptions
    
    #### Returns void
    
    Overrides EventTarget.removeEventListener
    
-   removeEventListener(  
        type: string,  
        listener: [EventListenerOrEventListenerObject](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.EventListenerOrEventListenerObject/),  
        options?: boolean | EventListenerOptions,  
    ): void[](#removeeventlistener-2)
    
    The **`removeEventListener()`** method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener)
    
    #### Parameters
    
    -   type: string
    -   listener: [EventListenerOrEventListenerObject](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.EventListenerOrEventListenerObject/)
    -   `Optional`options: boolean | EventListenerOptions
    
    #### Returns void
    
    Overrides EventTarget.removeEventListener
    

### resume[](#resume)

-   resume(): void[](#resume-1)
    
    The **`resume()`** method of the SpeechSynthesis interface puts the SpeechSynthesis object into a non-paused state: resumes it if it was already paused.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/SpeechSynthesis/resume)
    
    #### Returns void
    

### speak[](#speak)

-   speak(utterance: [SpeechSynthesisUtterance](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisUtterance/)): void[](#speak-1)
    
    The **`speak()`** method of the SpeechSynthesis interface adds an utterance to the utterance queue; it will be spoken when any other utterances queued before it have been spoken.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/SpeechSynthesis/speak)
    
    #### Parameters
    
    -   utterance: [SpeechSynthesisUtterance](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisUtterance/)
    
    #### Returns void
