
The Web Speech API Is Built Into Your Browser (and It's Actually Useful)
There's a fully functional text-to-speech engine built into every modern browser. No API keys, no third-party services, no npm packages. It's the Web Speech API, specifically the SpeechSynthesis interface, and it works with four lines of JavaScript. const utterance = new SpeechSynthesisUtterance ( ' Hello, world ' ); speechSynthesis . speak ( utterance ); That's it. The browser speaks the text aloud using system voices. I didn't know this API existed until I needed to build an accessibility feature for a reading application, and I was genuinely surprised by how capable it is. Getting the available voices Each browser and operating system provides a different set of voices. macOS ships with dozens. Windows has a handful. Chrome on Android uses Google's voices. You can list them: function getVoices () { return new Promise ( resolve => { let voices = speechSynthesis . getVoices (); if ( voices . length ) { resolve ( voices ); return ; } speechSynthesis . onvoiceschanged = () => { resolve
Continue reading on Dev.to Tutorial
Opens in a new tab




