Post

Converting text to speech with Javascript

How to convert text to speech in the browser using the JavaScript Web Speech API and SpeechSynthesisUtterance.

Converting text to speech with Javascript

API Web Speech & Demo

1
2
3
4
5
6
7
8
function speak (message) {
   var msg = new SpeechSynthesisUtterance(message)
   var voices = window.speechSynthesis.getVoices()
   msg.voice = voices[0]
   window.speechSynthesis.speak(msg)
}

speak('Hello. I am Khuong')

👉 Demo

References

This post is licensed under CC BY 4.0 by the author.