👂 Replace window.SpeechRecognition with a mock object and automate your tests
MIT License
Published by TalAter about 8 years ago
Added support for turning continuous mode on and off.
Published by TalAter almost 9 years ago
Previously setting lang to undefined threw an error.
It will now correctly set recognition.lang to a string: 'undefined'
Published by TalAter almost 9 years ago
Added say()
utility method to simulate voice input. This will emit a result event which you can listen to.
// Patch the current environment with a mock Speech Recognition object
Corti.patch();
// Interact with the mock object, like you would with the real SpeechRecognition object
var recognition = new window.SpeechRecognition();
recognition.addEventListener('result', function(sre) {
console.log(sre.results.item(sre.resultIndex).item(0).transcript);
});
recognition.start();
// Simulate speech recognition
recognition.say("Next time you want to stab me in the back, have the guts to do it to my face");