Sometimes, we want to use Google Text-To-Speech in JavaScript.
In this article, we’ll look at how to use Google Text-To-Speech in JavaScript.
How to use Google Text-To-Speech in JavaScript?
To use Google Text-To-Speech in JavaScript, we use the SpeechSynthesisUtterance
constructor.
For instance, we write
const msg = new SpeechSynthesisUtterance("Hello World");
window.speechSynthesis.speak(msg);
to create a SpeechSynthesisUtterance
object with the text string we want the computer to speak.
Then we call window.speechSynthesis.speak
with msg
to speak it.
Conclusion
To use Google Text-To-Speech in JavaScript, we use the SpeechSynthesisUtterance
constructor.