JSFiddle - React, Tailwind, and code Playground
HTML
<h1>Web Speech API example for Novo SGA</h1>
<p>Compatibility: <a href="http://caniuse.com/#search=speech">http://caniuse.com/#search=speech</a></p>
<a href="novosga.org">novosga.org</a>
JavaScript
function speech(text, lang) {
return new Promise(function (resolve, reject) {
var msg = new SpeechSynthesisUtterance();
msg.text = text;
msg.lang = lang;
msg.onend = function(e) {
resolve(event);
};
speechSynthesis.speak(msg);
});
}
var lang = 'pt-BR';
speech('Senha', lang)
.then(() => {
speech('001', lang)
.then(() => {
speech('guichê', lang)
.then(() => {
speech('3', lang)
})
})
})