Last active
February 27, 2024 22:38
-
-
Save bramus/e27fcb783f469b6585007a7453e1bb5a to your computer and use it in GitHub Desktop.
Text-to-Speech with the Web Speech API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 🗣 Text-to-Speech with the Web Speech API's SpeechSynthesis | |
// @link https://gist.github.com/bramus/e27fcb783f469b6585007a7453e1bb5a | |
// @ref https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis | |
((text) => { | |
// Create an Utterance (= speech request) | |
const utter = new SpeechSynthesisUtterance(text); | |
// Set the voice | |
utter.voice = window.speechSynthesis.getVoices()[0]; | |
// Speak! | |
window.speechSynthesis.speak(utter); | |
})('Hello from the DevTools'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment