Created
December 2, 2019 04:10
-
-
Save parzibyte/005d1e20342251ae635063e5bea888eb to your computer and use it in GitHub Desktop.
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
let sr = new webkitSpeechRecognition(); | |
// El elemento del DOM en donde vamos a colocar lo escuchado | |
const $texto = document.querySelector("#texto"); | |
sr.onresult = resultado => { | |
let indiceUltimoElemento = resultado.results.length - 1; | |
let textoEscuchado = resultado.results[indiceUltimoElemento][0].transcript; | |
// Concatenamos el HTML | |
$texto.innerHTML += "<br>" + textoEscuchado; | |
} | |
sr.onend = () => { | |
// Simplemente iniciamos de nuevo ;) | |
sr.start(); | |
}; | |
// Y lo iniciamos por primera vez ;) | |
sr.start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment