Chrome Extensions Gets Text-to-speech (TTs) APIs

Google Chrome now includes a Text-to-Speech (TTS) API that's simple to use, powerful, and flexible for users, revealed Dominic Mazzoni, Software Engineer. In fact, the "API is powerful enough that ChromeVox, the Chrome OS screen reader for visually impaired users, is built using this API," he said.Mazzoni explains, "If a user doesn't have any voices […]

Google Chrome now includes a Text-to-Speech (TTS) API that's simple to use, powerful, and flexible for users, revealed Dominic Mazzoni, Software Engineer. In fact, the "API is powerful enough that ChromeVox, the Chrome OS screen reader for visually impaired users, is built using this API," he said.

Mazzoni explains, "If a user doesn't have any voices installed, Chrome automatically speaks using the native speech capabilities of your Windows or Mac operating system, if possible. Chrome OS comes with a built-in speech engine, too. For now, there's unfortunately no default voice support on Linux - but TTS is fully supported once users first install a voice from the Chrome Web Store."

"With the new API, you just need to add "tts" to your permissions and then write:

chrome.tts.speak('Hello, world!');

It's also very easy to change the rate, pitch, and volume:

chrome.tts.speak('Can you understand me now?', {rate: 0.6});
chrome text-to-speech demo

And, to "get fancier and synchronize speech with your application, you can register to receive callbacks when the speech starts and finishes. When a TTS engine supports it, you can get callbacks for individual words too," explains Mazzoni.

You can also get a list of possible voices and ask for a particular voice - more on this below. All the details can be found in the TTS API docs, and through the example code on the samples page.

He writes, "The TTS Engine API enables you to implement a speech engine as an extension for Chrome. Essentially, you provide some information about your voice in the extension manifest and then register a JavaScript function that gets called when the client calls chrome.tts.speak. Your extension then takes care of synthesizing and outputting the speech - using any web technology you like, including HTML5 Audio, the new Web Audio API, or Native Client."

Here are examples you can try now:

chrome text-to-speech demo apps

"These voices both use Native Client to synthesize speech. The experience is very easy for end users: just click and install one of those voices, and immediately any talking app or extension has the ability to speak using that voice," Mazzoni said.