Last active
April 7, 2017 00:49
-
-
Save leonardokl/f7129f73941bca14070a50e393cbc9fb to your computer and use it in GitHub Desktop.
tts.js
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
/* global SpeechSynthesisUtterance */ | |
const speechSynthesis = window.speechSynthesis | |
const synthesizeSpeech = (text, { lang = 'pt-BR' } = {}) => { | |
const utterThis = new SpeechSynthesisUtterance(text) | |
const voices = speechSynthesis.getVoices() | |
const selectedVoice = voices.find(i => i.lang === lang) | |
utterThis.voice = selectedVoice | |
utterThis.pitch = 1 | |
utterThis.rate = 1 | |
speechSynthesis.speak(utterThis) | |
} | |
export default synthesizeSpeech | |
// synthesizeSpeech('TESTE') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment