NLU module updates, threaded through the Spokestack
wrapper
#123
Conversation
7c8933b
to
5433f64
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know I wasn't tagged, but have a couple of comments. I agree with the sentiment, and AutoCloseable
is a reasonable thing to implement to add clarity to resource management, but it does bother me that there's two different semantics in use (stop/start & prepare/release). Additionally, unclear how initialize
relates to this change (from a client's perspective). Finally, if you came across a use case from the tray work that motivated this change, it would be good to share that.
* <p> | ||
* This is useful for stopping passive listening (listening for wakeword | ||
* activation); for fully releasing <em>all</em> internal resources held by | ||
* Spokestack, see {@link #release()}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Spokestack, see {@link #release()}. | |
* the Spokestack pipeline, see {@link #release()}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Saying "the Spokestack pipeline" here introduces confusion between Spokestack (a collection of all modules), and the speech pipeline. This is meant to refer to the former.
I agree with the Because of the primacy of the speech pipeline, I think it's still useful to think of Another possibility I didn't touch on here is that of expanding the speech pipeline API to more closely resemble Python's. Including a |
Oh, and I'm not sure what you're referring to with Edit: I missed your last sentence on my first read-through. This change isn't motivated by the tray, but by me noticing that there was no way for an application to temporarily release resources held by the NLU module, but the other modules supported this use pattern. Once I'd put the modules on equal footing, it made sense to modify the wrapper to expose the full functionality. |
This change makes the NLUService extend AutoCloseable, which forces a `close()` method on all implementors. The existing service uses this to release TensorFlow model and vocab resources. On the NLU manager, `close()` has been duplicated as a convenience method called `release()`, named for parallelism with the newly added `prepare()` method, which is its inverse. The NLU module was the last one to provide release/prepare support, so adding it suggests a change to the Spokestack wrapper API, removing the release/prepare methods used for the TTS module and repurposing them to handle resources for both NLU and TTS.
5433f64
to
14123ce
Compare
The main purpose of the start/stop states are to minimize resource usage in the application when the speech features have been disabled. If you want to be able to stop listening during tts while not tearing everything down, it would probably make sense to add the pause/resume functions to the pipeline and then automatically call them in your spokestack wrapper during tts. |
This adds `pause` and `resume` methods to the speech pipeline to allow listening to be temporarily suspsended without fully releasing the pipeline's resources. In turn, `prepare` and `release` in the `Spokestack` wrapper have been removed, with `start` and `stop` controlling the resources of all modules instead of just the speech pipeline. `pause` and `resume` have been threaded through the wrapper and are automatically called by TTS events.
In consideration of the feedback here, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks like a simple solution, nice work
I'd like an API sanity check here—see if the commit message pasted below makes sense. Further explanation: I think we need to keep
Spokestack.start()
andstop()
limited to interacting with the speech pipeline—a user might want to force the pipeline to stop listening while playing a TTS prompt, sostop()
can't callclose()
on TTS—but it would also be good to have the ability to fully release all modules' resources if necessary.Would it be less surprising if
start()
also ranprepare()
implicitly?This change makes the NLUService extend AutoCloseable, which forces a
close()
method on all implementors. The existing service uses this torelease TensorFlow model and vocab resources.
On the NLU manager,
close()
has been duplicated as a conveniencemethod called
release()
, named for parallelism with the newlyadded
prepare()
method, which is its inverse.The NLU module was the last one to provide release/prepare
support, so adding it suggests a change to the Spokestack wrapper
API, removing the release/prepare methods used for the TTS module
and repurposing them to handle resources for both NLU and TTS.