Last active
October 21, 2021 05:49
-
-
Save ganmahmud/8770a5c213d551655d0355f8162b3c19 to your computer and use it in GitHub Desktop.
Text to Speech with JavaScript
This file contains hidden or 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