What it does
- Allows an extension to register itself as a source of synthesized speech.
- Other extensions (or the browser itself) that use the
chrome.ttsAPI can then select and use the voices provided by this engine. - The extension receives speech requests (text and parameters) and must respond with the corresponding audio data.
When to use it
This is a highly specialized permission for extensions that want to provide their own speech synthesis capabilities.
Examples:
- An extension that provides a new, high-quality, or unique voice for text-to-speech.
- An extension that connects to a cloud-based TTS service (like Amazon Polly or Google Cloud TTS) and makes its voices available to the browser.
- An extension that provides voices for a language not supported by the built-in TTS engines.
Manifest Declaration
In addition to the permission, the tts_engine key must be declared in the manifest.
{
"name": "My Custom TTS Engine",
"version": "1.0",
"manifest_version": 3,
"permissions": [
"ttsEngine"
],
"tts_engine": {
"voices": [
{
"voice_name": "My Custom Voice",
"lang": "en-US",
"event_types": ["start", "end", "error"]
}
]
},
"background": {
"service_worker": "background.js"
}
}Security & Privacy
Why is it risky?
This permission allows an extension to provide a new "voice" for your browser's text-to-speech feature. This means that whenever another extension or website tries to read text aloud, this extension will be the one to do it.
The risk is that the extension will receive all the text it is asked to speak. If another extension wants to read your private email aloud, this TTS Engine extension will get a copy of that email text. If the engine sends this text to an external server to generate the audio, your private text is being shared. You should only use TTS engines from trusted developers.
API Usage Example
The API is event-driven. The extension's service worker listens for speech requests.
// background.js
// This listener is called whenever another part of the browser
// wants to speak using one of our voices.
chrome.ttsEngine.onSpeak.addListener((utterance, options, sendTtsEvent) => {
console.log(`Request to speak: "${utterance}"`);
console.log(`Voice: ${options.voiceName}, Rate: ${options.rate}`);
// Signal that speech has started.
sendTtsEvent({ 'type': 'start', 'charIndex': 0 });
// In a real engine, you would generate or fetch the audio here.
// For this example, we'll just simulate it with a timeout.
const speechDurationMs = utterance.length * 100; // Estimate duration
setTimeout(() => {
// Check if the speech was stopped prematurely
// (This part is complex, would need to handle onStop events)
console.log('Finished speaking.');
// Signal that speech has ended.
sendTtsEvent({ 'type': 'end', 'charIndex': utterance.length });
}, speechDurationMs);
});
// This listener is called if another part of the browser
// wants to stop the current speech.
chrome.ttsEngine.onStop.addListener(() => {
console.log('Speech stopped by request.');
// Here you would stop any audio playback.
});Extensions with the ttsEngine permission
Here are some popular browser extensions that use the "ttsEngine" permission. To explore more, try our Advanced search.