Last active
August 29, 2015 14:07
-
-
Save jagill/8ff45414c9ad640a409a to your computer and use it in GitHub Desktop.
Listener tech spec
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
/* | |
* A Listener has four states: stopped, listening, continuous (listening), and stopping. | |
* (we'll handling pending/not-supported later). | |
* It starts off as stopped. It can be started normally, or in continuous mode. | |
* | |
* Listener Methods | |
* ================ | |
* | |
* Listener.start (normal): | |
* listener.continous = false | |
* recognizer.continuous = listener.continous | |
* recognizer.start() | |
* | |
* Listener.start (continuous): | |
* listener.continous = true | |
* recognizer.continuous = listener.continuous | |
* set longListenTimeout # to handle Google's API from being unresponsive after 60 seconds. | |
* | |
* Listener.cancel: | |
* return if state == stopped | |
* listener.continuous = false | |
* recognizer.abort() | |
* clear abortTimeout | |
* clear finalizePendingTimeout | |
* clear longListenTimeout | |
* | |
* Listener.stop: | |
* return if state == stopped | |
* if state == stopping, listener.cancel() instead | |
* listener.continuous = false | |
* state = stopping | |
* recognizer.stop() | |
* if pendingResult: | |
* Should finalize pendingResult and emit? Would that duplicate? | |
* set abortTimeout # to handle chrome bug where it doesn't always end | |
* clear longListenTimeout | |
* clear finalizePendingTimeout | |
* | |
* | |
* Recognizer events | |
* ================= | |
* onaudiostart: ignored | |
* onsoundstart: ignored | |
* onspeechstart: ignored | |
* onspeechend: ignored | |
* onsoundend: ignored | |
* onaudioend: ignored | |
* onnomatch: ignored for now | |
* | |
* onresult: | |
* clear finalizePendingTimeout | |
* if result.final: | |
* pendingResult = null | |
* emit result, naturalFinal = true | |
* else: | |
* if listener.interimResults: | |
* emit result | |
* pendingResult = result | |
* set finalizePendingTimeout | |
* | |
* onerror: | |
* "no-speech": ignore | |
* "aborted": ignore | |
* "audio-capture": emit | |
* "network": emit | |
* "not-allowed": emit | |
* "service-not-allowed": emit | |
* "bad-grammar": emit | |
* "language-not-supported": emit | |
* | |
* onstart: | |
* state = listening | |
* emit start | |
* | |
* onend: | |
* if continous == true: | |
* recognizer.start() | |
* else: | |
* state = stopped | |
* clearAbortTimeout | |
* emit end | |
* | |
*/ |
#34: it should emit IMO bc the result was never finalized/emitted.
#63: we fire this event currently right? It's annoying though bc we force abort a lot
Can you also add descriptions/functionality for the 3 timeouts we have: longListen, onEndAbort, and setEarlyFinalResult?
Thanks for putting this together. I think this gist should be our source of truth for what the listener should behave.
#59: add if continuous
#34: move to recognizer.onend
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
#9: we'll also set the finalresult time out here