Created
January 18, 2018 06:53
-
-
Save leaysgur/421f42f9b76449ef826fa55c64a412cd to your computer and use it in GitHub Desktop.
Continuous recognition by SpeechRecognition API
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 recognitions = []; | |
function R() { | |
const recognition = new window.SpeechRecognition(); | |
recognition.onresult = function(ev) { | |
const resultText = ev.results[0][0].transcript; | |
console.warn(resultText); | |
}; | |
recognition.onend = function() { | |
recognitions.push(new R()); | |
}; | |
// all events | |
[ | |
'onaudioend', | |
'onaudiostart', | |
'onerror', | |
'onnomatch', | |
'onsoundend', | |
'onsoundstart', | |
'onspeechend', | |
'onspeechstart', | |
'onstart', | |
].forEach(evName => { | |
recognition[evName] = function(ev) { | |
// console.log(evName, ev); | |
}; | |
}); | |
recognition.start(); | |
return recognition; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment