# SpeechSynthesisUtterance

> The `SpeechSynthesisUtterance` JS object describes a piece of text to be spoken and how to speak it.

## What is SpeechSynthesisUtterance?

The object that holds the text, language, voice, rate, pitch and volume of a phrase passed to `speechSynthesis.speak()`. Fires events like `start`, `end` and `boundary` to sync the UI with speech.

- Topic: Media & Audio
- Type: object
- Browser support: Chrome 33+, Chrome Android 33+, Edge 14+, Firefox 49+, Firefox Android 62+, Safari 7+, Safari iOS 7+

## Example

Wrong:

```js
const u = new SpeechSynthesisUtterance('Bonjour tout le monde');
speechSynthesis.speak(u);
```

Right:

```js
const u = new SpeechSynthesisUtterance('Bonjour tout le monde');
u.lang = 'fr-FR';
speechSynthesis.speak(u);
```

Setting `lang` lets the browser pick a matching voice instead of reading French with the default one.

## Common mistakes

- Leaving `lang` unset, so the text is read with the wrong voice and accent.

## Key points

- The `lang` property matches the language of the text.
- Long texts are split into sentences instead of one huge utterance.

## Interview questions

### How do I know when an utterance has finished speaking?

Listen for its `end` event. Many voices also fire `boundary` events at word or sentence boundaries.

### What values can `rate` and `pitch` take?

`rate` goes from 0.1 to 10 and `pitch` from 0 to 2. For both, 1 is the normal value.

### Can I change an utterance while it is being spoken?

No, changes apply only the next time it is spoken. Cancel the current speech and speak a new utterance instead.

## Related cards

- [speechSynthesis](https://wonderium.dev/js/speech-synthesis.md)
- [Text-to-Speech](https://wonderium.dev/ai/text-to-speech.md)
- [\[lang\]](https://wonderium.dev/html/lang.md)

---

- Level: [JavaScript](https://wonderium.dev/js.md)
- HTML version: https://wonderium.dev/js/speech-synthesis-utterance
- Last updated: 2026-11-25
