---
title: "SpeechSynthesisUtterance | 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 SpeechSynthesisUtterance

The **`SpeechSynthesisUtterance`** interface of the Web Speech API represents a speech request. It contains the content the speech service should read and information about how to read it (e.g., language, pitch and volume.)

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

interface SpeechSynthesisUtterance {  
    [lang](#lang): string;  
    [onboundary](#onboundary):  
        | ((this: SpeechSynthesisUtterance, ev: [SpeechSynthesisEvent](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisEvent/)) \=> any)  
        | null;  
    [onend](#onend):  
        | ((this: SpeechSynthesisUtterance, ev: [SpeechSynthesisEvent](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisEvent/)) \=> any)  
        | null;  
    [onerror](#onerror):  
        | (  
            (this: SpeechSynthesisUtterance, ev: [SpeechSynthesisErrorEvent](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisErrorEvent/)) \=> any  
        )  
        | null;  
    [onmark](#onmark):  
        | ((this: SpeechSynthesisUtterance, ev: [SpeechSynthesisEvent](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisEvent/)) \=> any)  
        | null;  
    [onpause](#onpause):  
        | ((this: SpeechSynthesisUtterance, ev: [SpeechSynthesisEvent](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisEvent/)) \=> any)  
        | null;  
    [onresume](#onresume):  
        | ((this: SpeechSynthesisUtterance, ev: [SpeechSynthesisEvent](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisEvent/)) \=> any)  
        | null;  
    [onstart](#onstart):  
        | ((this: SpeechSynthesisUtterance, ev: [SpeechSynthesisEvent](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisEvent/)) \=> any)  
        | null;  
    [pitch](#pitch): number;  
    [rate](#rate): number;  
    [text](#text): string;  
    [voice](#voice): [SpeechSynthesisVoice](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisVoice/) | null;  
    [volume](#volume): number;  
    [addEventListener](#addeventlistener-1)<[K](#addeventlistenerk) extends keyof [SpeechSynthesisUtteranceEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisUtteranceEventMap/)\>(  
        type: [K](#addeventlistenerk),  
        listener: (  
            this: SpeechSynthesisUtterance,  
            ev: [SpeechSynthesisUtteranceEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisUtteranceEventMap/)\[[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;  
    [dispatchEvent](#dispatchevent-1)(event: Event): boolean;  
    [removeEventListener](#removeeventlistener-1)<[K](#removeeventlistenerk) extends keyof [SpeechSynthesisUtteranceEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisUtteranceEventMap/)\>(  
        type: [K](#removeeventlistenerk),  
        listener: (  
            this: SpeechSynthesisUtterance,  
            ev: [SpeechSynthesisUtteranceEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisUtteranceEventMap/)\[[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;  
}

#### Hierarchy

-   EventTarget
    -   SpeechSynthesisUtterance

##### Index

### Properties[](#properties)

[lang](#lang) [onboundary](#onboundary) [onend](#onend) [onerror](#onerror) [onmark](#onmark) [onpause](#onpause) [onresume](#onresume) [onstart](#onstart) [pitch](#pitch) [rate](#rate) [text](#text) [voice](#voice) [volume](#volume)

### Methods[](#methods)

[addEventListener](#addeventlistener) [dispatchEvent](#dispatchevent) [removeEventListener](#removeeventlistener)

## Properties[](#properties-1)

### lang[](#lang)

lang: string

The **`lang`** property of the SpeechSynthesisUtterance interface gets and sets the language of the utterance.

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

### onboundary[](#onboundary)

onboundary:  
    | ((this: SpeechSynthesisUtterance, ev: [SpeechSynthesisEvent](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisEvent/)) \=> any)  
    | null

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

### onend[](#onend)

onend:  
    | ((this: SpeechSynthesisUtterance, ev: [SpeechSynthesisEvent](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisEvent/)) \=> any)  
    | null

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

### onerror[](#onerror)

onerror:  
    | (  
        (this: SpeechSynthesisUtterance, ev: [SpeechSynthesisErrorEvent](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisErrorEvent/)) \=> any  
    )  
    | null

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

### onmark[](#onmark)

onmark:  
    | ((this: SpeechSynthesisUtterance, ev: [SpeechSynthesisEvent](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisEvent/)) \=> any)  
    | null

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

### onpause[](#onpause)

onpause:  
    | ((this: SpeechSynthesisUtterance, ev: [SpeechSynthesisEvent](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisEvent/)) \=> any)  
    | null

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

### onresume[](#onresume)

onresume:  
    | ((this: SpeechSynthesisUtterance, ev: [SpeechSynthesisEvent](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisEvent/)) \=> any)  
    | null

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

### onstart[](#onstart)

onstart:  
    | ((this: SpeechSynthesisUtterance, ev: [SpeechSynthesisEvent](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisEvent/)) \=> any)  
    | null

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

### pitch[](#pitch)

pitch: number

The **`pitch`** property of the SpeechSynthesisUtterance interface gets and sets the pitch at which the utterance will be spoken at.

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

### rate[](#rate)

rate: number

The **`rate`** property of the SpeechSynthesisUtterance interface gets and sets the speed at which the utterance will be spoken at.

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

### text[](#text)

text: string

The **`text`** property of the SpeechSynthesisUtterance interface gets and sets the text that will be synthesized when the utterance is spoken.

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

### voice[](#voice)

voice: [SpeechSynthesisVoice](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisVoice/) | null

The **`voice`** property of the SpeechSynthesisUtterance interface gets and sets the voice that will be used to speak the utterance.

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

### volume[](#volume)

volume: number

The **`volume`** property of the SpeechSynthesisUtterance interface gets and sets the volume that the utterance will be spoken at.

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

## Methods[](#methods-1)

### addEventListener[](#addeventlistener)

-   addEventListener<[K](#addeventlistenerk) extends keyof [SpeechSynthesisUtteranceEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisUtteranceEventMap/)\>(  
        type: [K](#addeventlistenerk),  
        listener: (  
            this: SpeechSynthesisUtterance,  
            ev: [SpeechSynthesisUtteranceEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisUtteranceEventMap/)\[[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 keyof [SpeechSynthesisUtteranceEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisUtteranceEventMap/)
    
    #### Parameters
    
    -   type: [K](#addeventlistenerk)
    -   listener: (this: SpeechSynthesisUtterance, ev: [SpeechSynthesisUtteranceEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisUtteranceEventMap/)\[[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
    

### 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
    

### removeEventListener[](#removeeventlistener)

-   removeEventListener<[K](#removeeventlistenerk) extends keyof [SpeechSynthesisUtteranceEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisUtteranceEventMap/)\>(  
        type: [K](#removeeventlistenerk),  
        listener: (  
            this: SpeechSynthesisUtterance,  
            ev: [SpeechSynthesisUtteranceEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisUtteranceEventMap/)\[[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 keyof [SpeechSynthesisUtteranceEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisUtteranceEventMap/)
    
    #### Parameters
    
    -   type: [K](#removeeventlistenerk)
    -   listener: (this: SpeechSynthesisUtterance, ev: [SpeechSynthesisUtteranceEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SpeechSynthesisUtteranceEventMap/)\[[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
