Corti

👂 Replace window.SpeechRecognition with a mock object and automate your tests

MIT License

Downloads
732
Stars
19
Corti - Mocked soundstart event Latest Release

Published by TalAter about 8 years ago

[Added] Allow attaching events to onsoundstart

[Fixed] say() no longer does anything when Speech Recognition is not started

Corti - Mocked the behavior of SpeechRecognition.continuous

Published by TalAter about 8 years ago

Added support for turning continuous mode on and off.

Corti - Fixed setting lang to undefined

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'

Corti - Added support for mocking actual speech recognition events

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");