Skip to content

Instantly share code, notes, and snippets.

View leonardokl's full-sized avatar

Leonardo Luiz leonardokl

View GitHub Profile
@leonardokl
leonardokl / tts.js
Last active April 7, 2017 00:49
tts.js
/* 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