var speech = new SpeechSynthesisUtterance();
var all_voices = speechSynthesis.getVoices();
speech.voice = all_voices[1];
speech.text = "Hello John. Welcome to Devsheet";
speechSynthesis.speak(speech);
In the above code, we created a new object speech from SpeechSynthesisUtterance. You can add text, language, and voice objects to it. After creating a speech object and its configuration you can pass this to speechSynthesis.speak() method and you can hear the text that you provided in speech.text
var speech = new SpeechSynthesisUtterance();
speech.text = "Replace this text with your text";
const all_voices = speechSynthesis.getVoices();
speech.voice = all_voices[1];
var speech = new SpeechSynthesisUtterance();
speech.rate = -2;
0 Comments