Created
October 13, 2021 16:27
-
-
Save mizanmahi/ccf14bc6ef4de7f224e7fb2b64fab463 to your computer and use it in GitHub Desktop.
Js text to 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
const textToSpeech = (text) => { | |
const speech = new SpeechSynthesisUtterance(text); | |
[speech.voice] = speechSynthesis.getVoices(); | |
// sp.rate = ?; //speed of the voice. Default value is 1. lowest = 0.1 and highest = 10 | |
// sp.pitch = ?; //pitch of the voice. Default value is 1. lowest = 0 and highest = 2 | |
speechSynthesis.speak(speech); | |
}; | |
textToSpeech('Hello TalkJS!'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment