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
// Patch the current environment with a mock Speech Recognition objectCorti; // Interact with the mock object, like you would with the real SpeechRecognition objectvar recognition = ;recognition {console;};recognition;recognition;recognitioncontinuous = true; // Use extra utility methods added to the mock object to assist with testing;recognitionstart;;recognition;; // Simulate speech recognitionrecognition;not;recognition;;
Methods Mocked
- start()
- abort()
- stop()
- addEventListener()
Attributes Mocked
- interimResults
- lang
- continuous
- maxAlternatives
- onstart
- onend
- onresult
Events Mocked
- start
- end
- result
Event Objects Mocked
- SpeechRecognitionEvent
- SpeechRecognitionResultList
- SpeechRecognitionResult
- SpeechRecognitionAlternative
Extra Utility Methods Added To Object
- isStarted()
- say()
Author
Tal Ater: @TalAter
License
Licensed under MIT.