Corti
Corti is a drop in replacement for the browser's SpeechRecognition object. It mocks some of the behaviour of the native object to facilitate automated testing, and provides a number of extra methods beyond the spec to help testing.
For an example of using Corti to test a real project, check out SpeechKITT.
To easily use Speech Recognition in your own project, check out annyang.
Sample Test With Corti
Corti.patch();
var recognition = new window.SpeechRecognition();
expect(recognition.isStarted()).toBe(false);
recognition.onstart = function() {console.log('I\'m listening');};
recognition.addEventListener('end', function() {console.log('Quiet');});
recognition.start();
expect(recognition.isStarted()).toBe(true);
recognition.abort();
expect(recognition.isStarted()).toBe(false);
Corti.unpatch();
Methods Currently Mocked
- start()
- abort()
- stop()
- addEventListener()
Author
Tal Ater: @TalAter
License
Licensed under MIT.