Extension Text-to-Speech API: speak, Voices, Engine, and SSML
How extension tts and ttsEngine APIs speak text, queue utterances, choose voices, handle events, and register custom speech engines.
This page summarizes Chrome extension platform documentation on text-to-speech (TTS) for extensions. Consumer extensions call browser.tts (also exposed as chrome.tts in Manifest V2 reference material); separate extensions can register replacement speech engines with browser.ttsEngine / chrome.ttsEngine. The pair covers everything from “read this string aloud” to shipping a cloud or on-device synthesizer inside an extension.
browser.tts and chrome.tts: what the client API is for
Section titled “browser.tts and chrome.tts: what the client API is for”The client API plays synthesized speech from an extension context—typically a service worker or background page after you declare the tts permission.
Use the chrome.tts API to play synthesized text-to-speech (TTS). See also the related ttsEngine API, which allows an extension to implement a speech engine.
— Chrome, browser.tts
On Windows (SAPI 5), macOS, and ChromeOS, Chrome uses OS speech synthesis. On every platform, users can install extensions that register as alternative engines via browser.ttsEngine.
| Role | Permission | Primary methods |
|---|---|---|
| Speak text from your extension | tts |
speak(), stop(), pause(), resume(), getVoices() |
| Provide voices other extensions use | ttsEngine |
onSpeak, onStop, updateVoices(), optional onSpeakWithAudioStream |
Language tags passed to speak() follow the same style as other extension i18n APIs: ISO-style codes such as en or en-US (see browser.i18n for language code conventions).
tts.speak(): how to make an extension read text aloud
Section titled “tts.speak(): how to make an extension read text aloud”speak() takes an utterance string (plain text or SSML), optional TtsOptions, and optionally a callback. The utterance limit is 32,768 characters.
browser.tts.speak('Hello, world.');browser.tts.speak('Hello, world.', { lang: 'en-US', rate: 2.0 });By default, each speak() interrupts ongoing speech and clears the queue. To append instead, set enqueue: true on the second call:
browser.tts.speak('Speak this first.');browser.tts.speak( 'Speak this next, when the first sentence is done.', { enqueue: true });stop() ends current speech and drops pending queue items; it also clears a paused state before the next speak(). pause() may halt mid-utterance; resume() continues, and either resume() or stop() ends the paused state.
Rate, pitch, volume, and voice selection
Section titled “Rate, pitch, volume, and voice selection”Use lang (en, en-US, en-GB, zh-CN, and similar) so Chrome picks a synthesizer that supports the language and region. Optional voiceName and extensionId pin a specific engine when several extensions expose the same name.
| Option | Range / behavior |
|---|---|
rate |
Default 1.0 (~180–220 WPM); 2.0 is twice as fast. API disallows below 0.1 or above 10.0; voices may clamp further. |
pitch |
0–2, default 1.0 |
volume |
0–1, default 1.0 |
gender |
Deprecated; ignored |
Engines receiving SpeakOptions through ttsEngine must accept rate between 0.1 and 10.0 without error—clip to the voice’s real range instead of failing.
tts events: queueing, progress, and errors
Section titled “tts events: queueing, progress, and errors”Syntax problems surface quickly via an optional speak() callback: it runs before synthesis starts; check browser.runtime.lastError (or chrome.runtime.lastError). Runtime synthesis failures need onEvent in options:
browser.tts.speak( utterance, { onEvent(event) { if (event.type === 'error') { console.log(event.errorMessage); } } }, () => { if (browser.runtime.lastError) { console.log(browser.runtime.lastError.message); } });Event types include start, word, sentence, marker, end, interrupted, cancelled, error, plus pause and resume when supported. end, interrupted, cancelled, and error are final—no further events for that utterance.
Some voices omit events entirely. Filter with requiredEventTypes or pick a voice from getVoices() whose eventTypes meet your needs. Use desiredEventTypes to limit which events you receive.
SSML in tts.speak(): markup rules and engine limits
Section titled “SSML in tts.speak(): markup rules and engine limits”Utterances may use Speech Synthesis Markup Language (SSML). The first argument must be a complete SSML document with an XML declaration and a top-level speak element—not a fragment.
Engines may ignore unsupported tags but must still speak the underlying text. Not every engine supports every SSML feature.
getVoices() and onVoicesChanged: list available synthesizers
Section titled “getVoices() and onVoicesChanged: list available synthesizers”getVoices() returns TtsVoice objects with voiceName, lang, extensionId, eventTypes, and optional remote (network engine—higher latency and possible bandwidth cost). Subscribe to browser.tts.onVoicesChanged when engines install voices or call ttsEngine.updateVoices().
Default voice selection is automatic from lang unless you set voiceName / extensionId.
ttsEngine: how to build a custom speech engine extension
Section titled “ttsEngine: how to build a custom speech engine extension”An engine extension intercepts matching tts.speak() / tts.stop() calls when manifest voices and registered listeners align.
Use the chrome.ttsEngine API to implement a text-to-speech(TTS) engine using an extension. If your extension registers using this API, it will receive events containing an utterance to be spoken and other parameters when any extension or Chrome App uses the tts API to generate speech.
— Chrome, browser.ttsEngine
Engines may stream from a server, play HTML5 audio, show captions, or log utterances—any web technology is allowed.
Manifest voices and updateVoices()
Section titled “Manifest voices and updateVoices()”Declare permissions: ["ttsEngine"] and a tts_engine.voices array. voice_name is required and should identify both voice and engine. lang is optional but recommended (one voice per language is normal; omit lang only for a deliberate “any language” voice). List event_types when the engine can report progress—at minimum end is strongly recommended for queueing.
Manifest keys use snake_case (voice_name); updateVoices() uses camelCase (voiceName) and replaces manifest-declared voices.
onSpeak and onStop: required listeners
Section titled “onSpeak and onStop: required listeners”You must register both onSpeak and onStop. Without both, the extension will not intercept speech regardless of manifest voices.
Caution: If your extension does not register listeners for both onSpeak and onStop, it will not intercept any speech calls, regardless of what is in the manifest.
— Chrome, browser.ttsEngine
Routing is deterministic: Chrome sends a request when manifest voice parameters match speak() options and listeners exist—engines cannot dynamically decline a matched request.
Engines send start, word, sentence, marker, end, and error via sendTtsEvent. Chrome synthesizes interrupted and cancelled for clients; engines do not emit those.
onSpeakWithAudioStream and language lifecycle
Section titled “onSpeakWithAudioStream and language lifecycle”From Chrome 92+, onSpeakWithAudioStream lets the engine push linear PCM (Float32Array-style) mono buffers at audioStreamOptions.sampleRate while Chrome plays audio and dispatches client events.
From Chrome 131–132+, engines may handle onInstallLanguageRequest, onLanguageStatusRequest, and onUninstallLanguageRequest, reporting status through updateLanguage() and refreshing voices with updateVoices() after install or uninstall.
Optional onPause / onResume pair with client tts.pause() / tts.resume(); onStop must clear paused state even if speech already stopped (no error in that case).
Common mistakes when using extension TTS
Section titled “Common mistakes when using extension TTS”- Calling
speak()withoutlangwhen multiple voices exist, then wondering why the wrong language plays. - Expecting the
speak()callback to mean “playback finished”—onlyonEventwithtype: 'end'marks completion. - Using
enqueue: truewith an engine that never firesend. - Publishing a
ttsEnginemanifest but forgettingonStop(silently breaks interception). - Passing SSML fragments instead of a full document with XML header and
speakroot. - Relying on deprecated
genderin client or engine options.
Input method APIs such as browser.input.ime (contextID, spellCheck, field type) are unrelated to TTS—they target custom IMEs in text fields, not speech output.
How to check this on your site
Section titled “How to check this on your site”-
Add
"tts"topermissionsinmanifest.jsonfor a client extension, or"ttsEngine"plus atts_engine.voicesblock for an engine—see browser.tts and browser.ttsEngine. -
Load the unpacked extension in
chrome://extensions, open the service worker DevTools console, and runchrome.tts.getVoices(console.log)to confirm voices andeventTypes. -
Run
chrome.tts.speak('Test utterance', { lang: 'en-US', onEvent: console.log })and confirmstartandend(orerrorwitherrorMessage). -
For an engine build, verify both
chrome.ttsEngine.onSpeakandonStoplisteners are registered before testing; trigger speech from a second extension that targets yourvoice_name. -
You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”If something on this page does not match your experience or the official APIs, email yimasynthetic@gmail.com with the page URL and the exact sentence you think is wrong or unclear.